Python tkFont.Font() Examples

The following are 30 code examples of tkFont.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 tkFont , or try the search function .
Example #1
Source File: rdparser.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 = tkFont.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 = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = tkFont.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 = tkFont.Font(family='helvetica', weight='bold',
                                    size=big) 
Example #2
Source File: concordance_app.py    From luscan-devel with GNU General Public License v2.0 6 votes vote down vote up
def _init_results_box(self, parent):
        innerframe = Frame(parent)
        i1 = Frame(innerframe)
        i2 = Frame(innerframe)
        vscrollbar = Scrollbar(i1, borderwidth=1)
        hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
        self.results_box = Text(i1,
                                font=tkFont.Font(family='courier', size='16'),
                                state='disabled', borderwidth=1,
                                                            yscrollcommand=vscrollbar.set,
                                xscrollcommand=hscrollbar.set, wrap='none', width='40', height = '20', exportselection=1)
        self.results_box.pack(side='left', fill='both', expand=True)
        self.results_box.tag_config(self._HIGHLIGHT_WORD_TAG, foreground=self._HIGHLIGHT_WORD_COLOUR)
        self.results_box.tag_config(self._HIGHLIGHT_LABEL_TAG, foreground=self._HIGHLIGHT_LABEL_COLOUR)
        vscrollbar.pack(side='left', fill='y', anchor='e')
        vscrollbar.config(command=self.results_box.yview)
        hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
        hscrollbar.config(command=self.results_box.xview)
        #there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
        Label(i2, text='   ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
        i1.pack(side='top', fill='both', expand=True, anchor='n')
        i2.pack(side='bottom', fill='x', anchor='s')
        innerframe.pack(side='top', fill='both', expand=True) 
Example #3
Source File: collocations_app.py    From luscan-devel with GNU General Public License v2.0 6 votes vote down vote up
def _init_results_box(self, parent):
        innerframe = Frame(parent)
        i1 = Frame(innerframe)
        i2 = Frame(innerframe)
        vscrollbar = Scrollbar(i1, borderwidth=1)
        hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
        self.results_box = Text(i1,
                    font=tkFont.Font(family='courier', size='16'),
                    state='disabled', borderwidth=1,
                    yscrollcommand=vscrollbar.set,
                    xscrollcommand=hscrollbar.set, wrap='none', width='40', height = '20', exportselection=1)
        self.results_box.pack(side='left', fill='both', expand=True)
        vscrollbar.pack(side='left', fill='y', anchor='e')
        vscrollbar.config(command=self.results_box.yview)
        hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
        hscrollbar.config(command=self.results_box.xview)
        #there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
        Label(i2, text='   ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
        i1.pack(side='top', fill='both', expand=True, anchor='n')
        i2.pack(side='bottom', fill='x', anchor='s')
        innerframe.pack(side='top', fill='both', expand=True) 
Example #4
Source File: rdparser_app.py    From luscan-devel with GNU General Public License v2.0 6 votes vote down vote up
def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.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 = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = tkFont.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 = tkFont.Font(family='helvetica', weight='bold',
                                    size=big) 
Example #5
Source File: drt_glue_demo.py    From luscan-devel with GNU General Public License v2.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 #6
Source File: help.py    From Splunking-Crime with GNU Affero 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 #7
Source File: aisc_steel_shapes.py    From Structural-Engineering with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def font_size_down(self, *event):
        if self.f_size-1 < 6:
            self.f_size = 6
        else:
            self.f_size = self.f_size-1
            
        helv = tkFont.Font(family='Helvetica',size=self.f_size, weight='bold')
        self.f_size_label.configure(text='Font Size ('+str(self.f_size)+'):')
        self.value_def_menu.config(font=helv)
        self.shape_type_menu.config(font=helv)
        self.value_filter_menu.config(font=helv)
        for widget in self.widgets:
            widget.configure(font=helv) 
Example #8
Source File: aisc_steel_shapes_historic.py    From Structural-Engineering with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def font_size_down(self, *event):
        if self.f_size-1 < 6:
            self.f_size = 6
        else:
            self.f_size = self.f_size-1
            
        helv = tkFont.Font(family='Helvetica',size=self.f_size, weight='bold')
        self.f_size_label.configure(text='Font Size ('+str(self.f_size)+'):')
        self.edition_type_menu.config(font=helv)
        self.shape_type_menu.config(font=helv)
        for widget in self.widgets:
            widget.configure(font=helv) 
Example #9
Source File: chunkparser_app.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _init_fonts(self, top):
        # TWhat's our font size (default=same as sysfont)
        self._size = IntVar(top)
        self._size.set(20)
        self._font = tkFont.Font(family='helvetica',
                                 size=-self._size.get())
        self._smallfont = tkFont.Font(family='helvetica',
                                      size=-(self._size.get()*14/20)) 
Example #10
Source File: srparser_app.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.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 = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = tkFont.Font(family='helvetica',
                                    size=self._size.get()) 
Example #11
Source File: chartparser_app.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _init_fonts(self, root):
        self._boldfont = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._fontsize)
        self._font = tkFont.Font(family='helvetica',
                                    size=self._fontsize)
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.Font(font=Tkinter.Button()["font"])
        root.option_add("*Font", self._sysfont) 
Example #12
Source File: chartparser_app.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.Font(font=Tkinter.Button()["font"])
        root.option_add("*Font", self._sysfont)

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

        self._boldfont = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = tkFont.Font(family='helvetica',
                                    size=self._size.get()) 
Example #13
Source File: drt_glue_demo.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, canvas, drs, **attribs):
        self._drs = drs
        self._canvas = canvas
        canvas.font = Font(font=canvas.itemcget(canvas.create_text(0, 0, text=''), 'font'))
        canvas._BUFFER = 3
        self.bbox = (0, 0, 0, 0) 
