python类Font()的实例源码

tk_ui.py 文件源码 项目:pytknvim 作者: timeyyy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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')
tarruda.py 文件源码 项目:pytknvim 作者: timeyyy 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
tarruda.py 文件源码 项目:pytknvim 作者: timeyyy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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()
tk_canvas.py 文件源码 项目:pytknvim 作者: timeyyy 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
tk_canvas.py 文件源码 项目:pytknvim 作者: timeyyy 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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()
treeview_multicolumn.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
colorlearn.py 文件源码 项目:learnRGB 作者: cbott 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:live_scoreboard 作者: ClysmiC 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
dialog_PeripheralSetting.py 文件源码 项目:Farmbot_GeneralAP 作者: SpongeYao 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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")
    # ########################################
judge.py 文件源码 项目:pokerface 作者: LiuRoy 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
speedometer.py 文件源码 项目:Sample-Code 作者: meigrafd 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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')
rdparser.py 文件源码 项目:rensapy 作者: RensaProject 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
rdparser.py 文件源码 项目:RePhraser 作者: MissLummie 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
rdparser.py 文件源码 项目:Verideals 作者: Derrreks 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
SIGMAEditor.py 文件源码 项目:adtree-py 作者: uraplutonium 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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()
recipe-578886.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
recipe-580774.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
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)
recipe-579107.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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)
recipe-579107.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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()
tkvt100.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 49 收藏 0 点赞 0 评论 0
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')
test_font.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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)
test_font.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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])
help.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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
ttkcalendar.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
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')
ttkcalendar.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
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)
test_font.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
test_font.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
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])
tkvt100.py 文件源码 项目:sslstrip-hsts-openwrt 作者: adde88 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
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')
YEDDA_Annotator.py 文件源码 项目:SUTDAnnotator 作者: jiesutd 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
Event_beta.py 文件源码 项目:SUTDAnnotator 作者: jiesutd 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)


问题


面经


文章

微信
公众号

扫码关注公众号