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


Python ttk.Style方法代码示例

本文整理汇总了Python中tkinter.ttk.Style方法的典型用法代码示例。如果您正苦于以下问题:Python ttk.Style方法的具体用法?Python ttk.Style怎么用?Python ttk.Style使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.ttk的用法示例。


在下文中一共展示了ttk.Style方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def __init__(self, *args, error_var=None, **kwargs):
        self.error = error_var or tk.StringVar()
        super().__init__(*args, **kwargs)

        vcmd = self.register(self._validate)
        invcmd = self.register(self._invalid)

        style = ttk.Style()
        widget_class = self.winfo_class()
        validated_style = 'ValidatedInput.' + widget_class
        style.map(
            validated_style,
            foreground=[('invalid', 'white'), ('!invalid', 'black')],
            fieldbackground=[('invalid', 'darkred'), ('!invalid', 'white')]
        )

        self.config(
            style=validated_style,
            validate='all',
            validatecommand=(vcmd, '%P', '%s', '%S', '%V', '%i', '%d'),
            invalidcommand=(invcmd, '%P', '%s', '%S', '%V', '%i', '%d')
        ) 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-with-Tkinter,代码行数:24,代码来源:widgets.py

示例2: body

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def body(self, parent):
        lf = tk.Frame(self)
        ttk.Label(lf, text='Login to ABQ',
                  font='TkHeadingFont').grid(row=0)

        ttk.Style().configure('err.TLabel',
                background='darkred', foreground='white')
        if self.error.get():
            ttk.Label(lf, textvariable=self.error,
                      style='err.TLabel').grid(row=1)
        ttk.Label(lf, text='User name:').grid(row=2)
        self.username_inp = ttk.Entry(lf, textvariable=self.user)
        self.username_inp.grid(row=3)
        ttk.Label(lf, text='Password:').grid(row=4)
        self.password_inp = ttk.Entry(lf, show='*', textvariable=self.pw)
        self.password_inp.grid(row=5)
        lf.pack()
        return self.username_inp 
开发者ID:PacktPublishing,项目名称:Python-GUI-Programming-with-Tkinter,代码行数:20,代码来源:views.py

示例3: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def __init__(self, master=None, **kw):
        """
        Create a CheckboxTreeview.

        :param master: master widget
        :type master: widget
        :param kw: options to be passed on to the :class:`ttk.Treeview` initializer
        """
        ttk.Treeview.__init__(self, master, style='Checkbox.Treeview', **kw)
        # style (make a noticeable disabled style)
        style = ttk.Style(self)
        style.map("Checkbox.Treeview",
                  fieldbackground=[("disabled", '#E6E6E6')],
                  foreground=[("disabled", 'gray40')],
                  background=[("disabled", '#E6E6E6')])
        # checkboxes are implemented with pictures
        self.im_checked = ImageTk.PhotoImage(Image.open(IM_CHECKED), master=self)
        self.im_unchecked = ImageTk.PhotoImage(Image.open(IM_UNCHECKED), master=self)
        self.im_tristate = ImageTk.PhotoImage(Image.open(IM_TRISTATE), master=self)
        self.tag_configure("unchecked", image=self.im_unchecked)
        self.tag_configure("tristate", image=self.im_tristate)
        self.tag_configure("checked", image=self.im_checked)
        # check / uncheck boxes on click
        self.bind("<Button-1>", self._box_click, True) 
开发者ID:TkinterEP,项目名称:ttkwidgets,代码行数:26,代码来源:checkboxtreeview.py

示例4: trans

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def trans(self):
        gui_style = ttk.Style()
        gui_style.configure('Ui.TButton', foreground='#FF0000')
        self.trans_button.config(style='Ui.TButton')
        self.run_queue.put(1)
        if self.input_text.get():
            query_string = self.input_text.get()
        else:
            try:
                query_string = self.window.clipboard_get()
                self.window.clipboard_clear()
            except Exception as e:
                query_string = str(e)
        Args.query = query_string
        trans_result = trans(Args)
        self.st.delete('1.0', tk.END)
        self.st.insert(tk.END, trans_result)
        self.run_queue.get()
        gui_style.configure('Ui.TButton', foreground='#000000') 
开发者ID:xinebf,项目名称:google-translate-for-goldendict,代码行数:21,代码来源:googletranslateui.py

示例5: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def __init__(self, parent, *tabs, **kwargs):
        super().__init__(parent, **kwargs)
        
        assert all(isinstance(t, str) for t in tabs)

        self.style = ttk.Style(self)
        self.style.configure("TNotebook.Tab")
        self._notebook = ttk.Notebook(self, style="TNotebook")
        self.data = {
            name: tk.Frame(self._notebook)
            for name in tabs}
        self._tab_ids = {}
        for name in self.data:
            self._notebook.add(self.data[name], text=name)
            self._tab_ids[name] = self._notebook.tabs()[-1]
        
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self._notebook.grid(row=0, column=0, sticky="nswe") 
开发者ID:BnetButter,项目名称:hwk-mirror,代码行数:22,代码来源:tkwidgets.py

