本文整理汇总了Python中tkinter.font.BOLD属性的典型用法代码示例。如果您正苦于以下问题:Python font.BOLD属性的具体用法?Python font.BOLD怎么用?Python font.BOLD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类tkinter.font
的用法示例。
在下文中一共展示了font.BOLD属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_tags
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [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)
示例2: update_variables
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def update_variables(self):
settings = TkUtil.Settings.Data
family, pointSize, bold, italic = ("Helvetica", 11, False, False)
self.restoreFont = settings.get_bool(FONT, RESTORE, True)
if self.restoreFont:
family = settings.get_str(FONT, FAMILY, family)
pointSize = settings.get_int(FONT, FONT_SIZE, pointSize)
bold = settings.get_bool(FONT, BOLD, bold)
italic = settings.get_bool(FONT, ITALIC, italic)
self.fontFamily.set(family)
self.fontPointSize.set(pointSize)
self.fontPointSize.trace("w", self.update_font)
self.bold.set(bold)
self.italic.set(italic)
self.recentFiles = []
for i in range(MAX_RECENT_FILES):
filename = settings.get_str(RECENT_FILES, "file{}".format(i))
if filename is not None and os.path.exists(filename):
self.update_recent_files(filename, False)
self.recentFiles.reverse()
示例3: font
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def font(self):
"""
Selected font.
:return: font tuple (family_name, size, \*options), :class:`~font.Font` object
"""
if self._family is None:
return None, None
else:
font_tuple = self.__generate_font_tuple()
font_obj = tkfont.Font(family=self._family, size=self._size,
weight=tkfont.BOLD if self._bold else tkfont.NORMAL,
slant=tkfont.ITALIC if self._italic else tkfont.ROMAN,
underline=1 if self._underline else 0,
overstrike=1 if self._overstrike else 0)
return font_tuple, font_obj
示例4: font
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def font(self):
"""
Font property.
:return: a :class:`~font.Font` object if family is set, else None
:rtype: :class:`~font.Font` or None
"""
if not self._family:
return None, None
font_obj = font.Font(family=self._family, size=self._size,
weight=font.BOLD if self._bold else font.NORMAL,
slant=font.ITALIC if self._italic else font.ROMAN,
underline=1 if self._underline else 0,
overstrike=1 if self._overstrike else 0)
font_tuple = self.__generate_font_tuple()
return font_tuple, font_obj
示例5: create_images
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def create_images(self):
imagePath = os.path.join(os.path.dirname(
os.path.realpath(__file__)), "images")
for name in (NEW, OPEN, SAVE, SAVEAS, PREFERENCES,
QUIT, UNDO, REDO, COPY, CUT, PASTE, FIND,
BOLD, ITALIC, ALIGNLEFT, ALIGNCENTER, ALIGNRIGHT,
HELP, ABOUT):
filename = os.path.join(imagePath, name + "_16x16.gif")
if os.path.exists(filename):
self.menuImages[name] = tk.PhotoImage(file=filename)
filename = os.path.join(imagePath, name + "_24x24.gif")
if os.path.exists(filename):
self.toolbarImages[name] = tk.PhotoImage(file=filename)
filename = os.path.join(imagePath, "ToolbarMenu_3x24.gif")
self.toolbarImages[TOOLBARMENU] = tk.PhotoImage(file=filename)
示例6: create_view_menu
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def create_view_menu(self):
modifier = TkUtil.menu_modifier()
viewMenu = tk.Menu(self.menubar)
viewMenu.add_checkbutton(label=BOLD, underline=0,
image=self.menuImages[BOLD], compound=tk.LEFT,
variable=self.bold,
command=lambda: self.toggle_button(self.boldButton))
viewMenu.add_checkbutton(label=ITALIC, underline=0,
image=self.menuImages[ITALIC], compound=tk.LEFT,
variable=self.italic,
command=lambda: self.toggle_button(self.italicButton))
viewMenu.add_separator()
viewMenu.add_radiobutton(label=ALIGN_LEFT, underline=6,
image=self.menuImages[ALIGNLEFT], compound=tk.LEFT,
variable=self.alignment, value=tk.LEFT,
command=self.toggle_alignment)
viewMenu.add_radiobutton(label=ALIGN_CENTER, underline=6,
image=self.menuImages[ALIGNCENTER],
compound=tk.LEFT, variable=self.alignment, value=tk.CENTER,
command=self.toggle_alignment)
viewMenu.add_radiobutton(label=ALIGN_RIGHT, underline=6,
image=self.menuImages[ALIGNRIGHT],
compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT,
command=self.toggle_alignment)
self.menubar.add_cascade(label="View", underline=0,
menu=viewMenu)
示例7: create_font
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def create_font(self):
weight = tkfont.BOLD if int(self.bold.get()) else tkfont.NORMAL
slant = tkfont.ITALIC if int(self.italic.get()) else tkfont.ROMAN
return tkfont.Font(family=self.fontFamily.get(),
size=self.fontPointSize.get(), weight=weight, slant=slant)
示例8: save_font
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def save_font(self):
settings = TkUtil.Settings.Data
settings.put(FONT, RESTORE, self.restoreFont)
if self.restoreFont:
settings.put(FONT, BOLD, self.bold.get())
settings.put(FONT, ITALIC, self.italic.get())
settings.put(FONT, FAMILY, self.fontFamily.get())
settings.put(FONT, FONT_SIZE, self.fontPointSize.get())
示例9: context_menu
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def context_menu(self, event):
modifier = TkUtil.menu_modifier()
menu = tk.Menu(self.master)
if self.editor.text.tag_ranges(tk.SEL):
menu.add_command(label=COPY, underline=0,
command=lambda: self.editor.text.event_generate(
"<<Copy>>"), image=self.menuImages[COPY],
compound=tk.LEFT, accelerator=modifier + "+C")
menu.add_command(label=CUT, underline=2,
command=lambda: self.editor.text.event_generate(
"<<Cut>>"), image=self.menuImages[CUT],
compound=tk.LEFT, accelerator=modifier + "+X")
menu.add_command(label=PASTE, underline=0,
command=lambda: self.editor.text.event_generate(
"<<Paste>>"), image=self.menuImages[PASTE],
compound=tk.LEFT, accelerator=modifier + "+V")
menu.add_separator()
menu.add_checkbutton(label=BOLD, underline=0,
image=self.menuImages[BOLD], compound=tk.LEFT,
variable=self.bold,
command=lambda: self.toggle_button(self.boldButton))
menu.add_checkbutton(label=ITALIC, underline=0,
image=self.menuImages[ITALIC], compound=tk.LEFT,
variable=self.italic,
command=lambda: self.toggle_button(self.italicButton))
menu.add_separator()
menu.add_radiobutton(label=ALIGN_LEFT, underline=6,
image=self.menuImages[ALIGNLEFT], compound=tk.LEFT,
variable=self.alignment, value=tk.LEFT,
command=self.toggle_alignment)
menu.add_radiobutton(label=ALIGN_CENTER, underline=6,
image=self.menuImages[ALIGNCENTER],
compound=tk.LEFT, variable=self.alignment, value=tk.CENTER,
command=self.toggle_alignment)
menu.add_radiobutton(label=ALIGN_RIGHT, underline=6,
image=self.menuImages[ALIGNRIGHT],
compound=tk.LEFT, variable=self.alignment, value=tk.RIGHT,
command=self.toggle_alignment)
menu.tk_popup(event.x_root, event.y_root)
示例10: SetFontSample
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def SetFontSample(self, event=None):
fontName = self.fontName.get()
fontWeight = tkFont.BOLD if self.fontBold.get() else tkFont.NORMAL
newFont = (fontName, self.fontSize.get(), fontWeight)
self.labelFontSample.config(font=newFont)
self.textHighlightSample.configure(font=newFont)
示例11: define_style
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [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}
示例12: create_view_toolbar
# 需要导入模块: from tkinter import font [as 别名]
# 或者: from tkinter.font import BOLD [as 别名]
def create_view_toolbar(self):
settings = TkUtil.Settings.Data
self.viewToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
self.viewToolbar.text = FORMAT_TOOLBAR
self.viewToolbar.underline = 1
menuButton = ttk.Button(self.viewToolbar,
text="Format Toolbar Menu",
image=self.toolbarImages[TOOLBARMENU],
command=self.toolbar_menu)
TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
TkUtil.Tooltip.Tooltip(menuButton, text="Format Toolbar Menu")
self.fontFamilyCombobox = ttk.Combobox(self.viewToolbar,
width=15, textvariable=self.fontFamily,
state="readonly", values=TkUtil.font_families())
self.fontFamilyCombobox.bind("<<ComboboxSelected>>",
self.update_font)
TkUtil.set_combobox_item(self.fontFamilyCombobox,
self.fontFamily.get())
TkUtil.Tooltip.Tooltip(self.fontFamilyCombobox, text="Font Family")
self.fontSizeSpinbox = Spinbox(self.viewToolbar, width=2,
textvariable=self.fontPointSize, from_=6, to=72,
justify=tk.RIGHT, validate="all")
self.fontSizeSpinbox.config(validatecommand=(
self.fontSizeSpinbox.register(self.validate_int),
"fontSizeSpinbox", "%P"))
TkUtil.Tooltip.Tooltip(self.fontSizeSpinbox,
text="Font Point Size")
self.boldButton = ttk.Button(self.viewToolbar,
text=BOLD, image=self.toolbarImages[BOLD])
self.boldButton.config(
command=lambda: self.toggle_button(self.boldButton,
self.bold))
TkUtil.Tooltip.Tooltip(self.boldButton, text=BOLD)
self.italicButton = ttk.Button(self.viewToolbar,
text=ITALIC,
image=self.toolbarImages[ITALIC])
self.italicButton.config(
command=lambda: self.toggle_button(self.italicButton,
self.italic))
TkUtil.Tooltip.Tooltip(self.italicButton, text=ITALIC)
TkUtil.add_toolbar_buttons(self.viewToolbar, (menuButton,
self.fontFamilyCombobox, self.fontSizeSpinbox,
self.boldButton, self.italicButton))
self.toolbars.append(self.viewToolbar)