Python tkinter.font.BOLD Examples
The following are 22
code examples of tkinter.font.BOLD().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tkinter.font
, or try the search function
.
Example #1
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 8 votes |
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)
Example #2
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
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()
Example #3
Source File: selectframe.py From ttkwidgets with GNU General Public License v3.0 | 6 votes |
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
Example #4
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
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)
Example #6
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
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)
Example #7
Source File: chooser.py From ttkwidgets with GNU General Public License v3.0 | 6 votes |
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
Example #8
Source File: About.py From python-in-practice with GNU General Public License v3.0 | 6 votes |
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)
Example #9
Source File: configDialog.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
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)
Example #10
Source File: gui.py From snn_toolbox with MIT License | 5 votes |
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}
Example #11
Source File: configDialog.py From ironpython3 with Apache License 2.0 | 5 votes |
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)
Example #12
Source File: configDialog.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
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)
Example #13
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #14
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #15
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #16
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #17
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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())
Example #18
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #19
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #20
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 5 votes |
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)
Example #21
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 4 votes |
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)
Example #22
Source File: Main.py From python-in-practice with GNU General Public License v3.0 | 4 votes |
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)