當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。