Python tkFont 模块,Font() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用tkFont.Font()

项目:pytknvim    作者:timeyyy    | 项目源码 | 文件源码
def _nvimtk_config(self, *args):
        '''required config'''
        # Hide tkinter cursor
        self.config(insertontime=0)

        # Remove Default Bindings and what happens on insert etc
        bindtags = list(self.bindtags())
        bindtags.remove("Text")
        self.bindtags(tuple(bindtags))

        self.bind('<Key>', self.nvim_handler.tk_key_pressed)

        self.bind('<Button-1>', lambda e: self.focus_set())

        # The negative number makes it pixels instead of point sizes
        size = self.make_font_size(13)
        self._fnormal = tkfont.Font(family='Monospace', size=size)
        self._fbold = tkfont.Font(family='Monospace', weight='bold', size=size)
        self._fitalic = tkfont.Font(family='Monospace', slant='italic', size=size)
        self._fbolditalic = tkfont.Font(family='Monospace', weight='bold',
                                 slant='italic', size=size)
        self.config(font=self._fnormal, wrap=tk.NONE)

        self.nvim_handler._colsize = self._fnormal.measure('M')
        self.nvim_handler._rowsize = self._fnormal.metrics('linespace')
项目:pytknvim    作者:timeyyy    | 项目源码 | 文件源码
def _tk_nvim_put(self, data):
        # choose a Font instance
        font = self._fnormal
        if self._attrs.get('bold', False):
            font = self._fbold
        if self._attrs.get('italic', False):
            font = self._fbolditalic if font == self._fbold else self._fitalic
        # colors
        fg = "#{0:0{1}x}".format(self._attrs.get('foreground', self._fg), 6)
        bg = "#{0:0{1}x}".format(self._attrs.get('background', self._bg), 6)
        # get the "text" and "rect" which correspond to the current cell
        x, y = self._tk_get_coords(self._cursor_row, self._cursor_col)
        items = self._canvas.find_overlapping(x, y, x + 1, y + 1)
        if len(items) != 2:
            # caught part the double-width character in the cell to the left,
            # filter items which dont have the same horizontal coordinate as
            # "x"
            predicate = lambda item: self._canvas.coords(item)[0] == x
            items = filter(predicate, items)
        # rect has lower id than text, sort to unpack correctly
        rect, text = sorted(items)
        self._canvas.itemconfig(text, fill=fg, font=font, text=data or ' ')
        self._canvas.itemconfig(rect, fill=bg)
        self._tk_nvim_cursor_goto(self._cursor_row, self._cursor_col + 1)
项目:pytknvim    作者:timeyyy    | 项目源码 | 文件源码
def _tk_redraw_canvas(self, width, height):
        if self._canvas:
            self._canvas.destroy()
        self._fnormal = Font(family='Monospace', size=13)
        self._fbold = Font(family='Monospace', weight='bold', size=13)
        self._fitalic = Font(family='Monospace', slant='italic', size=13)
        self._fbolditalic = Font(family='Monospace', weight='bold',
                                 slant='italic', size=13)
        self._colsize = self._fnormal.measure('A')
        self._rowsize = self._fnormal.metrics('linespace')
        self._canvas = Canvas(self._root, width=self._colsize * width,
                              height=self._rowsize * height)
        self._tk_fill_region(0, height - 1, 0, width - 1)
        self._cursor_row = 0
        self._cursor_col = 0
        self._scroll_top = 0
        self._scroll_bot = height - 1
        self._scroll_left = 0
        self._scroll_right = width - 1
        self._width, self._height = (width, height,)
        self._canvas.pack()
项目:pytknvim    作者:timeyyy    | 项目源码 | 文件源码
def _tk_nvim_put(self, data):
        # choose a Font instance
        font = self._fnormal
        if self._attrs.get('bold', False):
            font = self._fbold
        if self._attrs.get('italic', False):
            font = self._fbolditalic if font == self._fbold else self._fitalic
        # colors
        fg = "#{0:0{1}x}".format(self._attrs.get('foreground', self._fg), 6)
        bg = "#{0:0{1}x}".format(self._attrs.get('background', self._bg), 6)
        # get the "text" and "rect" which correspond to the current cell
        x, y = self._tk_get_coords(self._cursor_row, self._cursor_col)
        items = self._canvas.find_overlapping(x, y, x + 1, y + 1)
        if len(items) != 2:
            # caught part the double-width character in the cell to the left,
            # filter items which dont have the same horizontal coordinate as
            # "x"
            predicate = lambda item: self._canvas.coords(item)[0] == x
            items = filter(predicate, items)
        # rect has lower id than text, sort to unpack correctly
        rect, text = sorted(items)
        self._canvas.itemconfig(text, fill=fg, font=font, text=data or ' ')
        self._canvas.itemconfig(rect, fill=bg)
        self._tk_nvim_cursor_goto(self._cursor_row, self._cursor_col + 1)