Example #14
Source File: drt.py    From luscan-devel with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, drs, size_canvas=True, canvas=None):
        """
        :param drs: ``AbstractDrs``, The DRS to be drawn
        :param size_canvas: bool, True if the canvas size should be the exact size of the DRS
        :param canvas: ``Canvas`` The canvas on which to draw the DRS.  If none is given, create a new canvas.
        """
        master = None
        if not canvas:
            master = Tk()
            master.title("DRT")

            font = Font(family='helvetica', size=12)

            if size_canvas:
                canvas = Canvas(master, width=0, height=0)
                canvas.font = font
                self.canvas = canvas
                (right, bottom) = self._visit(drs, self.OUTERSPACE, self.TOPSPACE)

                width = max(right+self.OUTERSPACE, 100)
                height = bottom+self.OUTERSPACE
                canvas = Canvas(master, width=width, height=height)#, bg='white')
            else:
                canvas = Canvas(master, width=300, height=300)

            canvas.pack()
            canvas.font = font

        self.canvas = canvas
        self.drs = drs
        self.master = master 
Example #15
Source File: aisc_steel_shapes_historic.py    From Structural-Engineering with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def edition_change(self, *event):
        self.shape_type_menu.destroy()
        edition = self.edition_type.get()
        edition_index = self.edition.index(edition)
        self.shape_type_menu = tk.OptionMenu(self.menu_frame, self.shape_type, *self.shape_sets[edition_index], command=self.shape_change)
        helv = tkFont.Font(family='Helvetica',size=self.f_size, weight='bold')
        self.shape_type_menu.config(font=helv)
        self.shape_type_menu.pack(side=tk.TOP, fill=tk.X, expand=True)
        self.shape_type.set(self.shape_sets[edition_index][0]) 
Example #16
Source File: tkvt100.py    From python-for-android with Apache License 2.0 5 votes vote down vote up
def __init__(self, *args, **kw):
        global ttyFont, fontHeight, fontWidth
        ttyFont = tkFont.Font(family = 'Courier', size = 10)
        fontWidth, fontHeight = max(map(ttyFont.measure, string.letters+string.digits)), 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 #17
Source File: game.py    From Connect4 with MIT License 5 votes vote down vote up
def __init__(self, master=None):
        Frame.__init__(self)
        self.configure(width=500, height=100, bg="white")
        police = tkFont.Font(family="Arial",size=36,weight="bold") 
        self.t = Label(self, text="Connect4 AI", font=police, bg ="white")
        self.t.grid(sticky=NSEW, pady=20) 
Example #18
Source File: tkvt100.py    From BitTorrent with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kw):
        global ttyFont, fontHeight, fontWidth
        ttyFont = tkFont.Font(family = 'Courier', size = 10)
        fontWidth, fontHeight = max(map(ttyFont.measure, string.letters+string.digits)), 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 #19
Source File: viewer.py    From minecart with MIT License 5 votes vote down vote up
def get_font_program(font_dict):
    """
    Extracts the font program from a PDF font dictionary.

    Returns a tuple (family_name, font_program_data, attrs), where
    family_name is the unicode name of the family that can be passed to
    `tkFont.Font` to create the font. `font_program_data` is the raw binary
    data of the embedded font, if any, that can be passed to
    `loadfont_memory` to load the font into the central repository, or `None`
    if the font isn't emebedded. `attrs` is a dictionary of kwargs that can
    be passed to `tkFont.Font`.

    """
    subtype = str(pdfminer.pdftypes.resolve1(font_dict['Subtype']))
    if subtype == '/Type1':
        return get_type1_font(font_dict)
    elif subtype == '/TrueType':
        return get_truetype_font(font_dict)
    elif subtype == '/Type0':
        return get_type0_font(font_dict)
    elif subtype == '/Type3':
        raise pdfminer.pdftypes.PDFNotImplementedError(
            "Type 3 Fonts are not supported by this viewer")
    elif subtype == '/MMType1':
        raise pdfminer.pdftypes.PDFNotImplementedError(
            "Multiple Master Fonts are not supported by this viewer")
    raise pdfminer.pdftypes.PDFValueError(
        "Unknown font subtype: '%s'" % subtype) 
