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

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

示例1: create_tags

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [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,

示例2: __init__

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def __init__(self, master):

self.master = master

master.title("StochOPy Viewer")

master.protocol("WM_DELETE_WINDOW", self.close_window)

master.geometry("900x600")

master.minsize(900, 600)

master.maxsize(900, 600)

default_font = font.nametofont("TkDefaultFont")

default_font.configure(family = "Helvetica", size = 9)

master.option_add("*Font", default_font)

self.define_variables()

self.trace_variables()

self.init_variables()

self.menubar()

self.frame1()

self.frame2()

self.footer()

self.select_widget(self.solver_name.get())

开发者ID:keurfonluu,项目名称:stochopy,代码行数:22,

示例3: chg_fontsize

​点赞 6

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def chg_fontsize(self):

"""change the display font size"""

sizes = [10, 13, 14]

font_types = ["TkDefaultFont", "TkTextFont", "TkFixedFont",

"TkMenuFont", "TkHeadingFont", "TkCaptionFont",

"TkSmallCaptionFont", "TkIconFont", "TkTooltipFont"]

ww = ['normal', 'bold']

if self.font_size < max(sizes):

self.font_size = min([i for i in sizes if i > self.font_size])

else:

self.font_size = sizes[0]

self.font_wheight = 0

ff = 'Helvetica' if self.font_size != min(sizes) else 'Courier'

self.font_wheight = 0 if self.font_size == min(sizes) else 1

for typ in font_types:

default_font = font.nametofont(typ)

default_font.configure(size=self.font_size,

weight=ww[self.font_wheight], family=ff)

开发者ID:stonebig,项目名称:sqlite_bro,代码行数:21,

示例4: set_font

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def set_font(self, *args):

font_size = self.settings['font size'].get()

font_names = ('TkDefaultFont', 'TkMenuFont', 'TkTextFont')

for font_name in font_names:

tk_font = nametofont(font_name)

tk_font.config(size=font_size)

开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-with-Tkinter,代码行数:8,

示例5: get_font_scale_factor

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def get_font_scale_factor(font_name):

"""

Calculate the ratio between the system font and the default font, on which default sizes are based

:return the ratio between system font (currently used) and the default font

"""

font_size_system = font.nametofont(font_name).cget("size")

if font_size_system > 0:

# pt size

return font_size_system / FONT_DEFAULT_SIZE

else:

return font_size_system / FONT_DEFAULT_SIZE_PIXEL

开发者ID:morpheusthewhite,项目名称:nordpy,代码行数:14,

示例6: define_style

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def define_style(self):

"""Define apperance style."""

self.padx = 10

self.pady = 5

font_family = 'clearlyu devagari'

self.header_font = (font_family, '11', 'bold')

font.nametofont('TkDefaultFont').configure(family=font_family, size=11)

font.nametofont('TkMenuFont').configure(family=font_family, size=11,

weight=font.BOLD)

font.nametofont('TkTextFont').configure(family=font_family, size=11)

self.kwargs = {'fill': 'both', 'expand': True,

'padx': self.padx, 'pady': self.pady}

开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:14,

示例7: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def __init__(self, msg, title, choices, preselect, multiple_select, callback):

self.callback = callback

self.choices = choices

self.width_in_chars = global_state.prop_font_line_length

# Initialize self.selected_choices

# This is the value that will be returned if the user clicks the close

# icon

# self.selected_choices = None

self.multiple_select = multiple_select

self.boxRoot = tk.Tk()

self.boxFont = tk_Font.nametofont("TkTextFont")

self.config_root(title)

self.set_pos(global_state.window_position) # GLOBAL POSITION

self.create_msg_widget(msg)

self.create_choicearea()

self.create_ok_button()

self.create_cancel_button()

self. create_special_buttons()

self.preselect_choice(preselect)

self.choiceboxWidget.focus_force()

# Run and stop methods ---------------------------------------

开发者ID:robertlugg,项目名称:easygui,代码行数:39,

示例8: get_text_font

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def get_text_font(text):

font = text["font"]

if isinstance(font, str):

return tkfont.nametofont(font)

else:

return font

开发者ID:thonny,项目名称:thonny,代码行数:8,

示例9: __init__

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def __init__(self, master, columns, show_statusbar=False):

TreeFrame.__init__(self, master, columns, show_statusbar=show_statusbar)

font = tk_font.nametofont("TkDefaultFont").copy()

font.configure(underline=True)

self.tree.tag_configure("hovered", font=font)

开发者ID:thonny,项目名称:thonny,代码行数:8,

示例10: update_fonts

​点赞 5

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def update_fonts():

from tkinter import font

options = {}

for path in [GLOBAL_CONFIGURATION_PATH, CONFIGURATION_PATH]:

if os.path.exists(path):

with open(path) as fp:

for line in fp:

if "sGtk/FontName" in line:

result = re.search(r"=([^0-9]*) ([0-9]*)", line, re.M) # @UndefinedVariable

family = result.group(1)

options["size"] = int(result.group(2))

if re.search(r"\bBold\b", family):

options["weight"] = "bold"

else:

options["weight"] = "normal"

if re.search(r"\bItalic\b", family):

options["slant"] = "italic"

else:

options["slant"] = "roman"

options["family"] = family.replace(" Bold", "").replace(" Italic", "")

if options:

for name in ["TkDefaultFont", "TkMenuFont", "TkTextFont", "TkHeadingFont"]:

font.nametofont(name).configure(**options)

开发者ID:thonny,项目名称:thonny,代码行数:30,

示例11: __init__

​点赞 4

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def __init__(self, msg, title, text, codebox, callback):

""" Create ui object

Parameters

----------

msg : string

text displayed in the message area (instructions...)

title : str

the window title

text: str, list or tuple

text displayed in textAres (editable)

codebox: bool

if True, don't wrap, and width is set to 80 chars

callback: function

if set, this function will be called when OK is pressed

Returns

-------

object

The ui object

"""

self.callback = callback

self.boxRoot = tk.Tk()

# self.boxFont = tk_Font.Font(

# family=global_state.PROPORTIONAL_FONT_FAMILY,

# size=global_state.PROPORTIONAL_FONT_SIZE)

wrap_text = not codebox

if wrap_text:

self.boxFont = tk_Font.nametofont("TkTextFont")

self.width_in_chars = global_state.prop_font_line_length

else:

self.boxFont = tk_Font.nametofont("TkFixedFont")

self.width_in_chars = global_state.fixw_font_line_length

# default_font.configure(size=global_state.PROPORTIONAL_FONT_SIZE)

self.configure_root(title)

self.create_msg_widget(msg)

self.create_text_area(wrap_text)

self.create_buttons_frame()

self.create_cancel_button()

self.create_ok_button()

# Run and stop methods ---------------------------------------

开发者ID:robertlugg,项目名称:easygui,代码行数:54,

示例12: __init__

​点赞 4

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def __init__(self, msg, title, choices, images, default_choice, cancel_choice, callback):

""" Create ui object

Parameters

----------

msg : string

text displayed in the message area (instructions...)

title : str

the window title

choices : iterable of strings

build a button for each string in choices

images : iterable of filenames, or an iterable of iterables of filenames

displays each image

default_choice : string

one of the strings in choices to be the default selection

cancel_choice : string

if X or is pressed, it appears as if this button was pressed.

callback: function

if set, this function will be called when any button is pressed.

Returns

-------

object

The ui object

"""

self._title = title

self._msg = msg

self._choices = choices

self._default_choice = default_choice

self._cancel_choice = cancel_choice

self.callback = callback

self._choice_text = None

self._choice_rc = None

self._images = list()

self.boxRoot = tk.Tk()

# self.boxFont = tk_Font.Font(

# family=global_state.PROPORTIONAL_FONT_FAMILY,

# size=global_state.PROPORTIONAL_FONT_SIZE)

self.boxFont = tk_Font.nametofont("TkFixedFont")

self.width_in_chars = global_state.fixw_font_line_length

# default_font.configure(size=global_state.PROPORTIONAL_FONT_SIZE)

self.configure_root(title)

self.create_msg_widget(msg)

self.create_images_frame()

self.create_images(images)

self.create_buttons_frame()

self.create_buttons(choices, default_choice)

开发者ID:robertlugg,项目名称:easygui,代码行数:59,

示例13: _init_scaling

​点赞 4

# 需要导入模块: from tkinter import font [as 别名]

# 或者: from tkinter.font import nametofont [as 别名]

def _init_scaling(self) -> None:

self._default_scaling_factor = self.tk.call("tk", "scaling")

if self._default_scaling_factor > 10:

# it may be infinity in eg. Fedora

self._default_scaling_factor = 1.33

scaling = self.get_option("general.scaling")

if scaling in ["default", "auto"]: # auto was used in 2.2b3

self._scaling_factor = self._default_scaling_factor

else:

self._scaling_factor = float(scaling)

MAC_SCALING_MODIFIER = 1.7

if running_on_mac_os():

self._scaling_factor *= MAC_SCALING_MODIFIER

self.tk.call("tk", "scaling", self._scaling_factor)

font_scaling_mode = self.get_option("general.font_scaling_mode")

if (

running_on_linux()

and font_scaling_mode in ["default", "extra"]

and scaling not in ["default", "auto"]

):

# update system fonts which are given in pixel sizes

for name in tk_font.names():

f = tk_font.nametofont(name)

orig_size = f.cget("size")

# According to do documentation, absolute values of negative font sizes

# should be interpreted as pixel sizes (not affected by "tk scaling")

# and positive values are point sizes, which are supposed to scale automatically

# http://www.tcl.tk/man/tcl8.6/TkCmd/font.htm#M26

# Unfortunately it seems that this cannot be relied on

# https://groups.google.com/forum/#!msg/comp.lang.tcl/ZpL6tq77M4M/GXImiV2INRQJ

# My experiments show that manually changing negative font sizes

# doesn't have any effect -- fonts keep their default size

# (Tested in Raspbian Stretch, Ubuntu 18.04 and Fedora 29)

# On the other hand positive sizes scale well (and they don't scale automatically)

# convert pixel sizes to point_size

if orig_size < 0:

orig_size = -orig_size / self._default_scaling_factor

# scale

scaled_size = round(

orig_size * (self._scaling_factor / self._default_scaling_factor)

)

f.configure(size=scaled_size)

elif running_on_mac_os() and scaling not in ["default", "auto"]:

# see http://wiki.tcl.tk/44444

# update system fonts

for name in tk_font.names():

f = tk_font.nametofont(name)

orig_size = f.cget("size")

assert orig_size > 0

f.configure(size=int(orig_size * self._scaling_factor / MAC_SCALING_MODIFIER))

开发者ID:thonny,项目名称:thonny,代码行数:62,

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

python中font的用法_Python font.nametofont方法代码示例相关推荐

  1. python中stringvar的用法_Python tkinter.StringVar方法代码示例

    本文整理汇总了Python中tkinter.StringVar方法的典型用法代码示例.如果您正苦于以下问题:Python tkinter.StringVar方法的具体用法?Python tkinter ...

  2. python中formatter的用法_Python pyplot.FuncFormatter方法代码示例

    本文整理汇总了Python中matplotlib.pyplot.FuncFormatter方法的典型用法代码示例.如果您正苦于以下问题:Python pyplot.FuncFormatter方法的具体 ...

  3. python中bind的用法_Python socket.bind方法代码示例

    本文整理汇总了Python中socket.bind方法的典型用法代码示例.如果您正苦于以下问题:Python socket.bind方法的具体用法?Python socket.bind怎么用?Pyth ...

  4. python中geometry用法_Python geometry.Point方法代码示例

    本文整理汇总了Python中shapely.geometry.Point方法的典型用法代码示例.如果您正苦于以下问题:Python geometry.Point方法的具体用法?Python geome ...

  5. python中fact用法_Python covariance.EllipticEnvelope方法代码示例

    本文整理汇总了Python中sklearn.covariance.EllipticEnvelope方法的典型用法代码示例.如果您正苦于以下问题:Python covariance.EllipticEn ...

  6. python end用法_Python turtle.end_fill方法代码示例

    本文整理汇总了Python中turtle.end_fill方法的典型用法代码示例.如果您正苦于以下问题:Python turtle.end_fill方法的具体用法?Python turtle.end_ ...

  7. python geometry用法_Python geometry.MultiPolygon方法代码示例

    本文整理汇总了Python中shapely.geometry.MultiPolygon方法的典型用法代码示例.如果您正苦于以下问题:Python geometry.MultiPolygon方法的具体用 ...

  8. python中type(12.34)_Python typing.TYPE_CHECKING属性代码示例

    本文整理汇总了Python中typing.TYPE_CHECKING属性的典型用法代码示例.如果您正苦于以下问题:Python typing.TYPE_CHECKING属性的具体用法?Python t ...

  9. python中import math用法_Python math.hypot() 方法

    Python math.hypot() 方法 例如: 找到已知垂直和底角的直角三角形的斜边:#Import math Library import math #垂线与底面 parendicular = ...

  10. python中isalpha的用法_python函数--isalpha()方法

    原博文 2019-09-26 10:59 − isalpha()方法 描述:Python isalpha() 方法检测字符串是否只由字母组成.isalpha()方法语法:str.isalpha()参数 ...

最新文章

  1. python 使用scapy创建arping脚本
  2. 如何更好的与人沟通?[图]
  3. Hadoop集群(第6期)_WordCount运行详解
  4. 来入门一下kotlin吧
  5. open打开新窗口时的选项
  6. C# WinForm关闭窗体确认
  7. MainStoryboard.storyboard could not be opened
  8. Apache简单配置(5)搭建phpcms2007网站+phpBB-3.0论坛
  9. 黑苹果OC配置工具 OpenCore Configurator 2.25中文版
  10. 用SandCastle为注释生成chm文档
  11. 基于单片机的HC-SR04超声波模块测距仪设计(数码管显示)
  12. 单片机延时函数移植问题
  13. 【PageHelper分页】实现拦截pageNum和pageSize
  14. android 文件保存到应用和sd卡中
  15. Cocos Creator plist图集使用方法
  16. 面试题:一个人走到岔道处,有2人,一人只说真话一人只说假话,只能问其中一人一个问题,怎么解决?
  17. java xsl转换pdf_fop生成PDF支持中文(xml amp; xsl) - 飞猪 - ITeye博客
  18. 老年人大学计算机课程,老人学电脑(入门级)
  19. ERNIE-Search: Bridging Cross-Encoder with Dual-Encoder via Self On-the-fly Distillation
  20. Python爬虫,爬取百度贴吧图片和视频文件,xpath+lxml,访问被拒的原因分析

热门文章

  1. 自动化出来都干什么了?自动化本科生最好的出路!
  2. 如何轻松录制 CS 游戏玩法?4 种免费录制 CS 游戏视频的方法
  3. 数据库DML语句:数据库操作语句
  4. 从零开始做量化(4)
  5. 跨系统/文件系统操作后的U盘容量/识别问题对策
  6. java qq授权登录开发者_Java QQ授权第三方登陆
  7. Android 限制 EditText 只能输入英文加汉字
  8. 看图说话——完美夏天
  9. Linux下TomcatVM参数修改:Native memory allocation (mmap) failed to map 3221225472 bytes for committing res
  10. Error:Dll调用问题,0X000005地址内存非法访问