当前位置: 首页>>代码示例>>Python>>正文


Python font.families方法代码示例

本文整理汇总了Python中tkinter.font.families方法的典型用法代码示例。如果您正苦于以下问题:Python font.families方法的具体用法?Python font.families怎么用?Python font.families使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.font的用法示例。


在下文中一共展示了font.families方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_fontselectframe_family

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [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

示例2: __init__

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def __init__(self, master=None, callback=None, **kwargs):
        """
        Create a FontFamilyDropdown.

        :param master: master widget
        :type master: widget
        :param callback: callable object with single argument: font family name
        :type callback: function
        :param kwargs: keyword arguments passed on to the :class:`~ttkwidgets.autocomplete.AutocompleteCombobox` initializer
        """
        font_families = sorted(set(font.families()))
        self._fonts = font_families
        self._font = tk.StringVar(master)
        self.__callback = callback
        AutocompleteCombobox.__init__(self, master, textvariable=self._font, completevalues=font_families, **kwargs)
        self.bind("<<ComboboxSelected>>", self._on_select)
        self.bind("<Return>", self._on_select) 
开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:19,代码来源:familydropdown.py

示例3: __init__

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def __init__(self, master=None, callback=None, **kwargs):
        """
        Create a FontFamilyListbox.

        :param master: master widget
        :type master: widget
        :param callback: callable object with one argument: the font family name
        :type callback: function
        :param kwargs: keyword arguments passed to :class:`~ttkwidgets.ScrolledListbox`, in turn passed to :class:`tk.Listbox`
        """
        ScrolledListbox.__init__(self, master, compound=tk.RIGHT, **kwargs)
        self._callback = callback
        font_names = sorted(set(font.families()))
        index = 0
        self.font_indexes = {}
        for name in font_names:
            self.listbox.insert(index, name)
            self.font_indexes[index] = name
            index += 1
        self.listbox.bind("<<ListboxSelect>>", self._on_click) 
开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:22,代码来源:familylistbox.py

示例4: __init__

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def __init__(self, master, **kwargs):
        super().__init__(**kwargs)
        self.master = master

        self.transient(self.master)
        self.geometry('500x250')
        self.title('Choose font and size')

        self.configure(bg=self.master.background)

        self.font_list = tk.Listbox(self, exportselection=False)

        self.available_fonts = sorted(families())

        for family in self.available_fonts:
            self.font_list.insert(tk.END, family)

        current_selection_index = self.available_fonts.index(self.master.font_family)
        if current_selection_index:
            self.font_list.select_set(current_selection_index)
            self.font_list.see(current_selection_index)

        self.size_input = tk.Spinbox(self, from_=0, to=99, value=self.master.font_size)

        self.save_button = ttk.Button(self, text="Save", style="editor.TButton", command=self.save)

        self.save_button.pack(side=tk.BOTTOM, fill=tk.X, expand=1, padx=40)
        self.font_list.pack(side=tk.LEFT, fill=tk.Y, expand=1)
        self.size_input.pack(side=tk.BOTTOM, fill=tk.X, expand=1) 
开发者ID:PacktPublishing,项目名称:Tkinter-GUI-Programming-by-Example,代码行数:31,代码来源:fontchooser.py

示例5: font_families

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def font_families():
    """Returns all the system-specific font families, plus the three
    guaranteed built-in font families"""
    return sorted(set(tkfont.families()) |
            {"Helvetica", "Times", "Courier"}) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:7,代码来源:__init__.py

示例6: test_families

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def test_families(self):
        families = font.families(self.root)
        self.assertIsInstance(families, tuple)
        self.assertTrue(families)
        for family in families:
            self.assertIsInstance(family, str)
            self.assertTrue(family) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:9,代码来源:test_font.py

示例7: LoadFontCfg

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def LoadFontCfg(self):
        ##base editor font selection list
        fonts = list(tkFont.families(self))
        fonts.sort()
        for font in fonts:
            self.listFontName.insert(END, font)
        configuredFont = idleConf.GetFont(self, 'main', 'EditorWindow')
        fontName = configuredFont[0].lower()
        fontSize = configuredFont[1]
        fontBold  = configuredFont[2]=='bold'
        self.fontName.set(fontName)
        lc_fonts = [s.lower() for s in fonts]
        try:
            currentFontIndex = lc_fonts.index(fontName)
            self.listFontName.see(currentFontIndex)
            self.listFontName.select_set(currentFontIndex)
            self.listFontName.select_anchor(currentFontIndex)
        except ValueError:
            pass
        ##font size dropdown
        self.optMenuFontSize.SetMenu(('7', '8', '9', '10', '11', '12', '13',
                                      '14', '16', '18', '20', '22'), fontSize )
        ##fontWeight
        self.fontBold.set(fontBold)
        ##font sample
        self.SetFontSample() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:28,代码来源:configDialog.py

示例8: findfont

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
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 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:11,代码来源:help.py

示例9: get_clean_fonts

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def get_clean_fonts():
    """ Return the font list with any @prefixed or non-Unicode characters stripped
        and default prefixed """
    cleaned_fonts = sorted([fnt for fnt in font.families()
                            if not fnt.startswith("@") and not any([ord(c) > 127 for c in fnt])])
    return ["default"] + cleaned_fonts 
开发者ID:deepfakes,项目名称:faceswap,代码行数:8,代码来源:_config.py

示例10: _get_families_to_show

# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import families [as 别名]
def _get_families_to_show(self):
        # In Linux, families may contain duplicates (actually different fonts get same names)
        return sorted(set(filter(lambda name: name[0].isalpha(), tk_font.families()))) 
开发者ID:thonny,项目名称:thonny,代码行数:5,代码来源:theme_and_font_config_page.py


注:本文中的tkinter.font.families方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。