Example #20
Source File: viewer.py    From minecart with MIT License 5 votes vote down vote up
def get_font(self, m_font, size):
        "Return a font matching the given specs, loading it if necessary."
        try:
            family, attrs = self.font_cache[m_font]
        except KeyError:
            family, data, attrs = get_font_program(m_font)
            self.font_cache[m_font] = family, attrs
            loadfont_memory(data)
        desc = pdfminer.pdftypes.resolve1(m_font.descriptor)
        if 'FontWeight' in desc:
            attrs['weight'] = 'normal' if desc['FontWeight'] < 450 else 'bold'
        if 'ItalicAngle' in desc:
            attrs['slant'] = 'roman' if desc['ItalicAngle'] ==0 else 'italic'
        return tkFont.Font(family=family, size=-int(size * self.res), **attrs) 
Example #21
Source File: rickmote.py    From rickmote with GNU General Public License v3.0 5 votes vote down vote up
def __init__( self ):
        Tk.__init__(self)
        self.title("Rickcaster")
        self.smallFont = tkFont.Font(family="Helvetica", size=20)
        self.hackFont = tkFont.Font(family="Helvetica", size=40)

        self.frame=Frame(self)
        self.MainMenu() 
Example #22
Source File: grid_box.py    From PCWG with MIT License 5 votes vote down vote up
def adjust_width(self, values):

        # adjust column's width if necessary to fit each value
        for ix, val in enumerate(values):

            if not val is None: 
    
                try:
                    col_w = tkFont.Font().measure(val)
                    if self.tree.column(self.headers[ix],width=None)<col_w:
                        self.tree.column(self.headers[ix], width=col_w)
                except ExceptionHandler.ExceptionType as e:
                    ExceptionHandler.add("Cannot adjust column width {0}: {1}".format(val, e)) 
Example #23
Source File: grid_box.py    From PCWG with MIT License 5 votes vote down vote up
def get_header_width(self, header):
        return tkFont.Font().measure(header.title()) * self.get_header_scale() 
Example #24
Source File: test_font.py    From PokemonGo-DesktopMap with MIT License 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: test_font.py    From PokemonGo-DesktopMap with MIT License 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)
        self.assertNotIn(font1, [0]) 
Example #26
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 #27
Source File: chart.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def _init_fonts(self, root):
        self._boldfont = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._fontsize)
        self._font = tkFont.Font(family='helvetica',
                                    size=self._fontsize)
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.Font(font=Tkinter.Button()["font"])
        root.option_add("*Font", self._sysfont) 
Example #28
Source File: chart.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.Font(font=Tkinter.Button()["font"])
        root.option_add("*Font", self._sysfont)
        
        # TWhat's our font size (default=same as sysfont)
        self._size = Tkinter.IntVar(root)
        self._size.set(self._sysfont.cget('size'))

        self._boldfont = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = tkFont.Font(family='helvetica',
                                    size=self._size.get()) 
Example #29
Source File: srparser.py    From razzy-spinner with GNU General Public License v3.0 5 votes vote down vote up
def _init_fonts(self, root):
        # See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
        self._sysfont = tkFont.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 = tkFont.Font(family='helvetica', weight='bold',
                                    size=self._size.get())
        self._font = tkFont.Font(family='helvetica',
                                    size=self._size.get()) 
Example #30
Source File: ttkHyperlinkLabel.py    From EDMarketConnector with GNU General Public License v2.0 5 votes vote down vote up
def configure(self, cnf=None, **kw):
        # This class' state
        for thing in ['url', 'popup_copy', 'underline']:
            if thing in kw:
                setattr(self, thing, kw.pop(thing))
        for thing in ['foreground', 'disabledforeground']:
            if thing in kw:
                setattr(self, thing, kw[thing])

        # Emulate disabledforeground option for ttk.Label
        if kw.get('state') == tk.DISABLED:
            if 'foreground' not in kw:
                kw['foreground'] = self.disabledforeground
        elif 'state' in kw:
            if 'foreground' not in kw:
                kw['foreground'] = self.foreground

        if 'font' in kw:
            self.font_n = kw['font']
            self.font_u = tkFont.Font(font = self.font_n)
            self.font_u.configure(underline = True)
            kw['font'] = self.underline is True and self.font_u or self.font_n

        if 'cursor' not in kw:
            if (kw['state'] if 'state' in kw else str(self['state'])) == tk.DISABLED:
                kw['cursor'] = 'arrow'	# System default
            elif self.url and (kw['text'] if 'text' in kw else self['text']):
                kw['cursor'] = platform=='darwin' and 'pointinghand' or 'hand2'
            else:
                kw['cursor'] = (platform=='darwin' and 'notallowed') or (platform=='win32' and 'no') or 'circle'

        super(HyperlinkLabel, self).configure(cnf, **kw)