示例6: main

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def main():
    """
    Start StochOPy Viewer window.
    """
    from sys import platform as _platform
    
    root = tk.Tk()
    root.resizable(0, 0)
    StochOGUI(root)
    s = ttk.Style()
    if _platform == "win32":
        s.theme_use("vista")
    elif _platform in [ "linux", "linux2" ]:
        s.theme_use("alt")
    elif _platform == "darwin":
        s.theme_use("aqua")
    root.mainloop() 
开发者ID:keurfonluu,项目名称:stochopy,代码行数:19,代码来源:gui.py

示例7: build_widgets

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def build_widgets(self):
        style = ttk.Style()
        style.configure('Horizontal.TProgressbar', background='#5eba21')
        self.progress = ttk.Progressbar(self, mode='indeterminate', maximum=50)
        self.progress.grid(row=0, columnspan=2, sticky=tk.W+tk.E)
        self.progress.start(30)

        self.lbl_look = ttk.Label(self, text="Looking for Device...")
        self.lbl_look.grid(row=1, column=0, columnspan=2, pady=8)

        self.btn_open = ttk.Button(self, text="Select Payload", command=self.btn_open_pressed)
        self.btn_open.grid(row=2, column=0, padx=8)

        self.lbl_file = ttk.Label(self, text="No Payload Selected.    ", justify=tk.LEFT)
        self.lbl_file.grid(row=2, column=1, padx=8)

        self.btn_send = ttk.Button(self, text="Send Payload!", command=self.btn_send_pressed)
        self.btn_send.grid(row=3, column=0, columnspan=2, sticky=tk.W+tk.E, pady=8, padx=8)
        self.btn_send.state(('disabled',)) # trailing comma to define single element tuple

        self.btn_mountusb = ttk.Button(self, text="Mount SD on PC", command=self.btn_mountusb_pressed)
        self.btn_mountusb.grid(row=4, column=0, columnspan=2, sticky=tk.W+tk.E, pady=8, padx=8)
        self.btn_mountusb.state(('disabled',)) # trailing comma to define single element tuple 
开发者ID:nh-server,项目名称:fusee-interfacee-tk,代码行数:25,代码来源:app.py

示例8: launch

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def launch(self):
        self.root = tk.Tk()
        self.root.wait_visibility(self.root)
        self.title_font = Font(size=16, weight='bold')
        self.bold_font = Font(weight='bold')

        self.root.geometry("900x600")

        style = ttk.Style(self.root)
        style.configure("TLable", bg="black")

        self.add_toolbar(self.root)
        self.add_send_command_box(self.root)
        self.add_list_commands(self.root)

        self.root.protocol("WM_DELETE_WINDOW", lambda root=self.root: self.on_closing(root))
        self.root.createcommand('exit', lambda root=self.root: self.on_closing(root))

        self.root.mainloop() 
开发者ID:IBM,项目名称:clai,代码行数:21,代码来源:clai_emulator.py

示例9: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def __init__(self, master):
        super().__init__(master, text="Levels", padding=4)
        self.lowest_level = Player.levelmeter_lowest
        self.pbvar_left = tk.IntVar()
        self.pbvar_right = tk.IntVar()
        pbstyle = ttk.Style()
        # pbstyle.theme_use("classic")  # clam, alt, default, classic
        pbstyle.configure("green.Vertical.TProgressbar", troughcolor="gray", background="light green")
        pbstyle.configure("yellow.Vertical.TProgressbar", troughcolor="gray", background="yellow")
        pbstyle.configure("red.Vertical.TProgressbar", troughcolor="gray", background="orange")

        ttk.Label(self, text="dB").pack(side=tkinter.TOP)
        frame = ttk.LabelFrame(self, text="L.")
        frame.pack(side=tk.LEFT)
        self.pb_left = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level,
                                       variable=self.pbvar_left, mode='determinate',
                                       style='yellow.Vertical.TProgressbar')
        self.pb_left.pack()

        frame = ttk.LabelFrame(self, text="R.")
        frame.pack(side=tk.LEFT)
        self.pb_right = ttk.Progressbar(frame, orient=tk.VERTICAL, length=200, maximum=-self.lowest_level,
                                        variable=self.pbvar_right, mode='determinate',
                                        style='yellow.Vertical.TProgressbar')
        self.pb_right.pack() 
开发者ID:irmen,项目名称:synthesizer,代码行数:27,代码来源:box.py