项目:pytknvim    作者:timeyyy    | 项目源码 | 文件源码
def _tk_redraw_canvas(self, width, height):
        if self._canvas:
            self._canvas.destroy()
        self._fnormal = Font(family='Monospace', size=13)
        self._fbold = Font(family='Monospace', weight='bold', size=13)
        self._fitalic = Font(family='Monospace', slant='italic', size=13)
        self._fbolditalic = Font(family='Monospace', weight='bold',
                                 slant='italic', size=13)
        self._colsize = self._fnormal.measure('A')
        self._rowsize = self._fnormal.metrics('linespace')
        self._canvas = Canvas(self._root, width=self._colsize * width,
                              height=self._rowsize * height)
        self._tk_fill_region(0, height - 1, 0, width - 1)
        self._cursor_row = 0
        self._cursor_col = 0
        self._scroll_top = 0
        self._scroll_bot = height - 1
        self._scroll_left = 0
        self._scroll_right = width - 1
        self._width, self._height = (width, height,)
        self._canvas.pack()
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def _build_tree(self):
        for col in tree_columns:
            self.tree.heading(col, text=col.title(),
                command=lambda c=col: sortby(self.tree, c, 0))
            # XXX tkFont.Font().measure expected args are incorrect according
            #     to the Tk docs
            self.tree.column(col, width=tkFont.Font().measure(col.title()))

        for item in tree_data:
            self.tree.insert('', 'end', values=item)

            # adjust columns lenghts if necessary
            for indx, val in enumerate(item):
                ilen = tkFont.Font().measure(val)
                if self.tree.column(tree_columns[indx], width=None) < ilen:
                    self.tree.column(tree_columns[indx], width=ilen)
