當前位置: 首頁>>代碼示例>>Python>>正文


Python font.Font方法代碼示例

本文整理匯總了Python中tkinter.font.Font方法的典型用法代碼示例。如果您正苦於以下問題:Python font.Font方法的具體用法?Python font.Font怎麽用?Python font.Font使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tkinter.font的用法示例。


在下文中一共展示了font.Font方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _init_fonts

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
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) 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:19,代碼來源:drt_glue_demo.py

示例2: create_tags

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def create_tags(self):
        super().create_tags() # for url tag
        # Don't modify predefined fonts!
        baseFont = tkfont.nametofont("TkDefaultFont")
        size = baseFont.cget("size") # -ve is pixels +ve is points
        bodyFont = tkfont.Font(family=baseFont.cget("family"), size=size)
        titleFont = tkfont.Font(family=baseFont.cget("family"),
                size=((size - 8) if size < 0 else (size + 3)),
                weight=tkfont.BOLD)

        self.text.config(font=bodyFont)
        self.text.tag_config("title", font=titleFont,
                foreground="navyblue", spacing1=3, spacing3=5)
        self.text.tag_config("versions", foreground="darkgreen")
        self.text.tag_config("above5", spacing1=5)
        self.text.tag_config("above3", spacing1=3) 
開發者ID:lovexiaov,項目名稱:python-in-practice,代碼行數:18,代碼來源:About.py

示例3: create_widgets

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def create_widgets(self, **kwargs):
    """
    Widgets shown:
    - The frame's title,
    - The checkbutton to enable/disable displaying,
    - The textbox.

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

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

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

    self.top_frame.grid(row=0)
    self.serial_monitor.grid(row=1) 
開發者ID:LaboratoireMecaniqueLille,項目名稱:crappy,代碼行數:27,代碼來源:arduino_basics.py

示例4: test_fontchooser_selection

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def test_fontchooser_selection(self):
            chooser = FontChooser(self.window)
            self.window.update()
            chooser._font_family_list.listbox.selection_set(1)
            chooser._font_family_list._on_click()
            self.window.update()
            results = chooser.font
            self.assertIsInstance(results, tuple)
            self.assertEqual(len(results), 2)
            self.assertIsInstance(results[0], tuple)
            self.assertEqual(len(results[0]), 2)
            self.assertIsInstance(results[1], font.Font)
            chooser._on_family('')
            self.window.update()
            results = chooser.font
            self.assertIsNone(results[0]) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:18,代碼來源:test_font_widgets.py

示例5: test_fontselectframe_family

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def test_fontselectframe_family(self):
            frame = FontSelectFrame(self.window)
            frame.pack()
            self.window.update()
            frame._family_dropdown.set(font.families()[1])
            self.window.update()
            frame._on_family(frame._family_dropdown.get())
            results = frame.font
            self.assertIsInstance(results, tuple)
            self.assertEqual(len(results), 2)
            self.assertIsInstance(results[0], tuple)
            self.assertEqual(len(results[0]), 2)
            self.assertIsInstance(results[1], font.Font)

            frame._on_size(20)
            frame._on_family('Arial')
            frame._on_properties((True, True, True, True))
            self.window.update()
            results = frame.font
            self.assertEqual(results[0], ('Arial', 20, 'bold', 'italic',
                                          'underline', 'overstrike')) 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:23,代碼來源:test_font_widgets.py

示例6: font

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def font(self):
        """
        Selected font.
        
        :return: font tuple (family_name, size, \*options), :class:`~font.Font` object
        """
        if self._family is None:
            return None, None
        else:
            font_tuple = self.__generate_font_tuple()
            font_obj = tkfont.Font(family=self._family, size=self._size,
                                   weight=tkfont.BOLD if self._bold else tkfont.NORMAL,
                                   slant=tkfont.ITALIC if self._italic else tkfont.ROMAN,
                                   underline=1 if self._underline else 0,
                                   overstrike=1 if self._overstrike else 0)
            return font_tuple, font_obj 
開發者ID:TkinterEP,項目名稱:ttkwidgets,代碼行數:18,代碼來源:chooser.py

示例7: launch

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def launch(self):
        self.root = tk.Tk()
        self.root.wait_visibility(self.root)
        self.title_font = Font(size=16, weight='bold')
        self.bold_font = Font(weight='bold')

        self.root.geometry("900x600")

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

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

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

        self.root.mainloop() 
開發者ID:IBM,項目名稱:clai,代碼行數:21,代碼來源:clai_emulator.py

示例8: drawGrid

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def drawGrid(self, clearGrid = False):
		font = tkFont.Font(family=zynthian_gui_config.font_topbar[0], size=self.fontsize)
		if clearGrid:
			self.gridCanvas.delete(tkinter.ALL)
			self.columnWidth = self.gridWidth / self.horizontalZoom
			self.trackTitleCanvas.delete("trackname")
		self.playCanvas.delete("timetext")
		# Draw cells of grid
		self.gridCanvas.itemconfig("gridcell", fill=CELL_BACKGROUND)
		for row in range(self.verticalZoom):
			if row >= len(self.tracks):
				break
			if clearGrid:
				self.trackTitleCanvas.create_text((0, self.rowHeight * (row + 0.5)), text="Track %d" % (self.tracks[row]), font=font, fill=CELL_FOREGROUND, tags=("rowtitle%d" % (row),"trackname"), anchor="w")
				self.gridCanvas.create_text(self.gridWidth - self.selectThickness, self.rowHeight * (self.rowHeight * int(row + 0.5)), state="hidden", tags=("lastpatterntext%d" % (row), "lastpatterntext"), font=font, anchor="e")
			self.drawRow(row)
		self.playCanvas.create_text(0 * self.columnWidth, PLAYHEAD_HEIGHT / 2, text="%d"%(self.colOffset), tags=("timetext"), anchor="w", fill=CELL_FOREGROUND)

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

	# Function to update selectedCell
	#	clock: Clock (column) of selected cell (Optional - default to reselect current column)
	#	track: Track number of selected cell (Optional - default to reselect current =row) 
開發者ID:zynthian,項目名稱:zynthian-ui,代碼行數:27,代碼來源:zynthian_gui_songeditor.py

示例9: __init__

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def __init__(self, master=None, **kw):
        now = datetime.datetime.now()
        fwday = kw.pop('firstweekday', calendar.MONDAY)
        year = kw.pop('year', now.year)
        month = kw.pop('month', now.month)
        sel_bg = kw.pop('selectbackground', '#ecffc4')
        sel_fg = kw.pop('selectforeground', '#05640e')

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

        self.selected = None
        self.date = datetime.date(year, month, 1)
        self.cal = calendar.TextCalendar(fwday)
        self.font = tkfont.Font(self)
        self.header = self.create_header()
        self.table = self.create_table()
        self.canvas = self.create_canvas(sel_bg, sel_fg)
        self.build_calendar() 
開發者ID:PacktPublishing,項目名稱:Tkinter-GUI-Application-Development-Cookbook,代碼行數:20,代碼來源:chapter8_07.py

示例10: __init__

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
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) 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:8,代碼來源:drt_glue_demo.py

示例11: __init__

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def __init__(self, drs, size_canvas=True, canvas=None):
        """
        :param drs: ``DrtExpression``, 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 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:33,代碼來源:drt.py

