本文整理汇总了Python中tkFont.Font方法的典型用法代码示例。如果您正苦于以下问题:Python tkFont.Font方法的具体用法?Python tkFont.Font怎么用?Python tkFont.Font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkFont
的用法示例。
在下文中一共展示了tkFont.Font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_fonts
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_fonts(self, root):
# See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
self._sysfont = tkFont.Font(font=Button()["font"])
root.option_add("*Font", self._sysfont)
# TWhat's our font size (default=same as sysfont)
self._size = IntVar(root)
self._size.set(self._sysfont.cget('size'))
self._boldfont = tkFont.Font(family='helvetica', weight='bold',
size=self._size.get())
self._font = tkFont.Font(family='helvetica',
size=self._size.get())
if self._size.get() < 0: big = self._size.get()-2
else: big = self._size.get()+2
self._bigfont = tkFont.Font(family='helvetica', weight='bold',
size=big)
示例2: _init_fonts
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_fonts(self, root):
# See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
self._sysfont = Font(font=Button()["font"])
root.option_add("*Font", self._sysfont)
# TWhat's our font size (default=same as sysfont)
self._size = IntVar(root)
self._size.set(self._sysfont.cget('size'))
self._boldfont = Font(family='helvetica', weight='bold',
size=self._size.get())
self._font = Font(family='helvetica',
size=self._size.get())
if self._size.get() < 0: big = self._size.get()-2
else: big = self._size.get()+2
self._bigfont = Font(family='helvetica', weight='bold',
size=big)
示例3: _init_fonts
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_fonts(self, root):
# See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
self._sysfont = tkFont.Font(font=Button()["font"])
root.option_add("*Font", self._sysfont)
# TWhat's our font size (default=same as sysfont)
self._size = IntVar(root)
self._size.set(self._sysfont.cget('size'))
self._boldfont = tkFont.Font(family='helvetica', weight='bold',
size=self._size.get())
self._font = tkFont.Font(family='helvetica',
size=self._size.get())
if self._size.get() < 0: big = self._size.get()-2
else: big = self._size.get()+2
self._bigfont = tkFont.Font(family='helvetica', weight='bold',
size=big)
示例4: _init_results_box
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_results_box(self, parent):
innerframe = Frame(parent)
i1 = Frame(innerframe)
i2 = Frame(innerframe)
vscrollbar = Scrollbar(i1, borderwidth=1)
hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
self.results_box = Text(i1,
font=tkFont.Font(family='courier', size='16'),
state='disabled', borderwidth=1,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set, wrap='none', width='40', height = '20', exportselection=1)
self.results_box.pack(side='left', fill='both', expand=True)
self.results_box.tag_config(self._HIGHLIGHT_WORD_TAG, foreground=self._HIGHLIGHT_WORD_COLOUR)
self.results_box.tag_config(self._HIGHLIGHT_LABEL_TAG, foreground=self._HIGHLIGHT_LABEL_COLOUR)
vscrollbar.pack(side='left', fill='y', anchor='e')
vscrollbar.config(command=self.results_box.yview)
hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
hscrollbar.config(command=self.results_box.xview)
#there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
Label(i2, text=' ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
i1.pack(side='top', fill='both', expand=True, anchor='n')
i2.pack(side='bottom', fill='x', anchor='s')
innerframe.pack(side='top', fill='both', expand=True)
示例5: _init_results_box
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_results_box(self, parent):
innerframe = Frame(parent)
i1 = Frame(innerframe)
i2 = Frame(innerframe)
vscrollbar = Scrollbar(i1, borderwidth=1)
hscrollbar = Scrollbar(i2, borderwidth=1, orient='horiz')
self.results_box = Text(i1,
font=tkFont.Font(family='courier', size='16'),
state='disabled', borderwidth=1,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set, wrap='none', width='40', height = '20', exportselection=1)
self.results_box.pack(side='left', fill='both', expand=True)
vscrollbar.pack(side='left', fill='y', anchor='e')
vscrollbar.config(command=self.results_box.yview)
hscrollbar.pack(side='left', fill='x', expand=True, anchor='w')
hscrollbar.config(command=self.results_box.xview)
#there is no other way of avoiding the overlap of scrollbars while using pack layout manager!!!
Label(i2, text=' ', background=self._BACKGROUND_COLOUR).pack(side='left', anchor='e')
i1.pack(side='top', fill='both', expand=True, anchor='n')
i2.pack(side='bottom', fill='x', anchor='s')
innerframe.pack(side='top', fill='both', expand=True)
示例6: _init_fonts
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_fonts(self, root):
self._boldfont = tkFont.Font(family='helvetica', weight='bold',
size=self._fontsize)
self._font = tkFont.Font(family='helvetica',
size=self._fontsize)
# See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
self._sysfont = tkFont.Font(font=Tkinter.Button()["font"])
root.option_add("*Font", self._sysfont)
示例7: _init_fonts
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def _init_fonts(self, root):
# See: <http://www.astro.washington.edu/owen/ROTKFolklore.html>
self._sysfont = tkFont.Font(font=Button()["font"])
root.option_add("*Font", self._sysfont)
# TWhat's our font size (default=same as sysfont)
self._size = IntVar(root)
self._size.set(self._sysfont.cget('size'))
self._boldfont = tkFont.Font(family='helvetica', weight='bold',
size=self._size.get())
self._font = tkFont.Font(family='helvetica',
size=self._size.get())
示例8: configure
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def configure(self, cnf=None, **kw):
# This class' state
for thing in ['url', 'popup_copy', 'underline']:
if thing in kw:
setattr(self, thing, kw.pop(thing))
for thing in ['foreground', 'disabledforeground']:
if thing in kw:
setattr(self, thing, kw[thing])
# Emulate disabledforeground option for ttk.Label
if kw.get('state') == tk.DISABLED:
if 'foreground' not in kw:
kw['foreground'] = self.disabledforeground
elif 'state' in kw:
if 'foreground' not in kw:
kw['foreground'] = self.foreground
if 'font' in kw:
self.font_n = kw['font']
self.font_u = tkFont.Font(font = self.font_n)
self.font_u.configure(underline = True)
kw['font'] = self.underline is True and self.font_u or self.font_n
if 'cursor' not in kw:
if (kw['state'] if 'state' in kw else str(self['state'])) == tk.DISABLED:
kw['cursor'] = 'arrow' # System default
elif self.url and (kw['text'] if 'text' in kw else self['text']):
kw['cursor'] = platform=='darwin' and 'pointinghand' or 'hand2'
else:
kw['cursor'] = (platform=='darwin' and 'notallowed') or (platform=='win32' and 'no') or 'circle'
super(HyperlinkLabel, self).configure(cnf, **kw)
示例9: __init__
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def __init__(self, text, regexp=False, nocase=False):
self.text = text
self.pattern = tkinter.StringVar()
self.regexp = tkinter.IntVar(int(regexp))
self.nocase = tkinter.IntVar(int(nocase))
self.prev_pattern = ""
self.prev_regexp = regexp
self.prev_nocase = nocase
self.findings = []
self.current = -1
self.text.tag_config("search", background='yellow', foreground="black")
bold_font = Font(self.text)
bold_font.configure(weight="bold")
self.text.tag_config("search_current", font=bold_font)
示例10: test_font_eq
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def test_font_eq(self):
fontname = "TkDefaultFont"
try:
f = font.Font(root=self.root, name=fontname, exists=True)
except tkinter._tkinter.TclError:
f = font.Font(root=self.root, name=fontname, exists=False)
font1 = font.Font(root=self.root, name=fontname, exists=True)
font2 = font.Font(root=self.root, name=fontname, exists=True)
self.assertIsNot(font1, font2)
self.assertEqual(font1, font2)
self.assertNotEqual(font1, font1.copy())
self.assertNotEqual(font1, 0)
self.assertNotIn(font1, [0])
示例11: __init__
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def __init__(self, *args, **kw):
global ttyFont, fontHeight, fontWidth
ttyFont = tkFont.Font(family = 'Courier', size = 10)
fontWidth = max(map(ttyFont.measure, string.ascii_letters+string.digits))
fontHeight = int(ttyFont.metrics()['linespace'])
self.width = kw.get('width', 80)
self.height = kw.get('height', 25)
self.callback = kw['callback']
del kw['callback']
kw['width'] = w = fontWidth * self.width
kw['height'] = h = fontHeight * self.height
Tkinter.Frame.__init__(self, *args, **kw)
self.canvas = Tkinter.Canvas(bg='#000000', width=w, height=h)
self.canvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
self.canvas.bind('<Key>', self.keyPressed)
self.canvas.bind('<1>', lambda x: 'break')
self.canvas.bind('<Up>', self.upPressed)
self.canvas.bind('<Down>', self.downPressed)
self.canvas.bind('<Left>', self.leftPressed)
self.canvas.bind('<Right>', self.rightPressed)
self.canvas.focus()
self.ansiParser = ansi.AnsiParser(ansi.ColorText.WHITE, ansi.ColorText.BLACK)
self.ansiParser.writeString = self.writeString
self.ansiParser.parseCursor = self.parseCursor
self.ansiParser.parseErase = self.parseErase
#for (a, b) in colorMap.items():
# self.canvas.tag_config(a, foreground=b)
# self.canvas.tag_config('b'+a, background=b)
#self.canvas.tag_config('underline', underline=1)
self.x = 0
self.y = 0
self.cursor = self.canvas.create_rectangle(0,0,fontWidth-1,fontHeight-1,fill='green',outline='green')
示例12: draw_slider
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def draw_slider(self):
# scale to choose iteration to view
self.w = Tk.Scale(
self.options_frame,
from_=0, to=self.num_iters - 1,
orient=Tk.HORIZONTAL,
resolution=1,
font=tkFont.Font(family="Helvetica", size=10),
command=self.update_graphs,
length=200)
if self.curr_pos == self.num_iters - 1 or self.curr_pos == 0 or self.var_ref.get():
self.curr_pos = self.num_iters - 1
self.w.set(self.curr_pos)
self.w.grid(row=0, column=1, padx=5, sticky=Tk.W)
示例13: get_text_metrics
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def get_text_metrics(self, family, size, text):
font = None
key = (family, size)
if key in self.fonts:
font = self.fonts[key]
else:
font = tkFont.Font(family=family, size=size)
self.fonts[key] = font
assert font is not None
w, h = (font.measure(text), font.metrics("linespace"))
return w, h
示例14: textbox_write
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def textbox_write(self, tag, message, color, extras):
widget = self.textbox_choose(message)
self.w_maxpix, self.h_maxpix = widget.winfo_width(), widget.winfo_height()
self.xfont = tkFont.Font(font = widget['font'])
widget.configure(state = 'normal')
widget.insert('end', self.textbox_format(message), tag)
self.textbox_color(tag, widget, color, self.customcolors['black'], extras)
widget.after(100, widget.see('end'))
widget.configure(state = 'disabled')
示例15: __init__
# 需要导入模块: import tkFont [as 别名]
# 或者: from tkFont import Font [as 别名]
def __init__(self, srv_text_space, clt_text_space, customcolors, side):
self.srv_text_space = srv_text_space
self.clt_text_space = clt_text_space
self.customcolors = customcolors
self.side = side
self.tag_err = 'STDERR'
self.xfont = tkFont.Font(font = self.srv_text_space['font'])