项目:learnRGB    作者:cbott    | 项目源码 | 文件源码
def __init__(self, master):
        #canvas / colored rectangle dimensions
        self.width =  800
        self.height = 300
        #answer rectangle dimenstions
        self.ans_width = 120
        self.ans_height= 120
        #Actual color of the displayed rectangle (r, g, b)
        self.current_color = (0, 0, 0)

        #just a big font so things are bigger
        self.big_font = tkFont.Font(root=master, family='Helvetica', size=20)

        Frame.__init__(self, master)
        self.grid(sticky=(E, W, S, N))

        master.columnconfigure(0, weight=1)
        master.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.mode = StringVar() #format for representing colors: INT/HEX
        self.generate()
        self.next_color()
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def __init__(self, x, y, panelWidth, panelHeight):
        self.width = panelWidth
        self.height = panelHeight
        self.x = x
        self.y = y

        self.canvas = tk.Canvas(root, width=self.width, height=self.height, background=panelBackground, highlightthickness=0)
        self.canvas.place(x=self.x, y=self.y)

        self.topHeightPercent = 0.85 # main box score
        self.botHeightPercent = 1 - self.topHeightPercent # win/loss/save pitcher info, post game

        #                         1  2  3  4  5  6  7  8  9   R  H  E
        exampleString = "*  STL  10 10 10 10 10 10 10 10 10  10 10 10"

        topNumLines = 3
        lineHeightMultiplier = 1.2

        self.topFont, self.topFontHeight = fontFit(fontName, exampleString, (self.width * .9, self.height * self.topHeightPercent // topNumLines // lineHeightMultiplier))
        self.topLineHeight = self.topFontHeight * lineHeightMultiplier
        self.topUnderlinedFont = tkFont.Font(family=fontName, size=-self.topFontHeight, underline=1)

        self.topStartLineY = (self.height * self.topHeightPercent - self.topLineHeight * topNumLines) // 2
        self.topStartX = (self.width - self.topFont.measure(exampleString)) // 2
项目:Farmbot_GeneralAP    作者:SpongeYao    | 项目源码 | 文件源码
def __init__(self, master, arg_PinList=[('',0)]):
        print 'init'
        strFont= 'Arial'
        self.__myfont12 = tkFont.Font(family=strFont, size=12)
        self.__myfont12_Bold = tkFont.Font(family=strFont, size=12, weight= tkFont.BOLD)
        self.__myfont10 = tkFont.Font(family=strFont, size=10)
        self.__myfont10_Bold = tkFont.Font(family=strFont, size=10, weight= tkFont.BOLD)
        self.__PinList= arg_PinList
        self.__MaxRow= 7
        self.__CurrentRow= len(arg_PinList)
        self.__CurGridRow= self.__CurrentRow
        self.__NumberList= range(0, self.__MaxRow+1)
        self.__entries_Func= [0]
        self.__entries_PinNumb= [0]
        self.__btns_clear=[0]
        #self.master= master
        tkSimpleDialog.Dialog.__init__(self, master, "Peripherals")
    # ########################################
项目:pokerface    作者:LiuRoy    | 项目源码 | 文件源码
def add_assembly():
    """????"""
    global index_label

    init()
    index_label = Label(master, text=u'{}/{}'.format(offset + 1, len(face_file_list)),
                        font=Font(size=20))
    index_label.place(anchor=u'nw', x=10, y=10)
    previous_button = Button(master, text=u'???', command=handle_previous)
    previous_button.place(anchor=u'nw', x=300, y=8)
    next_button = Button(master, text=u'???', command=handle_next)
    next_button.place(anchor=u'nw', x=380, y=8)
    rotate_button = Button(master, text=u'??', command=handle_rotate)
    rotate_button.place(anchor=u'nw', x=460, y=8)
    detect_button = Button(master, text=u'??', command=handle_detect)
    detect_button.place(anchor=u'nw', x=520, y=8)
项目:Sample-Code    作者:meigrafd    | 项目源码 | 文件源码
def createhand(self):
        # create text display
        self.textid = self.create_text(self.centrex,
        self.centrey - 3*self.blobrad,
        fill = 'red',
        font = tkf.Font(size = -int(2*self.majortick)))


        # create moving and changeable bits
        self.handid = self.create_line(self.centrex,self.centrey,
        self.centrex - self.handlen,self.centrey,
        width = 2*self.linewidth,
        fill = 'red')

        self.blobid = self.create_oval(self.centrex - self.blobrad,
        self.centrey - self.blobrad,
        self.centrex + self.blobrad,
        self.centrey + self.blobrad,
        outline = 'black', fill = 'black')
项目:rensapy    作者:RensaProject    | 项目源码 | 文件源码
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)
项目:RePhraser    作者:MissLummie    | 项目源码 | 文件源码
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)
项目:Verideals    作者:Derrreks    | 项目源码 | 文件源码
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)
项目:adtree-py    作者:uraplutonium    | 项目源码 | 文件源码
def showBayesNet(theBayesNet):
    global TK_ROOT, SP_CANVAS
    TK_ROOT = Tk(className=TITLE) # Create window
    TK_ROOT.grid_rowconfigure(0, weight=1)
    TK_ROOT.grid_columnconfigure(0, weight=1)
    SP_CANVAS = Canvas(TK_ROOT, width=1100, height=500, xscrollcommand=None,
                yscrollcommand=None)
    SP_CANVAS.grid(row=0,column=0,sticky='nesw')
    headingFont = tkFont.Font(family="Helvetica", size=18)
    SP_CANVAS.create_text(350, 50, font=headingFont,
            text='Bayes Net with Probability Updating using Conditional Probability Values')
    for node in theBayesNet.nodes:
        display_parent_links(node)
    for node in theBayesNet.nodes:
        display_node(node)
    createMenu(TK_ROOT)
    TK_ROOT.mainloop()
