Python tkinter.font.Font() Examples

The following are 30 code examples of tkinter.font.Font(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module tkinter.font , or try the search function .
Example #1
Source File: About.py    From python-in-practice with GNU General Public License v3.0 8 votes vote down vote up
def create_tags(self):
        super().create_tags() # for url tag
        # Don't modify predefined fonts!
        baseFont = tkfont.nametofont("TkDefaultFont")
        size = baseFont.cget("size") # -ve is pixels +ve is points
        bodyFont = tkfont.Font(family=baseFont.cget("family"), size=size)
        titleFont = tkfont.Font(family=baseFont.cget("family"),
                size=((size - 8) if size < 0 else (size + 3)),
                weight=tkfont.BOLD)

        self.text.config(font=bodyFont)
        self.text.tag_config("title", font=titleFont,
                foreground="navyblue", spacing1=3, spacing3=5)
        self.text.tag_config("versions", foreground="darkgreen")
        self.text.tag_config("above5", spacing1=5)
        self.text.tag_config("above3", spacing1=3) 
Example #2
Source File: chapter8_07.py    From Tkinter-GUI-Application-Development-Cookbook with MIT License 7 votes vote down vote up
def __init__(self, master=None, **kw):
        now = datetime.datetime.now()
        fwday = kw.pop('firstweekday', calendar.MONDAY)
        year = kw.pop('year', now.year)
        month = kw.pop('month', now.month)
        sel_bg = kw.pop('selectbackground', '#ecffc4')
        sel_fg = kw.pop('selectforeground', '#05640e')

        super().__init__(master, **kw)

        self.selected = None
        self.date = datetime.date(year, month, 1)
        self.cal = calendar.TextCalendar(fwday)
        self.font = tkfont.Font(self)
        self.header = self.create_header()
        self.table = self.create_table()
        self.canvas = self.create_canvas(sel_bg, sel_fg)
        self.build_calendar() 
Example #3
Source File: drt_glue_demo.py    From razzy-spinner with GNU General Public License v3.0 6 votes vote down vote up
def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = Font(font=Button()["font"])
        root.option_add("*Font", self._sysfont)

        # TWhat's our font size (default=same as sysfont)
        self._size = IntVar(root)
        self._size.set(self._sysfont.cget('size'))

        self._boldfont = Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = Font(family='helvetica',
                                    size=self._size.get())
        if self._size.get() < 0: big = self._size.get()-2
        else: big = self._size.get()+2
        self._bigfont = Font(family='helvetica', weight='bold',
                                    size=big) 
Example #4
Source File: About.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_tags(self):
        super().create_tags() # for url tag
        # Don't modify predefined fonts!
        baseFont = tkfont.nametofont("TkDefaultFont")
        size = baseFont.cget("size") # -ve is pixels +ve is points
        bodyFont = tkfont.Font(family=baseFont.cget("family"), size=size)
        titleFont = tkfont.Font(family=baseFont.cget("family"),
                size=((size - 8) if size < 0 else (size + 3)),
                weight=tkfont.BOLD)

        self.text.config(font=bodyFont)
        self.text.tag_config("title", font=titleFont,
                foreground="navyblue", spacing1=3, spacing3=5)
        self.text.tag_config("versions", foreground="darkgreen")
        self.text.tag_config("above5", spacing1=5)
        self.text.tag_config("above3", spacing1=3) 
Example #5
Source File: About.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_tags(self):
        super().create_tags() # for url tag
        # Don't modify predefined fonts!
        baseFont = tkfont.nametofont("TkDefaultFont")
        size = baseFont.cget("size") # -ve is pixels +ve is points
        bodyFont = tkfont.Font(family=baseFont.cget("family"), size=size)
        titleFont = tkfont.Font(family=baseFont.cget("family"),
                size=((size - 8) if size < 0 else (size + 3)),
                weight=tkfont.BOLD)

        self.text.config(font=bodyFont)
        self.text.tag_config("title", font=titleFont,
                foreground="navyblue", spacing1=3, spacing3=5)
        self.text.tag_config("versions", foreground="darkgreen")
        self.text.tag_config("above5", spacing1=5)
        self.text.tag_config("above3", spacing1=3) 
Example #6
Source File: About.py    From python-in-practice with GNU General Public License v3.0 6 votes vote down vote up
def create_tags(self):
        super().create_tags() # for url tag
        # Don't modify predefined fonts!
        baseFont = tkfont.nametofont("TkDefaultFont")
        size = baseFont.cget("size") # -ve is pixels +ve is points
        bodyFont = tkfont.Font(family=baseFont.cget("family"), size=size)
        titleFont = tkfont.Font(family=baseFont.cget("family"),
                size=((size - 8) if size < 0 else (size + 3)),
                weight=tkfont.BOLD)

        self.text.config(font=bodyFont)
        self.text.tag_config("title", font=titleFont,
                foreground="navyblue", spacing1=3, spacing3=5)
        self.text.tag_config("versions", foreground="darkgreen")
        self.text.tag_config("above5", spacing1=5)
        self.text.tag_config("above3", spacing1=3) 
Example #7
Source File: clai_emulator.py    From clai with MIT License 6 votes vote down vote up
def launch(self):
        self.root = tk.Tk()
        self.root.wait_visibility(self.root)
        self.title_font = Font(size=16, weight='bold')
        self.bold_font = Font(weight='bold')

        self.root.geometry("900x600")

        style = ttk.Style(self.root)
        style.configure("TLable", bg="black")

        self.add_toolbar(self.root)
        self.add_send_command_box(self.root)
        self.add_list_commands(self.root)

        self.root.protocol("WM_DELETE_WINDOW", lambda root=self.root: self.on_closing(root))
        self.root.createcommand('exit', lambda root=self.root: self.on_closing(root))

        self.root.mainloop() 
Example #8
Source File: arduino_basics.py    From crappy with GNU General Public License v2.0 6 votes vote down vote up
def create_widgets(self, **kwargs):
    """
    Widgets shown:
    - The frame's title,
    - The checkbutton to enable/disable displaying,
    - The textbox.

    """
    self.top_frame = tk.Frame(self)
    tk.Label(self.top_frame,
        text=kwargs.get('title', '')).grid(row=0, column=0)

    tk.Checkbutton(self.top_frame,
                   variable=self.enabled_checkbox,
                   text="Display?").grid(row=0, column=1)

    self.serial_monitor = tk.Text(self,
                                  relief="sunken",
                                  height=int(self.total_width / 10),
                                  width=int(self.total_width),
                                  font=tkFont.Font(size=kwargs.get("fontsize",
                                                                   13)))

    self.top_frame.grid(row=0)
    self.serial_monitor.grid(row=1) 
Example #9
Source File: zynthian_gui_songeditor.py    From zynthian-ui with GNU General Public License v3.0 6 votes vote down vote up
def drawGrid(self, clearGrid = False):
		font = tkFont.Font(family=zynthian_gui_config.font_topbar[0], size=self.fontsize)
		if clearGrid:
			self.gridCanvas.delete(tkinter.ALL)
			self.columnWidth = self.gridWidth / self.horizontalZoom
			self.trackTitleCanvas.delete("trackname")
		self.playCanvas.delete("timetext")
		# Draw cells of grid
		self.gridCanvas.itemconfig("gridcell", fill=CELL_BACKGROUND)
		for row in range(self.verticalZoom):
			if row >= len(self.tracks):
				break
			if clearGrid:
				self.trackTitleCanvas.create_text((0, self.rowHeight * (row + 0.5)), text="Track %d" % (self.tracks[row]), font=font, fill=CELL_FOREGROUND, tags=("rowtitle%d" % (row),"trackname"), anchor="w")
				self.gridCanvas.create_text(self.gridWidth - self.selectThickness, self.rowHeight * (self.rowHeight * int(row + 0.5)), state="hidden", tags=("lastpatterntext%d" % (row), "lastpatterntext"), font=font, anchor="e")
			self.drawRow(row)
		self.playCanvas.create_text(0 * self.columnWidth, PLAYHEAD_HEIGHT / 2, text="%d"%(self.colOffset), tags=("timetext"), anchor="w", fill=CELL_FOREGROUND)

		if clearGrid:
			for clock in range(self.horizontalZoom):
				self.gridCanvas.tag_lower("clock%d"%clock)

	# Function to update selectedCell
	#	clock: Clock (column) of selected cell (Optional - default to reselect current column)
	#	track: Track number of selected cell (Optional - default to reselect current =row) 
Example #10
Source File: test_font_widgets.py    From ttkwidgets with GNU General Public License v3.0 6 votes vote down vote up
def test_fontselectframe_family(self):
            frame = FontSelectFrame(self.window)
            frame.pack()
            self.window.update()
            frame._family_dropdown.set(font.families()[1])
            self.window.update()
            frame._on_family(frame._family_dropdown.get())
            results = frame.font
            self.assertIsInstance(results, tuple)
            self.assertEqual(len(results), 2)
            self.assertIsInstance(results[0], tuple)
            self.assertEqual(len(results[0]), 2)
            self.assertIsInstance(results[1], font.Font)

            frame._on_size(20)
            frame._on_family('Arial')
            frame._on_properties((True, True, True, True))
            self.window.update()
            results = frame.font
            self.assertEqual(results[0], ('Arial', 20, 'bold', 'italic',
                                          'underline', 'overstrike')) 
Example #11
Source File: chooser.py    From ttkwidgets with GNU General Public License v3.0 6 votes vote down vote up
def font(self):
        """
        Selected font.
        
        :return: font tuple (family_name, size, \*options), :class:`~font.Font` object
        """
        if self._family is None:
            return None, None
        else:
            font_tuple = self.__generate_font_tuple()
            font_obj = tkfont.Font(family=self._family, size=self._size,
                                   weight=tkfont.BOLD if self._bold else tkfont.NORMAL,
                                   slant=tkfont.ITALIC if self._italic else tkfont.ROMAN,
                                   underline=1 if self._underline else 0,
                                   overstrike=1 if self._overstrike else 0)
            return font_tuple, font_obj 
Example #12
Source File: test_font_widgets.py    From ttkwidgets with GNU General Public License v3.0 6 votes vote down vote up
def test_fontchooser_selection(self):
            chooser = FontChooser(self.window)
            self.window.update()
            chooser._font_family_list.listbox.selection_set(1)
            chooser._font_family_list._on_click()
            self.window.update()
            results = chooser.font
            self.assertIsInstance(results, tuple)
            self.assertEqual(len(results), 2)
            self.assertIsInstance(results[0], tuple)
            self.assertEqual(len(results[0]), 2)
            self.assertIsInstance(results[1], font.Font)
            chooser._on_family('')
            self.window.update()
            results = chooser.font
            self.assertIsNone(results[0]) 
Example #13
Source File: pykms_GuiMisc.py    From py-kms with The Unlicense 5 votes vote down vote up
def textbox_write(self, tag, message, color, extras):
                        widget = self.textbox_choose(message)
                        self.w_maxpix, self.h_maxpix = widget.winfo_width(), widget.winfo_height()
                        self.xfont = tkFont.Font(font = widget['font'])
                        widget.configure(state = 'normal')
                        widget.insert('end', self.textbox_format(message), tag)
                        self.textbox_color(tag, widget, color, self.customcolors['black'], extras)
                        widget.after(100, widget.see('end'))
                        widget.configure(state = 'disabled') 
Example #14
Source File: recipe-578886.py    From code with MIT License 5 votes vote down vote up
def __init__(self, master, width=0, height=0, family=None, size=None,*args, **kwargs):
        
        Frame.__init__(self, master, width = width, height= height)
        self.pack_propagate(False)

        self._min_width = width
        self._min_height = height

        self._textarea = Text(self, *args, **kwargs)
        self._textarea.pack(expand=True, fill='both')

        if family != None and size != None:
            self._font = tkFont.Font(family=family,size=size)
        else:
            self._font = tkFont.Font(family=self._textarea.cget("font"))

        self._textarea.config(font=self._font)

        # I want to insert a tag just in front of the class tag
        # It's not necesseary to guive to this tag extra priority including it at the beginning
        # For this reason I am making this search
        self._autoresize_text_tag = "autoresize_text_"+str(id(self))
        list_of_bind_tags = list(self._textarea.bindtags())
        list_of_bind_tags.insert(list_of_bind_tags.index('Text'), self._autoresize_text_tag)

        self._textarea.bindtags(tuple(list_of_bind_tags))
        self._textarea.bind_class(self._autoresize_text_tag, "<KeyPress>",self._on_keypress) 
Example #15
Source File: zynthian_gui_seqtrigger.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def drawCell(self, col, row, clear = False):
		pad = row + col * self.rows + 1 # Index pads from 1 and use index to map sequence (sequence 0 is used by pattern editor)
		if col < 0 or col >= self.columns or row < 0 or row >= self.rows:
			return
		padX = col * self.width / self.columns
		padY = row * self.height / self.rows
		padWidth = self.width / self.columns - 2 #TODO: Calculate pad size once
		padHeight = self.height / self.rows - 2
		cell = self.gridCanvas.find_withtag("pad:%d"%(pad))
		if cell:
			if self.parent.libseq.getPlayState(pad) == zynthian_gui_config.SEQ_STOPPED:
				playColour = self.padColoursStopped[self.parent.libseq.getPlayMode(pad)]
			elif self.parent.libseq.getPlayState(pad) == zynthian_gui_config.SEQ_STARTING:
				playColour = self.padColoursStarting[self.parent.libseq.getPlayMode(pad)]
			elif self.parent.libseq.getPlayState(pad) == zynthian_gui_config.SEQ_STOPPING:
				playColour = self.padColoursStopping[self.parent.libseq.getPlayMode(pad)]
			else:
				playColour = self.padColoursPlaying[self.parent.libseq.getPlayMode(pad)]
			self.gridCanvas.itemconfig(cell, fill=playColour)
			self.gridCanvas.coords(cell, padX, padY, padX + padWidth, padY + padHeight)
		else:
			cell = self.gridCanvas.create_rectangle(padX, padY, padX + padWidth, padY + padHeight,
				fill='grey', width=0, tags=("pad:%d"%(pad), "gridcell"))
			self.gridCanvas.create_text(padX + padWidth / 2, padY + padHeight / 2,
				font=tkFont.Font(family=zynthian_gui_config.font_topbar[0],
				size=int(padHeight * 0.3)),
				fill=zynthian_gui_config.color_panel_tx,
				tags="lbl_pad:%d"%(pad),
				text="%s%d" % (chr(col + 65), row + 1))
			self.gridCanvas.tag_bind("pad:%d"%(pad), '<Button-1>', self.onPadPress)
			self.gridCanvas.tag_bind("lbl_pad:%d"%(pad), '<Button-1>', self.onPadPress)
			self.gridCanvas.tag_bind("pad:%d"%(pad), '<ButtonRelease-1>', self.onPadRelease)
			self.gridCanvas.tag_bind("lbl_pad:%d"%(pad), '<ButtonRelease-1>', self.onPadRelease)

	# Function to draw pad
	#	pad: Pad index
	#	returns: Pad sequence play state 
Example #16
Source File: zynthian_gui_patterneditor.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def drawGrid(self, clearGrid = False):
		font = tkFont.Font(family=zynthian_gui_config.font_topbar[0], size=self.fontsize)
		if clearGrid:
			self.gridCanvas.delete(tkinter.ALL)
			self.stepWidth = (self.gridWidth - 2) / self.parent.libseq.getSteps()
			self.drawPianoroll()
		# Draw cells of grid
		self.gridCanvas.itemconfig("gridcell", fill="black")
		# Redraw gridlines
		self.gridCanvas.delete("gridline")
		if self.parent.libseq.getStepsPerBeat():
			for step in range(0, self.parent.libseq.getSteps() + 1, self.parent.libseq.getStepsPerBeat()):
				self.gridCanvas.create_line(step * self.stepWidth, 0, step * self.stepWidth, self.zoom * self.rowHeight - 1, fill=GRID_LINE, tags=("gridline"))
		# Delete existing note names
		self.pianoRoll.delete("notename")
		for note in range(self.keyOrigin, self.keyOrigin + self.zoom):
			# Update pianoroll keys
			key = note % 12
			row = note - self.keyOrigin
			self.drawRow(note)
			if clearGrid:
				# Create last note labels in grid
				self.gridCanvas.create_text(self.gridWidth - self.selectThickness, self.fontsize, state="hidden", tags=("lastnotetext%d" % (row), "lastnotetext"), font=font, anchor="e")
			id = "row%d" % (row)
			if key in (0,2,4,5,7,9,11):
				self.pianoRoll.itemconfig(id, fill="white")
				if key == 0:
					self.pianoRoll.create_text((self.pianoRollWidth / 2, self.rowHeight * (self.zoom - row - 0.5)), text="C%d (%d)" % ((self.keyOrigin + row) // 12 - 1, self.keyOrigin + row), font=font, fill=CANVAS_BACKGROUND, tags="notename")
					self.gridCanvas.create_line(0, (self.zoom - row) * self.rowHeight, self.gridWidth, (self.zoom - row) * self.rowHeight, fill=GRID_LINE, tags=("gridline"))
			else:
				self.pianoRoll.itemconfig(id, fill="black")
		# Set z-order to allow duration to show
		if clearGrid:
			for step in range(self.parent.libseq.getSteps()):
				self.gridCanvas.tag_lower("step%d"%step)
		self.gridCanvas.tag_raise("selection")

	# Function to draw pianoroll keys (does not fill key colour) 
Example #17
Source File: test_font.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def setUpClass(cls):
        AbstractTkTest.setUpClass.__func__(cls)
        try:
            cls.font = font.Font(root=cls.root, name=fontname, exists=True)
        except tkinter.TclError:
            cls.font = font.Font(root=cls.root, name=fontname, exists=False) 
Example #18
Source File: test_font.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def test_eq(self):
        font1 = font.Font(root=self.root, name=fontname, exists=True)
        font2 = font.Font(root=self.root, name=fontname, exists=True)
        self.assertIsNot(font1, font2)
        self.assertEqual(font1, font2)
        self.assertNotEqual(font1, font1.copy())
        self.assertNotEqual(font1, 0) 
Example #19
Source File: help.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def findfont(self, names):
        "Return name of first font family derived from names."
        for name in names:
            if name.lower() in (x.lower() for x in tkfont.names(root=self)):
                font = tkfont.Font(name=name, exists=True, root=self)
                return font.actual()['family']
            elif name.lower() in (x.lower()
                                  for x in tkfont.families(root=self)):
                return name 
Example #20
Source File: groups.py    From tk_tools with MIT License 5 votes vote down vote up
def __config_calendar(self):
        cols = self._cal.formatweekheader(3).split()

        self._calendar['columns'] = cols
        self._calendar.tag_configure('header', background='grey90')
        self._calendar.insert('', 'end', values=cols, tag='header')

        # adjust its columns width
        font = Font()
        maxwidth = max(font.measure(col) for col in cols)
        for col in cols:
            self._calendar.column(
                col, width=maxwidth, minwidth=maxwidth, anchor='e'
            ) 
Example #21
Source File: groups.py    From tk_tools with MIT License 5 votes vote down vote up
def __setup_selection(self, sel_bg, sel_fg):
        self._font = Font()
        self._canvas = canvas = tk.Canvas(
            self._calendar, background=sel_bg,
            borderwidth=0, highlightthickness=0
        )
        canvas.text = canvas.create_text(0, 0, fill=sel_fg, anchor='w')

        canvas.bind('<ButtonPress-1>', lambda evt: canvas.place_forget())
        self._calendar.bind('<Configure>', lambda evt: canvas.place_forget())
        self._calendar.bind('<ButtonPress-1>', self._pressed) 
Example #22
Source File: zynthian_gui_controller.py    From zynthian-ui with GNU General Public License v3.0 5 votes vote down vote up
def set_title(self, tit):
		self.title=str(tit)
		#Calculate the font size ...
		max_fs=int(1.0*zynthian_gui_config.font_size)
		words=self.title.split()
		n_words=len(words)
		maxnumchar=max([len(w) for w in words])
		rfont=tkFont.Font(family=zynthian_gui_config.font_family,size=max_fs)
		if n_words==1:
			maxlen=rfont.measure(self.title)
		elif n_words==2:
			maxlen=max([rfont.measure(w) for w in words])
		elif n_words==3:
			maxlen=max([rfont.measure(w) for w in [words[0]+' '+words[1], words[1]+' '+words[2]]])
			max_fs=max_fs-1
		elif n_words>=4:
			maxlen=max([rfont.measure(w) for w in [words[0]+' '+words[1], words[2]+' '+words[3]]])
			max_fs=max_fs-1
		fs=int((zynthian_gui_config.ctrl_width-6)*max_fs/maxlen)
		fs=min(max_fs,max(int(0.7*zynthian_gui_config.font_size),fs))
		#logging.debug("TITLE %s => MAXLEN=%d, FONTSIZE=%d" % (self.title,maxlen,fs))
		#Set title label
		if not self.label_title:
			self.label_title = self.canvas.create_text(3, 4,
				anchor=tkinter.NW,
				justify=tkinter.LEFT,
				width=maxlen,
				text=self.title,
				font=(zynthian_gui_config.font_family,fs),
				fill=zynthian_gui_config.color_panel_tx)
		else:
			self.canvas.itemconfigure(self.label_title,
				width=maxlen,
				text=self.title,
				font=(zynthian_gui_config.font_family,fs)) 
Example #23
Source File: help.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def findfont(self, names):
        "Return name of first font family derived from names."
        for name in names:
            if name.lower() in (x.lower() for x in tkfont.names(root=self)):
                font = tkfont.Font(name=name, exists=True, root=self)
                return font.actual()['family']
            elif name.lower() in (x.lower()
                                  for x in tkfont.families(root=self)):
                return name 
Example #24
Source File: test_font.py    From ironpython3 with Apache License 2.0 5 votes vote down vote up
def setUpClass(cls):
        AbstractTkTest.setUpClass.__func__(cls)
        try:
            cls.font = font.Font(root=cls.root, name=fontname, exists=True)
        except tkinter.TclError:
            cls.font = font.Font(root=cls.root, name=fontname, exists=False) 
Example #25
Source File: pykms_GuiMisc.py    From py-kms with The Unlicense 5 votes vote down vote up
def __init__(self, srv_text_space, clt_text_space, customcolors, side):
                        self.srv_text_space = srv_text_space
                        self.clt_text_space = clt_text_space
                        self.customcolors = customcolors
                        self.side = side
                        self.tag_err = 'STDERR'
                        self.xfont = tkFont.Font(font = self.srv_text_space['font']) 
Example #26
Source File: tkvt100.py    From learn_python3_spider with MIT License 5 votes vote down vote up
def __init__(self, *args, **kw):
        global ttyFont, fontHeight, fontWidth
        ttyFont = tkFont.Font(family = 'Courier', size = 10)
        fontWidth = max(map(ttyFont.measure, string.ascii_letters+string.digits))
        fontHeight = int(ttyFont.metrics()['linespace'])
        self.width = kw.get('width', 80)
        self.height = kw.get('height', 25)
        self.callback = kw['callback']
        del kw['callback']
        kw['width'] = w = fontWidth * self.width
        kw['height'] = h = fontHeight * self.height
        Tkinter.Frame.__init__(self, *args, **kw)
        self.canvas = Tkinter.Canvas(bg='#000000', width=w, height=h)
        self.canvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        self.canvas.bind('<Key>', self.keyPressed)
        self.canvas.bind('<1>', lambda x: 'break')
        self.canvas.bind('<Up>', self.upPressed)
        self.canvas.bind('<Down>', self.downPressed)
        self.canvas.bind('<Left>', self.leftPressed)
        self.canvas.bind('<Right>', self.rightPressed)
        self.canvas.focus()

        self.ansiParser = ansi.AnsiParser(ansi.ColorText.WHITE, ansi.ColorText.BLACK)
        self.ansiParser.writeString = self.writeString
        self.ansiParser.parseCursor = self.parseCursor
        self.ansiParser.parseErase = self.parseErase
        #for (a, b) in colorMap.items():
        #    self.canvas.tag_config(a, foreground=b)
        #    self.canvas.tag_config('b'+a, background=b)
        #self.canvas.tag_config('underline', underline=1)

        self.x = 0 
        self.y = 0
        self.cursor = self.canvas.create_rectangle(0,0,fontWidth-1,fontHeight-1,fill='green',outline='green') 
Example #27
Source File: help.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def findfont(self, names):
        "Return name of first font family derived from names."
        for name in names:
            if name.lower() in (x.lower() for x in tkfont.names(root=self)):
                font = tkfont.Font(name=name, exists=True, root=self)
                return font.actual()['family']
            elif name.lower() in (x.lower()
                                  for x in tkfont.families(root=self)):
                return name 
Example #28
Source File: test_font.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def test_eq(self):
        font1 = font.Font(root=self.root, name=fontname, exists=True)
        font2 = font.Font(root=self.root, name=fontname, exists=True)
        self.assertIsNot(font1, font2)
        self.assertEqual(font1, font2)
        self.assertNotEqual(font1, font1.copy())
        self.assertNotEqual(font1, 0) 
Example #29
Source File: test_font.py    From Fluid-Designer with GNU General Public License v3.0 5 votes vote down vote up
def setUpClass(cls):
        AbstractTkTest.setUpClass.__func__(cls)
        try:
            cls.font = font.Font(root=cls.root, name=fontname, exists=True)
        except tkinter.TclError:
            cls.font = font.Font(root=cls.root, name=fontname, exists=False) 
Example #30
Source File: pykms_GuiBase.py    From py-kms with The Unlicense 5 votes vote down vote up
def __init__(self, *args, **kwargs):
                tk.Tk.__init__(self, *args, **kwargs)
                self.wraplength = 200
                serverthread.with_gui = True
                self.validation_int = (self.register(self.validate_int), "%S")
                self.validation_float = (self.register(self.validate_float), "%P")

                ## Define fonts and colors.
                self.btnwinfont = tkFont.Font(family = 'Times', size = 12, weight = 'bold')
                self.othfont = tkFont.Font(family = 'Times', size = 9, weight = 'bold')
                self.optfont = tkFont.Font(family = 'Helvetica', size = 11, weight = 'bold')
                self.optfontredux = tkFont.Font(family = 'Helvetica', size = 9, weight = 'bold')
                self.msgfont = tkFont.Font(family = 'Monospace', size = 6) # need a monospaced type (like courier, etc..).

                self.customcolors = { 'black'   : '#000000',
                                      'white'   : '#FFFFFF',
                                      'green'   : '#90EE90',
                                      'yellow'  : '#FFFF00',
                                      'magenta' : '#DA70D6',
                                      'orange'  : '#FFA500',
                                      'red'     : '#FF4500',
                                      'blue'    : '#1E90FF',
                                      'cyan'    : '#AFEEEE',
                                      'lavender': '#E6E6FA',
                                      }

                self.option_add('*TCombobox*Listbox.font', self.optfontredux)

                self.gui_create()