本文整理汇总了Python中tkinter.font.nametofont函数的典型用法代码示例。如果您正苦于以下问题:Python nametofont函数的具体用法?Python nametofont怎么用?Python nametofont使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了nametofont函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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)
示例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)
示例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()
示例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)
示例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()
示例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()
示例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)
示例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)
示例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()
示例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")
示例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'])
示例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()
示例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
示例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