项目:code    作者:ActiveState    | 项目源码 | 文件源码
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)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def __init__(self, master, text, background=None, font=None, familiy=None, size=None, underline=True, visited_fg = "#551A8B", normal_fg = "#0000EE", visited=False, action=None):
        self._visited_fg = visited_fg
        self._normal_fg = normal_fg

        if visited:
            fg = self._visited_fg
        else:
            fg = self._normal_fg

        if font is None:
            default_font = nametofont("TkDefaultFont")
            family = default_font.cget("family")

            if size is None:
                size = default_font.cget("size")

            font = Font(family=family, size=size, underline=underline)

        Label.__init__(self, master, text=text, fg=fg, cursor="hand2", font=font)

        if background is None:
            background = get_background_of_widget(master)

        self.configure(background=background)

        self._visited = visited
        self._action = action

        self.bind("<Button-1>", self._on_click)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def textwindow(url):
    title = url
    h = html2text.HTML2Text()
    h.ignore_links = True
    h.ignore_images = True
    s = gethtml(url)
    s = h.handle(s)
    s = h.unescape(s)
    text = convert65536(s)
    top = Tkinter.Toplevel()
    top.geometry("+200+100")
    top.title(title)
    top.bind("<Escape>", lambda _ : top.destroy())
    S = Tkinter.Scrollbar(top)
    customFont = tkFont.Font(family="Arial", size=16)
    T = TextPlus(top,height=20,width=78,font=customFont,bg="lightgrey")
    S.pack(side=Tkinter.RIGHT,fill=Tkinter.Y)
    T.pack(side=Tkinter.LEFT,fill=Tkinter.Y)
    S.config(command=T.yview)
    T.config(yscrollcommand=S.set)
    T.insert(Tkinter.END,text)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def main():
    root = Tkinter.Tk()
    root.geometry("950x32+200+32")
    root.title('markdown')
    dnd = TkDND(root)
    customFont = tkFont.Font(family="Arial", size=14)
    entry = EntryPlus(font=customFont,bg="lightgrey")
    entry.pack(expand=1,fill='both')
    dnd.bindtarget(entry,handle,'text/plain')
    entry.bind("<Return>", lambda _ : handlereturn(entry))
    root.mainloop()
项目:hostapd-mana    作者:adde88    | 项目源码 | 文件源码
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')
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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)
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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])
项目:oil    作者:oilshell    | 项目源码 | 文件源码
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
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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 = tkFont.Font()
        maxwidth = max(font.measure(col) for col in cols)
        for col in cols:
            self._calendar.column(col, width=maxwidth, minwidth=maxwidth,
                anchor='e')
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def __setup_selection(self, sel_bg, sel_fg):
        self._font = tkFont.Font()
        self._canvas = canvas = Tkinter.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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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)
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
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])
项目:sslstrip-hsts-openwrt    作者:adde88    | 项目源码 | 文件源码
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')
项目:SUTDAnnotator    作者:jiesutd    | 项目源码 | 文件源码
def setFont(self, value):
        _family=self.textFontStyle
        _size = value
        _weight="bold"
        _underline=0
        fnt = tkFont.Font(family= _family,size= _size,weight= _weight,underline= _underline)
        Text(self, font=fnt)
项目:SUTDAnnotator    作者:jiesutd    | 项目源码 | 文件源码
def setFont(self, value):
        _family=self.textFontStyle
        _size = value
        _weight="bold"
        _underline=0
        fnt = tkFont.Font(family= _family,size= _size,weight= _weight,underline= _underline)
        Text(self, font=fnt)
项目:learnRGB    作者:cbott    | 项目源码 | 文件源码
def __init__(self, master):
        #(r, g, b) displayed to the user
        self.color_prompt = [0, 0, 0]

        # user-selected color
        self.color_response = [random.randint(0,255) for i in range(3)]

        #just a big font so things are bigger
        self.big_font = tkFont.Font(root=master, family='Helvetica', size=20)

        Frame.__init__(self, master)
        self.grid()
        self.generate()
        self.next_color()
        self.select_color(0,0)
项目:raspberry-pi-2    作者:LuisDiazUgena    | 项目源码 | 文件源码
def __init__(self,_master):
        # ***** Toolbar *****
        self.toolBar = Frame(_master,bd=1,relief=SUNKEN)
        # ***** Statusbar *****
        self.status = Label(_master,text=" Preparing to do read...",bd=1,relief=SUNKEN,anchor=W)
        # ***** Buttons to bars *****
        self.aboutButton = Button(self.toolBar,text="About",command = about)
        self.githubButton = Button(self.toolBar,text="Github repo",command = openGit)
        self.quitButton = Button(self.toolBar,text="Quit",command = root.quit)
        # ***** Pack buttons *****
        self.aboutButton.pack(side=LEFT,padx=2,pady=2) #add padding
        self.githubButton.pack(side=LEFT,padx=2,pady=2) #add padding
        self.quitButton.pack(side=RIGHT,padx=2,pady=2) #add padding
        self.toolBar.pack(side=TOP,fill=X)
        self.status.pack(side=BOTTOM,fill=X)
        # ***** Frames for labels *****
        self.topFrame = Frame(_master)
        self.bottomFrame = Frame(_master)
        self.topFrame.pack(side=TOP)
        self.bottomFrame.pack(side=BOTTOM)
        # ***** Labels *****
        self.customFont = tkFont.Font(family="Helvetica", size=20)
        labelT = Label(self.topFrame,text="Temperature",font=self.customFont)
        valueT = Label(self.topFrame,text="None",font=self.customFont)
        labelH = Label(self.bottomFrame,text="Humidity",font=self.customFont)
        valueH = Label(self.bottomFrame,text="None",font=self.customFont)
        # ***** Pack labels *****
        labelT.pack(side=LEFT)
        valueT.pack(side=LEFT)
        labelH.pack(side=LEFT)
        valueH.pack(side=LEFT)
        measure()