示例12: get_avg_charwidth

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def get_avg_charwidth(widget=None, text=None):
    if text is None:
        text = string.printable
    if widget is None:
        font = tkfont.Font(font='TkTextFont')
    else:
        font = tkfont.Font(font=widget['font'])
    return sum([font.measure(c) for c in text]) / len(text) 
開發者ID:Dogeek,項目名稱:rpg-text,代碼行數:10,代碼來源:map-creator.py

示例13: __init__

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def __init__(self, root, text, suffix):
        super().__init__(root)
        self._text = tk.Text(self, width=90, yscrollcommand=self._text_scroll)
        self._scroll = ttk.Scrollbar(self)
        self._scroll.pack(side="left", fill="y")
        self._scroll.config(command=self._scrollbar_scroll)
        self._line_no = tk.Text(self, width=4, yscrollcommand=self._text_scroll)
        self._line_no.pack(side="left", fill="y")

        self._text.pack(side="right", fill="y")
        self._text.insert(1.0, text)

        for k, v in TEXT_COLORS.items():
            self._text.tag_config(k, **v)

        if suffix == ".sol":
            pattern = r"((?:\s*\/\/[^\n]*)|(?:\/\*[\s\S]*?\*\/))"
        else:
            pattern = r"((#[^\n]*\n)|(\"\"\"[\s\S]*?\"\"\")|('''[\s\S]*?'''))"
        for match in re.finditer(pattern, text):
            self.tag_add("comment", match.start(), match.end())

        self._line_no.insert(1.0, "\n".join(str(i) for i in range(1, text.count("\n") + 2)))
        self._line_no.tag_configure("justify", justify="right")
        self._line_no.tag_add("justify", 1.0, "end")

        for text in (self._line_no, self._text):
            text.config(**TEXT_STYLE)
            text.config(tabs=tkFont.Font(font=text["font"]).measure("    "), wrap="none")
        self._line_no.config(background="#272727")
        self._text.bind("<ButtonRelease-1>", root._search) 
開發者ID:eth-brownie,項目名稱:brownie,代碼行數:33,代碼來源:source.py

示例14: __init__

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def __init__(self, text, regexp=False, nocase=False):
        self.text = text
        self.pattern = tkinter.StringVar()
        self.regexp = tkinter.IntVar(int(regexp))
        self.nocase = tkinter.IntVar(int(nocase))
        self.prev_pattern = ""
        self.prev_regexp = regexp
        self.prev_nocase = nocase
        self.findings = []
        self.current = -1
        self.text.tag_config("search", background='yellow', foreground="black")
        bold_font = Font(self.text)
        bold_font.configure(weight="bold")
        self.text.tag_config("search_current", font=bold_font) 
開發者ID:YoannDupont,項目名稱:SEM,代碼行數:16,代碼來源:components.py

示例15: addEntrySetting

# 需要導入模塊: from tkinter import font [as 別名]
# 或者: from tkinter.font import Font [as 別名]
def addEntrySetting(self, var, labelText, descriptorText):
        centerFrame = tk.Frame(self)
        centerFrame.grid(row=self.counter, column="1", columnspan="2", sticky="w")
        label = tk.Label(centerFrame, text=labelText)
        label.grid(row=self.counter, column="1", sticky="w")
        entry = tk.Entry(centerFrame, textvariable=var, width=25)
        entry.grid(row=self.counter, column="2", sticky="w")
        descriptor = tk.Label(self, text=descriptorText)
        font = tkFont.Font(font=descriptor['font'])
        font.config(slant='italic')
        descriptor['font'] = font
        descriptor.grid(row=self.counter+1, column="1", columnspan="2", sticky="w")
        tk.Frame(self, height="10", width="10").grid(row=self.counter+2, column="1", columnspan="5")
        self.counter += 3 
開發者ID:ArtificialQualia,項目名稱:PyEveLiveDPS,代碼行數:16,代碼來源:fleetConnectionWindow.py


注:本文中的tkinter.font.Font方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。