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


Python Font.actual方法代码示例

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


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

示例1: GetFont

# 需要导入模块: from tkinter.font import Font [as 别名]
# 或者: from tkinter.font.Font import actual [as 别名]
    def GetFont(self, root, configType, section):
        """Retrieve a font from configuration (font, font-size, font-bold)
        Intercept the special value 'TkFixedFont' and substitute
        the actual font, factoring in some tweaks if needed for
        appearance sakes.

        The 'root' parameter can normally be any valid Tkinter widget.

        Return a tuple (family, size, weight) suitable for passing
        to tkinter.Font
        """
        family = self.GetOption(configType, section, "font", default="courier")
        size = self.GetOption(configType, section, "font-size", type="int", default="10")
        bold = self.GetOption(configType, section, "font-bold", default=0, type="bool")
        if family == "TkFixedFont":
            if TkVersion < 8.5:
                family = "Courier"
            else:
                f = Font(name="TkFixedFont", exists=True, root=root)
                actualFont = Font.actual(f)
                family = actualFont["family"]
                size = actualFont["size"]
                if size < 0:
                    size = 10  # if font in pixels, ignore actual size
                bold = actualFont["weight"] == "bold"
        return (family, size, "bold" if bold else "normal")
开发者ID:roseman,项目名称:idle,代码行数:28,代码来源:configHandler.py

示例2: GetFont

# 需要导入模块: from tkinter.font import Font [as 别名]
# 或者: from tkinter.font.Font import actual [as 别名]
    def GetFont(self, root, configType, section):
        """Retrieve a font from configuration (font, font-size, font-bold)
        Intercept the special value 'TkFixedFont' and substitute
        the actual font, factoring in some tweaks if needed for
        appearance sakes.

        The 'root' parameter can normally be any valid Tkinter widget.

        Return a tuple (family, size, weight) suitable for passing
        to tkinter.Font
        """
        family = self.GetOption(configType, section, 'font', default='courier')
        size = self.GetOption(configType, section, 'font-size', type='int',
                              default='10')
        bold = self.GetOption(configType, section, 'font-bold', default=0,
                              type='bool')
        if (family == 'TkFixedFont'):
            f = Font(name='TkFixedFont', exists=True, root=root)
            actualFont = Font.actual(f)
            family = actualFont['family']
            size = actualFont['size']
            if size <= 0:
                size = 10  # if font in pixels, ignore actual size
            bold = actualFont['weight'] == 'bold'
        return (family, size, 'bold' if bold else 'normal')
开发者ID:1st1,项目名称:cpython,代码行数:27,代码来源:config.py

示例3: test_get_font

# 需要导入模块: from tkinter.font import Font [as 别名]
# 或者: from tkinter.font.Font import actual [as 别名]
    def test_get_font(self):
        from test.support import requires
        from tkinter import Tk
        from tkinter.font import Font
        conf = self.mock_config()

        requires('gui')
        root = Tk()
        root.withdraw()

        f = Font.actual(Font(name='TkFixedFont', exists=True, root=root))
        self.assertEqual(
            conf.GetFont(root, 'main', 'EditorWindow'),
            (f['family'], 10 if f['size'] <= 0 else f['size'], f['weight']))

        # Cleanup root
        root.destroy()
        del root
开发者ID:Apoorvadabhere,项目名称:cpython,代码行数:20,代码来源:test_config.py


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