当前位置: 首页>>代码示例>>Python>>正文


Python font.BOLD属性代码示例

本文整理汇总了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) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:18,代码来源:About.py

示例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() 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:22,代码来源:Main.py

示例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 
开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:18,代码来源:chooser.py

示例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 
开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:18,代码来源:selectframe.py

示例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) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:17,代码来源:Main.py

示例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) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:28,代码来源:Main.py

示例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) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:7,代码来源:Main.py

示例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()) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:10,代码来源:Main.py

示例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) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:41,代码来源:Main.py

示例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) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:configDialog.py

示例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} 
开发者ID:NeuromorphicProcessorProject,项目名称:snn_toolbox,代码行数:14,代码来源:gui.py

示例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) 
开发者ID:lovexiaov,项目名称:python-in-practice,代码行数:46,代码来源:Main.py


注:本文中的tkinter.font.BOLD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。