项目:History-Generator    作者:ReedOei    | 项目源码 | 文件源码
def listbox_capacity(listbox):
    font = tkFont.Font(listbox, listbox['font'])

    return listbox.winfo_height() / font.metrics()['ascent']
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def fontFit(name, stringToFit, dimensionsToFit):
    fontSize = 1
    font = tkFont.Font(family=name, size=-fontSize) # Note: negative means font is that high, in pixels

    while True:
        fontSize += 1
        biggerFont = tkFont.Font(family=name, size=-fontSize)

        if fontSize >= dimensionsToFit[1] or font.measure(stringToFit) >= dimensionsToFit[0]:
            break

        font = biggerFont

    return font, (fontSize - 1)
项目:live_scoreboard    作者:ClysmiC    | 项目源码 | 文件源码
def __init__(self, x, y, panelWidth, panelHeight):
        self.width = panelWidth
        self.height = panelHeight
        self.x = x
        self.y = y

        self.canvas = tk.Canvas(root, width=self.width, height=self.height, background=panelBackground, highlightthickness=0)
        self.canvas.place(x=self.x, y=self.y)

        # Extra space before name for logo
        self.logoString = "    "
        exampleString = "1 " + self.logoString + " STL  100   62  -10.0"

        numLines = 9 # 1 for division name, 5 for teams, 2 for padding
        lineHeightMultiplier = 1.2 # Multiply font height by this to get line height

        self.font, self.fontHeight = fontFit(fontName, exampleString, (self.width * 0.9, self.height // (numLines * lineHeightMultiplier)))
        self.underlinedFont = tkFont.Font(family=fontName, size=-self.fontHeight, underline=1)

        self.lineHeight = self.fontHeight * lineHeightMultiplier

        # Center horizontally
        self.startX = (self.width - self.font.measure(exampleString)) // 2

        logoRegionWidth = self.font.measure(self.logoString)
        logoRegionHeight = self.fontHeight

        self.scaledLogos = {}

        # Initialize list of MLB team logos
        for key, logo in mlbLogos.items():
            logoHeight = logo.size[1]
            logoWidth = logo.size[0]
            scale = min(logoRegionHeight / float(logoHeight),
                        logoRegionWidth / float(logoWidth))

            self.scaledLogos[key] = ImageTk.PhotoImage(logo.resize((int(scale * logoWidth), int(scale * logoHeight))))                    

        self.displayingWildcard = False
        self.initiallySet = False
项目:zenchmarks    作者:squeaky-pl    | 项目源码 | 文件源码
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')
项目:Structural-Engineering    作者:buddyd16    | 项目源码 | 文件源码
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])
项目:Structural-Engineering    作者:buddyd16    | 项目源码 | 文件源码
def font_size_up(self, *event):
        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)
项目:Structural-Engineering    作者:buddyd16    | 项目源码 | 文件源码
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)
项目:Structural-Engineering    作者:buddyd16    | 项目源码 | 文件源码
def shape_click(self, *event):
        shape = self.shape_menu.get(self.shape_menu.curselection())
        shape_index = self.shape_types.index(self.shape_type.get())
        section_props = self.shape_sets[shape_index].get(shape)

        if section_props[0] == 'F':
            self.data_frame.configure(text="Section Properties - AISC 14th Edition:  --  Selected Shape: "+shape)
        else:
            note = self.shape_special_note[shape_index]
            self.data_frame.configure(text="Section Properties - AISC 14th Edition:  --  Selected Shape: "+shape+" -- Note: "+note)
        for labels in self.properties_labels:
            labels.configure( text=' ')

        props_counter = 0
        props_list = []
        for i in range(1,len(self.values_list)):
            if section_props[i] == '-':
               pass
            else:
                if self.values_units[i] == '':
                    string = '{0}{1}:\n{2}'.format(self.values_list[i],self.values_units[i],section_props[i])
                else:
                    string = '{0}({1}):\n{2}'.format(self.values_list[i],self.values_units[i],section_props[i])
                    props_list.append(self.values_list[i])

                self.properties_labels[props_counter].configure( text=string)                
                props_counter+=1

        self.value_def_menu.destroy()
        self.value_def_menu = tk.OptionMenu(self.value_def_frame, self.value_def, *props_list, command=self.value_definitions)
        helv = tkFont.Font(family='Helvetica',size=self.f_size, weight='bold')
        self.value_def_menu.config(font=helv)
        self.value_def_menu.grid(row=0, column=0, padx=1, pady=1)
        self.value_def.set(props_list[0])
        self.value_definitions()
