python类Font()的实例源码

numberlearn.py 文件源码 项目:learnRGB 作者: cbott 项目源码 文件源码 阅读 13 收藏 0 点赞 0 评论 0
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)
dht22-guy.py 文件源码 项目:raspberry-pi-2 作者: LuisDiazUgena 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
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()
utility.py 文件源码 项目:History-Generator 作者: ReedOei 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def listbox_capacity(listbox):
    font = tkFont.Font(listbox, listbox['font'])

    return listbox.winfo_height() / font.metrics()['ascent']
live_scoreboard.py 文件源码 项目:live_scoreboard 作者: ClysmiC 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
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.py 文件源码 项目:live_scoreboard 作者: ClysmiC 项目源码 文件源码 阅读 30 收藏 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)

        # 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
tkvt100.py 文件源码 项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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')
aisc_steel_shapes_historic.py 文件源码 项目:Structural-Engineering 作者: buddyd16 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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])
aisc_steel_shapes_historic.py 文件源码 项目:Structural-Engineering 作者: buddyd16 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
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)
aisc_steel_shapes_historic.py 文件源码 项目:Structural-Engineering 作者: buddyd16 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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)
aisc_steel_shapes.py 文件源码 项目:Structural-Engineering 作者: buddyd16 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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()
aisc_steel_shapes.py 文件源码 项目:Structural-Engineering 作者: buddyd16 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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)
shellwindow.py 文件源码 项目:Reversia 作者: Djedjeey 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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 #
    ###############################################
srparser.py 文件源码 项目:rensapy 作者: RensaProject 项目源码 文件源码 阅读 16 收藏 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())
chart.py 文件源码 项目:rensapy 作者: RensaProject 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
chart.py 文件源码 项目:rensapy 作者: RensaProject 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
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())
srparser.py 文件源码 项目:RePhraser 作者: MissLummie 项目源码 文件源码 阅读 17 收藏 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())
chart.py 文件源码 项目:RePhraser 作者: MissLummie 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
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)
chart.py 文件源码 项目:RePhraser 作者: MissLummie 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
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())
mark.py 文件源码 项目:huatian-funny 作者: LiuRoy 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
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)
srparser.py 文件源码 项目:Verideals 作者: Derrreks 项目源码 文件源码 阅读 21 收藏 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())


问题


面经


文章

微信
公众号

扫码关注公众号