当前位置: 首页>>代码示例>>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;未经允许,请勿转载。