项目:Structural-Engineering    作者:buddyd16    | 项目源码 | 文件源码
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)
项目:Reversia    作者:Djedjeey    | 项目源码 | 文件源码
def __init__(self, client, clientinlist, master=None):
        Frame.__init__(self, master)     # Create the main frame.

        self.widthx = 300                                       # Width of the frame.
        self.heighty = 100                                      # Height of the frame.
        self.client = client                                    # The client.
        self.dim = "600x300"                                    # Dimension of the panel.
        self.ip = str(self.client.ip)                           # Ip of the client.
        self.port = str(self.client.port)                       # Port of the client.
        self.write = None
        self.read = None
        self.clientinlist = clientinlist
        self.writetext = None
        self.textarea = None
        self.scroll = None

        master.wm_title(self.ip + ":" + self.port)              # Title of the window.
        master.minsize(width=self.widthx, height=self.heighty)  # Min size.
        master.geometry(self.dim)
        master.protocol("WM_DELETE_WINDOW", self.on_closing)

        self.customFont = tkFont.Font(family="Monospace", size=12)  # Set font family and text size.
        self.read_write_panel()                                     # Customize the frame by adding panel.
        self.thread_start()                                         # Start needed thread.

    ###############################################
    # Text Panel used to show the client messages #
    ###############################################
项目:rensapy    作者:RensaProject    | 项目源码 | 文件源码
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())
项目:rensapy    作者:RensaProject    | 项目源码 | 文件源码
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)
项目:rensapy    作者:RensaProject    | 项目源码 | 文件源码
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())
项目:RePhraser    作者:MissLummie    | 项目源码 | 文件源码
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())
项目:RePhraser    作者:MissLummie    | 项目源码 | 文件源码
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)
项目:RePhraser    作者:MissLummie    | 项目源码 | 文件源码
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())
项目:huatian-funny    作者:LiuRoy    | 项目源码 | 文件源码
def add_assembly():
    """????"""
    init()

    buy_house_static = Label(master, text=u'??: ', font=Font(size=15))
    buy_house_static.place(anchor=u'nw', x=440, y=50)
    buy_car_static = Label(master, text=u'??: ', font=Font(size=15))
    buy_car_static.place(anchor=u'nw', x=440, y=75)
    age_static = Label(master, text=u'??: ', font=Font(size=15))
    age_static.place(anchor=u'nw', x=440, y=100)
    height_static = Label(master, text=u'??: ', font=Font(size=15))
    height_static.place(anchor=u'nw', x=440, y=125)
    salary_static = Label(master, text=u'??: ', font=Font(size=15))
    salary_static.place(anchor=u'nw', x=440, y=150)
    education_static = Label(master, text=u'??: ', font=Font(size=15))
    education_static.place(anchor=u'nw', x=440, y=175)
    company_static = Label(master, text=u'??: ', font=Font(size=15))
    company_static.place(anchor=u'nw', x=440, y=200)
    industry_static = Label(master, text=u'??: ', font=Font(size=15))
    industry_static.place(anchor=u'nw', x=440, y=225)
    school_static = Label(master, text=u'??: ', font=Font(size=15))
    school_static.place(anchor=u'nw', x=440, y=250)
    position_static = Label(master, text=u'??: ', font=Font(size=15))
    position_static.place(anchor=u'nw', x=440, y=275)
    previous = Button(master, text=u'???', command=handle_previous)
    previous.place(anchor=u'nw', x=10, y=490)
    next = Button(master, text=u'???', command=handle_next)
    next.place(anchor=u'nw', x=520, y=490)
项目:Verideals    作者:Derrreks    | 项目源码 | 文件源码
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())