本文整理汇总了Python中tkinter.font.nametofont函数的典型用法代码示例。如果您正苦于以下问题:Python nametofont函数的具体用法?Python nametofont怎么用?Python nametofont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nametofont函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: initVars
def initVars(self):
self.vcmdIsNum = GuiUtil.create_vcmd(self.master, {})
self.vcmdTNI_10 = GuiUtil.create_vcmd(self.master, {"maxval" : 10})
self.invcmd_10 = GuiUtil.create_invcmd(self.master, {"maxval" : 10})
self.customFont = font.nametofont("TkTextFont").copy()
self.customFontMedium = font.nametofont("TkTextFont").copy()
self.customFontMedium["size"] = 12
self.customFontLarge = font.nametofont("TkTextFont").copy()
self.customFontLarge["size"] = 15
self.EntryOptions = {"font": self.customFontLarge}#, "validate": "key", "validatecommand": self.vcmdTNI_44, "invalidcommand": self.invcmd_44}
self.EntryOptionsNum = {"font": self.customFontLarge, "justify": tk.RIGHT, "validate": "key", "validatecommand": self.vcmdIsNum}
self.EntryOptions210 = {"font": self.customFontLarge, "justify": tk.RIGHT, "width": 2, "validate": "key", "validatecommand": self.vcmdTNI_10, "invalidcommand": self.invcmd_10}
self.PathSaves = Util.getScriptPath() + "/Configs"
self.FileOptionsJSON = {"initialdir": self.PathSaves, "filetypes": [("json", ".json"), ("all", "*")], "defaultextension": ".json"}
self.BoolOptions = {"offvalue": "False", "onvalue": "True", "takefocus": False}
self.widgetVars = {"name" : tk.StringVar(), "logo" : tk.StringVar(value = "Resources/UNF_Logo.svg"), "style" : tk.StringVar(value = "arabic"), "indexing" : tk.IntVar(value = 0), "booklet" : tk.BooleanVar(value = True)}
self.LOADED = False
self.TreeReady = True
self.filename = ""
self.tooltip = None
开发者ID:CapnOdin,项目名称:PySong,代码行数:28,代码来源:GUI.py
示例2: fixfonts
def fixfonts(self):
#screen_width = self.winfo_screenwidth()
#screen_height = self.winfo_screenheight()
self.default_font = nametofont('TkDefaultFont')
self.default_font.configure(size=10)
self.menu_font = nametofont('TkMenuFont')
self.menu_font.configure(size=10)
开发者ID:colemanc,项目名称:mymahjong,代码行数:8,代码来源:my_mahjong.py
示例3: test_font_eq
def test_font_eq(self):
fontname = "TkDefaultFont"
try:
f = font.Font(name=fontname, exists=True)
except tkinter._tkinter.TclError:
f = font.Font(name=fontname, exists=False)
font1 = font.nametofont(fontname)
font2 = font.nametofont(fontname)
self.assertIsNot(font1, font2)
self.assertEqual(font1, font2)
self.assertNotEqual(font1, font1.copy())
self.assertNotEqual(font1, 0)
开发者ID:ChowZenki,项目名称:kbengine,代码行数:12,代码来源:test_font.py
示例4: __init__
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, dont 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()
开发者ID:MaloneQQ,项目名称:easygui,代码行数:50,代码来源:text_box.py
示例5: fixFonts
def fixFonts(self):
screen_width = self.winfo_screenwidth()
screen_height = self.winfo_screenheight()
# print(screen_height)
# print(screen_width)
self.default_font = nametofont('TkDefaultFont')
# print(self.default_font.actual())
self.default_font.configure(size=16)
# print(self.default_font.actual())
self.menu_font = nametofont('TkMenuFont')
# print(self.menu_font.actual())
self.menu_font.configure(size=36)
开发者ID:colemanc,项目名称:mymahjong,代码行数:14,代码来源:application_view.py
示例6: __init__
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()
开发者ID:robertlugg,项目名称:easygui,代码行数:35,代码来源:choice_box.py
示例7: CreateWidgets
def CreateWidgets(self):
frameText = Frame(self, relief=SUNKEN, height=700)
frameCommands = Frame(self, relief=SUNKEN)
frameButtons = Frame(self)
self.buttonOk = Button(frameButtons, text='Close', command=lambda b=1: self.Ok(b), takefocus=FALSE)
self.buttonTwo = Button(frameButtons, text='Close2', command=lambda b=2: self.Ok(b), takefocus=FALSE)
self.scrollbarView = Scrollbar(frameText, orient=VERTICAL, takefocus=FALSE, highlightthickness=0)
self.textView = Text(frameText, wrap=WORD, highlightthickness=0, fg=self.fg, bg=self.bg, font=self.font, padx=8, pady=8)
self.scrollbarView.config(command=self.textView.yview)
self.textView.config(yscrollcommand=self.scrollbarView.set)
self.commandPrompt = Label(frameCommands, text="> ")
fixedFont = self.FindFont(["Consolas", "Lucida Console", "DejaVu Sans Mono"], self.fontsize_monospace)
if not fixedFont:
fixedFont = tkfont.nametofont('TkFixedFont').copy()
fixedFont["size"]=self.fontsize_monospace
self.commandEntry = Entry(frameCommands, takefocus=TRUE, font=fixedFont)
self.commandEntry.bind('<Return>',self.user_cmd)
self.commandEntry.bind('<Extended-Return>',self.user_cmd)
self.commandEntry.bind('<KP_Enter>',self.user_cmd)
self.commandEntry.bind('<F1>', self.f1_pressed)
self.buttonOk.pack()
self.buttonTwo.pack()
self.scrollbarView.pack(side=RIGHT,fill=Y)
self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
self.commandPrompt.pack(side=LEFT)
self.commandEntry.pack(side=LEFT, expand=TRUE, fill=X, ipady=1)
frameButtons.pack(side=BOTTOM,fill=X)
frameText.pack(side=TOP,expand=TRUE,fill=BOTH)
frameCommands.pack(side=BOTTOM, fill=X)
self.commandEntry.focus_set()
开发者ID:jordanaycamara,项目名称:Tale,代码行数:32,代码来源:tkinter_textarea.py
示例8: fontsize
def fontsize(self, sz_diff):
"""
Change font sizes by sz_diff.
"""
for fname in font.names():
f = font.nametofont(fname)
sz = f.configure()["size"]
if sz < 0:
# use negative numbers if tk does.
sz -= sz_diff
else:
sz += sz_diff
if abs(sz) <= 4 or abs(sz) >= 64:
# don't be stupid
continue
f.configure(size=sz)
# The treeview does not change row height automatically.
style = ttk.Style()
rowheight = style.configure("Treeview").get("rowheight")
if rowheight is None:
# The style doesn't have this set to start with.
# Shit like this makes ttk styling useless for portability.
rowheight = 20
rowheight += sz_diff
if rowheight <= 10 or rowheight >= 140:
# getting ridiculous
return
style.configure("Treeview", rowheight=rowheight+sz_diff)
开发者ID:grahamgower,项目名称:psfm,代码行数:35,代码来源:psfm.py
示例9: __init__
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 <esc> 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:CamilleMo,项目名称:easygui,代码行数:57,代码来源:button_box.py
示例10: CreateWidgets
def CreateWidgets(self):
frameText = Frame(self, relief=SUNKEN, height=700)
frameCommands = Frame(self, relief=SUNKEN)
self.scrollbarView = Scrollbar(frameText, orient=VERTICAL, takefocus=FALSE, highlightthickness=0)
self.textView = Text(frameText, wrap=WORD, highlightthickness=0, fg=self.fg, bg=self.bg, font=self.font, padx=8, pady=8)
self.scrollbarView.config(command=self.textView.yview)
self.textView.config(yscrollcommand=self.scrollbarView.set)
self.commandPrompt = Label(frameCommands, text="> ")
fixedFont = self.FindFont(["Consolas", "Lucida Console", "DejaVu Sans Mono"], self.fontsize_monospace)
if not fixedFont:
fixedFont = tkfont.nametofont('TkFixedFont').copy()
fixedFont["size"] = self.fontsize_monospace
self.commandEntry = Entry(frameCommands, takefocus=TRUE, font=fixedFont)
self.commandEntry.bind('<Return>', self.user_cmd)
self.commandEntry.bind('<Extended-Return>', self.user_cmd)
self.commandEntry.bind('<KP_Enter>', self.user_cmd)
self.commandEntry.bind('<F1>', self.f1_pressed)
self.commandEntry.bind('<Up>', self.up_pressed)
self.commandEntry.bind('<Down>', self.down_pressed)
self.scrollbarView.pack(side=RIGHT, fill=Y)
self.textView.pack(side=LEFT, expand=TRUE, fill=BOTH)
# configure the text tags
self.textView.tag_configure('userinput', font=fixedFont, foreground='maroon', spacing1=10, spacing3=4, lmargin1=20, lmargin2=20, rmargin=20)
self.textView.tag_configure('dim', foreground='brown')
self.textView.tag_configure('bright', foreground='black', font=self.boldFond)
self.textView.tag_configure('ul', foreground='black', font=self.underlinedFond)
self.textView.tag_configure('rev', foreground=self.bg, background=self.fg)
self.textView.tag_configure('living', foreground='black', font=self.boldFond)
self.textView.tag_configure('player', foreground='black', font=self.boldFond)
self.textView.tag_configure('item', foreground='black', font=self.boldFond)
self.textView.tag_configure('exit', foreground='black', font=self.boldFond)
self.textView.tag_configure('location', foreground='navy', font=self.boldFond)
self.textView.tag_configure('monospaced', font=fixedFont)
self.textView.tag_configure('black', foreground='black')
self.textView.tag_configure('red', foreground='red')
self.textView.tag_configure('green', foreground='green')
self.textView.tag_configure('yellow', foreground='yellow')
self.textView.tag_configure('blue', foreground='blue')
self.textView.tag_configure('magenta', foreground='magenta')
self.textView.tag_configure('cyan', foreground='cyan')
self.textView.tag_configure('white', foreground='white')
self.textView.tag_configure('bg:black', background='black')
self.textView.tag_configure('bg:red', background='red')
self.textView.tag_configure('bg:green', background='green')
self.textView.tag_configure('bg:yellow', background='yellow')
self.textView.tag_configure('bg:blue', background='blue')
self.textView.tag_configure('bg:magenta', background='magenta')
self.textView.tag_configure('bg:cyan', background='cyan')
self.textView.tag_configure('bg:white', background='white')
# pack
self.commandPrompt.pack(side=LEFT)
self.commandEntry.pack(side=LEFT, expand=TRUE, fill=X, ipady=1)
frameText.pack(side=TOP, expand=TRUE, fill=BOTH)
frameCommands.pack(side=BOTTOM, fill=X)
self.commandEntry.focus_set()
开发者ID:jordanaycamara,项目名称:Tale,代码行数:57,代码来源:tkinter_io.py
示例11: loadTags
def loadTags(self, txtwig):
self.txtwig = txtwig
font_name = txtwig['font']
b = tkFont.nametofont(font_name).copy()
b.config(weight="bold")
txtwig.tag_config("tags", foreground="purple", font=b)
txtwig.tag_config("attribs", font=b)
txtwig.tag_config("values", foreground="blue")
开发者ID:bekar,项目名称:tk_xmlview,代码行数:9,代码来源:main.py
示例12: __init__
def __init__(self, parent, columns, **kwargs):
Treeview.__init__(self, parent,
columns=tuple(c['cid'] for c in columns[1:]), **kwargs)
heading_font = font.nametofont('TkHeadingFont')
for c in columns:
width = max(heading_font.measure(c['text']) + 15, c['minwidth'])
self.column(c['cid'], width=width, minwidth=c['minwidth'],
anchor=c['anchor'])
self.heading(c['cid'], text=c['text'])
开发者ID:pkesist,项目名称:buildpal,代码行数:9,代码来源:gui.py
示例13: __init__
def __init__(self, master=None):
root = Tk()
root.tk.call('tk', 'scaling', 20.0)
Frame.__init__(self, master)
self.pack
self.grid()
myfont = nametofont('TkDefaultFont')
myfont.configure(size=36)
print(dir(myfont))
self.create_board()
开发者ID:colemanc,项目名称:pythonsnippets,代码行数:10,代码来源:fontstuff.py
示例14: resize
def resize(self, d=1):
self.container.grid_propagate(False)
font_names = [ self.tag_cget(t, "font") for t in self.tag_names() ]
font_names.append(self['font'])
for name in set(font_names):
try:
font = tkFont.nametofont(name)
s = abs(font["size"]); #print(s)
font.config(size=max(s+2*d, 8))
except:
continue
开发者ID:bekar,项目名称:tk_zoomText,代码行数:11,代码来源:main.py
示例15: initialize
def initialize(self):
"""Create the GUI."""
# Set the font
default_font = nametofont("TkDefaultFont")
default_font['size'] = 12
self.option_add("*Font", default_font)
# General commands and bindings
self.bind_all('q', self.do_exit)
# Create widgets.
# First row
prbut = ttk.Button(self, text="File:", command=self.do_fileopen)
prbut.grid(row=0, column=0, sticky='w')
fnlabel = ttk.Label(self, anchor='w', textvariable=self.lamfile)
fnlabel.grid(row=0, column=1, columnspan=4, sticky='ew')
# Second row
rldbut = ttk.Button(self, text="Reload", command=self.do_reload)
rldbut.grid(row=1, column=0, sticky='w')
# Third row
cb = partial(self.on_laminate, event=0)
chkengprop = ttk.Checkbutton(
self, text='Engineering properties', variable=self.engprop,
command=cb
)
chkengprop.grid(row=2, column=0, columnspan=3, sticky='w')
# Fourth row
chkmat = ttk.Checkbutton(
self, text='ABD & abd matrices', variable=self.matrices,
command=cb
)
chkmat.grid(row=3, column=0, columnspan=3, sticky='w')
# Fifth row
cxlam = ttk.Combobox(self, state='readonly', justify='left')
cxlam.grid(row=4, column=0, columnspan=5, sticky='we')
cxlam.bind("<<ComboboxSelected>>", self.on_laminate)
self.cxlam = cxlam
# Sixth row
fixed = nametofont('TkFixedFont')
fixed['size'] = 12
res = ScrolledText(self, state='disabled', font=fixed)
res.grid(row=5, column=0, columnspan=5, sticky='ew')
self.result = res
开发者ID:rsmith-nl,项目名称:lamprop,代码行数:41,代码来源:gui.py
示例16: draw
def draw(self, scale):
height = scale*self.bar.get_height()
width = scale*self.bar.get_width()
xpos = scale*self.bar.get_xpos()
ypos = scale*self.bar.get_ypos()
canvas_height = scale*CANVAS_HEIGHT
self.main_rect = self.canvas.create_rectangle(xpos - width/2, ypos - height/2, xpos + width/2, ypos + height/2, fill=self.bar.color)
if self.bar.get_id() != None and self.bar.get_id() != -1:
self.id_text = self.canvas.create_text(xpos, ypos)
idfont = font.nametofont("TkDefaultFont")
idfont.configure(size=int(20*scale))
self.canvas.itemconfig(self.id_text, text=self.bar.get_id(), font=idfont, fill="white")
self.drawn = True
开发者ID:magetron,项目名称:ENGF0002,代码行数:13,代码来源:pong_view.py
示例17: alter_fonts
def alter_fonts(self, normal=None, bold=None, initial=False):
label_w = next(self.iter_all_label_widgets())
if normal is None:
first_font = nametofont(label_w.cget('font'))
cnormal = dict(first_font.configure())
cnormal['weight'] = 'normal'
else:
cnormal = dict(normal.configure())
if bold is None:
first_font = nametofont(label_w.cget('font'))
cbold = dict(first_font.configure())
cbold['weight'] = 'bold'
else:
cbold = dict(bold.configure())
if initial:
self.fonts['normal'] = Font(**cnormal)
self.fonts['bold'] = Font(**cbold)
[w.configure(font=self.fonts['normal'])
for w in self.iter_all_label_widgets()]
else:
self.fonts['normal'].configure(**cnormal)
self.fonts['bold'].configure(**cbold)
开发者ID:tajfutas,项目名称:tajf,代码行数:22,代码来源:infopanel.py
示例18: create_tags
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:ShuyaMotouchi,项目名称:joke,代码行数:16,代码来源:About.py
示例19: __init__
def __init__(self, parent, width=10, height=4, font="TkDefaultFont"):
self.font = nametofont(font)
self.bold_font = self.font.copy()
self.italic_font = self.font.copy()
self.bold_font['weight'] = 'bold'
self.italic_font['slant'] = 'italic'
super().__init__(
parent,
width=width,
height=height,
wrap="word",
font=self.font,
)
self.tag_config(
"underline",
underline=1,
)
self.tag_config(
"bold",
font=self.bold_font,
)
self.tag_config(
"italic",
font=self.italic_font,
)
self.tag_config(
"invert",
background='black',
foreground='white',
)
self.tag_config(
"indent",
# Indent the first line slightly, but indent the following
# lines more to line up with the text.
lmargin1="10",
lmargin2="25",
)
self.tag_config(
"hrule",
relief="sunken",
borderwidth=1,
# This makes the line-height very short.
font=tkFont(size=1),
)
self['state'] = "disabled"
开发者ID:Coolasp1e,项目名称:BEE2.4,代码行数:47,代码来源:richTextBox.py
示例20: resize
def resize(self, d=1):
'''Text() font resize for key binding Ctrl + {Scroll,+,-,0}'''
self.config(state="normal")
self.container.grid_propagate(False)
font_names = [ self.tag_cget(t, "font") for t in self.tag_names() ]
font_names.append(self['font'])
for name in set(font_names):
try:
font = tkFont.nametofont(name)
s = abs(font["size"]); #print(s)
font.config(size=max(s+2*d, 8))
except:
continue
self.config(state="disable")
开发者ID:bekar,项目名称:tk_lineno,代码行数:18,代码来源:main.py
注:本文中的tkinter.font.nametofont函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论