示例10: _setup_style

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def _setup_style(self, event=None):
        """Style configuration to make the DateEntry look like a Combobbox."""
        self.style.layout('DateEntry', self.style.layout('TCombobox'))
        self.update_idletasks()
        conf = self.style.configure('TCombobox')
        if conf:
            self.style.configure('DateEntry', **conf)
        maps = self.style.map('TCombobox')
        if maps:
            try:
                self.style.map('DateEntry', **maps)
            except tk.TclError:
                # temporary fix for issue #61 and https://bugs.python.org/issue38661
                maps = MAPS.get(self.style.theme_use(), MAPS['default'])
                self.style.map('DateEntry', **maps)
        try:
            self.after_cancel(self._determine_downarrow_name_after_id)
        except ValueError:
            # nothing to cancel
            pass
        self._determine_downarrow_name_after_id = self.after(10, self._determine_downarrow_name) 
开发者ID:j4321,项目名称:tkcalendar,代码行数:23,代码来源:dateentry.py

示例11: add_info

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def add_info(self, frame):
        """ Plugin information """
        gui_style = ttk.Style()
        gui_style.configure('White.TFrame', background='#FFFFFF')
        gui_style.configure('Header.TLabel',
                            background='#FFFFFF',
                            font=get_config().default_font + ("bold", ))
        gui_style.configure('Body.TLabel',
                            background='#FFFFFF')

        info_frame = ttk.Frame(frame, style='White.TFrame', relief=tk.SOLID)
        info_frame.pack(fill=tk.X, side=tk.TOP, expand=True, padx=10, pady=10)
        label_frame = ttk.Frame(info_frame, style='White.TFrame')
        label_frame.pack(padx=5, pady=5, fill=tk.X, expand=True)
        for idx, line in enumerate(self.header_text.splitlines()):
            if not line:
                continue
            style = "Header.TLabel" if idx == 0 else "Body.TLabel"
            info = ttk.Label(label_frame, text=line, style=style, anchor=tk.W)
            info.bind("<Configure>", self._adjust_wraplength)
            info.pack(fill=tk.X, padx=0, pady=0, expand=True, side=tk.TOP) 
开发者ID:deepfakes,项目名称:faceswap,代码行数:23,代码来源:control_helper.py

示例12: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def __init__(self, master):
        ttk.Frame.__init__(self, master, style="CustomMenubar.TFrame")
        self._menus = []
        self._opened_menu = None

        ttk.Style().map(
            "CustomMenubarLabel.TLabel",
            background=[
                ("!active", lookup_style_option("Menubar", "background", "gray")),
                ("active", lookup_style_option("Menubar", "activebackground", "LightYellow")),
            ],
            foreground=[
                ("!active", lookup_style_option("Menubar", "foreground", "black")),
                ("active", lookup_style_option("Menubar", "activeforeground", "black")),
            ],
        ) 
开发者ID:thonny,项目名称:thonny,代码行数:18,代码来源:ui_utils.py

示例13: _reload_theme_options

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def _reload_theme_options(self, event=None):
        style = ttk.Style()

        states = []
        if self["state"] == "disabled":
            states.append("disabled")

        # Following crashes when a combobox is focused
        # if self.focus_get() == self:
        #    states.append("focus")
        opts = {}
        for key in [
            "background",
            "foreground",
            "highlightthickness",
            "highlightcolor",
            "highlightbackground",
        ]:
            value = style.lookup(self.get_style_name(), key, states)
            if value:
                opts[key] = value

        self.configure(opts) 
开发者ID:thonny,项目名称:thonny,代码行数:25,代码来源:ui_utils.py

示例14: _reload_theme_options

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def _reload_theme_options(self, event=None):

        style = ttk.Style()

        states = []
        if self.is_read_only():
            states.append("readonly")

        # Following crashes when a combobox is focused
        # if self.focus_get() == self:
        #    states.append("focus")

        if "background" not in self._initial_configuration:
            background = style.lookup(self._style, "background", states)
            if background:
                self.configure(background=background)

        if "foreground" not in self._initial_configuration:
            foreground = style.lookup(self._style, "foreground", states)
            if foreground:
                self.configure(foreground=foreground)
                self.configure(insertbackground=foreground) 
开发者ID:thonny,项目名称:thonny,代码行数:24,代码来源:tktextext.py

示例15: __init__

# 需要导入模块: from tkinter import ttk [as 别名]
# 或者: from tkinter.ttk import Style [as 别名]
def __init__(self, master):
        super().__init__(master)

        ttk.Style().configure("Centered.TButton", justify="center")
        self.back_button = ttk.Button(
            self.tree,
            style="Centered.TButton",
            text=_("Back to\ncurrent frame"),
            command=self._handle_back_button,
            width=15,
        )

        get_workbench().bind("BackendRestart", self._handle_backend_restart, True)
        get_workbench().bind("ToplevelResponse", self._handle_toplevel_response, True)
        # get_workbench().bind("DebuggerResponse", self._debugger_response, True)
        get_workbench().bind("get_frame_info_response", self._handle_frame_info_event, True)
        get_workbench().bind("get_globals_response", self._handle_get_globals_response, True)

        # records last info from progress messages
        self._last_active_info = None 
开发者ID:thonny,项目名称:thonny,代码行数:22,代码来源:variables.py


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