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


Python ttk.Style方法代码示例

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


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

示例1: __init__

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

        ttk.Notebook.__init__(self, master, **kw)
        style = ttk.Style()

        if platform=='darwin':
            if map(int, mac_ver()[0].split('.')) >= [10,10]:
                # Hack for tab appearance with 8.5 on Yosemite & El Capitan. For proper fix see
                # https://github.com/tcltk/tk/commit/55c4dfca9353bbd69bbcec5d63bf1c8dfb461e25
                style.configure('TNotebook.Tab', padding=(12,10,12,2))
                style.map('TNotebook.Tab', foreground=[('selected', '!background', 'systemWhite')])
            self.grid(sticky=tk.NSEW)	# Already padded apropriately
        elif platform == 'win32':
            style.configure('nb.TFrame',                          background=PAGEBG)
            style.configure('nb.TButton',                         background=PAGEBG)
            style.configure('nb.TCheckbutton', foreground=PAGEFG, background=PAGEBG)
            style.configure('nb.TMenubutton',  foreground=PAGEFG, background=PAGEBG)
            style.configure('nb.TRadiobutton', foreground=PAGEFG, background=PAGEBG)
            self.grid(padx=10, pady=10, sticky=tk.NSEW)
        else:
            self.grid(padx=10, pady=10, sticky=tk.NSEW) 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:23,代码来源:myNotebook.py

示例2: main

# 需要导入模块: import ttk [as 别名]
# 或者: from 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

示例3: _setup_style

# 需要导入模块: import ttk [as 别名]
# 或者: from 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

示例4: __init__

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def __init__(self, parent_window):
        Frame.__init__(self, parent_window)
        # Configure the window
        self.configure(background=window_background_color)
        # Create the header
        Header(self).grid(row=0, columnspan=4)

        s = ttk.Style()
        s.configure(".", font=("Arial", 15))

        tab_control = ttk.Notebook(self)
        attack_tab = TabFrame(tab_control, ExportOptions.ATTACK)
        tab_control.add(attack_tab, text="Attack")

        attacksuite_tab = TabFrame(tab_control, ExportOptions.ATTACK_SUITE)
        tab_control.add(attacksuite_tab, text="Attack Suite")

        protocol_tab = TabFrame(tab_control, ExportOptions.PROTOCOL)
        tab_control.add(protocol_tab, text="Protocol")

        tab_control.grid(row=1, column=0, columnspan=4, rowspan=3, sticky=W + E + S + N)
        CustomButton(self, back_to_menu_label, lambda: change_frame(self, ExtensionPage(root)), 7, None, E, 1)
        self.grid() 
开发者ID:yakuza8,项目名称:peniot,代码行数:25,代码来源:tkinter.py

示例5: createClosableTabStyle

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def createClosableTabStyle(self):

        style = ttk.Style()

        style.element_create("close", "image", "img_close",
            ("active", "pressed", "!disabled", "img_closepressed"),
            ("active", "!disabled", "img_closeactive"), border=8, sticky='')

        style.layout("ButtonNotebook", [("ButtonNotebook.client", {"sticky": "nswe"})])
        style.layout("ButtonNotebook.Tab", [
            ("ButtonNotebook.tab", {"sticky": "nswe", "children":
                [("ButtonNotebook.padding", {"side": "top", "sticky": "nswe",
                                             "children":
                    [("ButtonNotebook.focus", {"side": "top", "sticky": "nswe",
                                               "children":
                        [("ButtonNotebook.label", {"side": "left", "sticky": ''}),
                         ("ButtonNotebook.close", {"side": "left", "sticky": ''})]
                    })]
                })]
            })]
        )

        return style 
开发者ID:PCWG,项目名称:PCWG,代码行数:25,代码来源:closable_Tab_with_menu.py

示例6: __init__

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def __init__(self, master=None, **kw):
        self.url = 'url' in kw and kw.pop('url') or None
        self.popup_copy = kw.pop('popup_copy', False)
        self.underline = kw.pop('underline', None)	# override ttk.Label's underline
        self.foreground = kw.get('foreground') or 'blue'
        self.disabledforeground = kw.pop('disabledforeground', ttk.Style().lookup('TLabel', 'foreground', ('disabled',)))	# ttk.Label doesn't support disabledforeground option

        if platform == 'darwin':
            # Use tk.Label 'cos can't set ttk.Label background - http://www.tkdocs.com/tutorial/styles.html#whydifficult
            kw['background'] = kw.pop('background', 'systemDialogBackgroundActive')
            kw['anchor'] = kw.pop('anchor', tk.W)	# like ttk.Label
            tk.Label.__init__(self, master, **kw)
        else:
            ttk.Label.__init__(self, master, **kw)

        self.bind('<Button-1>', self._click)

        self.menu = tk.Menu(None, tearoff=tk.FALSE)
        self.menu.add_command(label=_('Copy'), command = self.copy)	# As in Copy and Paste
        self.bind(platform == 'darwin' and '<Button-2>' or '<Button-3>', self._contextmenu)

        self.bind('<Enter>', self._enter)
        self.bind('<Leave>', self._leave)

        # set up initial appearance
        self.configure(state = kw.get('state', tk.NORMAL),
                       text = kw.get('text'),
                       font = kw.get('font', ttk.Style().lookup('TLabel', 'font')))

    # Change cursor and appearance depending on state and text 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:32,代码来源:ttkHyperlinkLabel.py

示例7: setUp

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def setUp(self):
        self.style = ttk.Style() 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:4,代码来源:test_style.py

示例8: setUp

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def setUp(self):
        super(StyleTest, self).setUp()
        self.style = ttk.Style(self.root) 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:5,代码来源:test_style.py

示例9: initUI

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def initUI(self):
		self.parent.title("Bitmesh Client")
		self.style = Style()
		self.style.theme_use("default")
		self.pack(fill=BOTH, expand=1)

		# set up the grid on the frame. Feels a lot like 
		# "GridBagLayout" from java.swing
		self.columnconfigure(1, weight=1)
		self.columnconfigure(3, pad=1)
		self.rowconfigure(3, weight=1)
		self.rowconfigure(5, pad=1)
		
		# establish text area with border of 1 that is "Sunken"
		self.log_text_area = Text(self, bd=1, relief=SUNKEN)
		self.log_text_area.insert(END,"BEGIN LOG\n---------")
		# Texts have to be in state normal to be modified. I am doing this
		# so the user doesn't edit the log
		self.log_text_area.config(state=DISABLED)
		self.log_text_area.grid(row=1, column=0, columnspan=2, rowspan=4, sticky=E+W+S+N)
		
		self.connect_button = Button(self, text="Connect to Server")
		# TODO: attempting to strech the button across the grid
		self.connect_button.grid(row=1, column=2, sticky=E+W+N)
		self.connect_button.bind("<Button-1>", self.connect_callback)

		self.request_text_area = Text(self, height=1, bd=1, relief=SUNKEN)
		self.request_text_area.grid(row=0 ,column=1, sticky=E+W)

		self.request_website_button = Button(self, text="Request Site")
		self.request_website_button.grid(row=0, column=0, columnspan=1, sticky=W+N)
		self.request_website_button.bind("<Button-1>", self.request_callback)

	# on connect_button left clicked 
开发者ID:adonley,项目名称:BitMeshPOC,代码行数:36,代码来源:client_interface.py

示例10: __init__

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def __init__(self, top=None):
        """This class configures and populates the toplevel window.
           top is the toplevel containing window."""
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.', background=[('selected', _compcolor), ('active', _ana1color)])

        top.geometry("388x169+474+249")
        top.title("Cheetah Update")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.TButton1 = ttk.Button(top)
        self.TButton1.place(relx=0.23, rely=0.71, height=27, width=87)
        self.TButton1.configure(command=cheetah_update_support.check_updates)
        self.TButton1.configure(takefocus="")
        self.TButton1.configure(textvariable=cheetah_update_support.check_update)

        self.Message1 = Message(top)
        self.Message1.place(relx=0.05, rely=0.12, relheight=0.44, relwidth=0.87)
        self.Message1.configure(background="#d9d9d9")
        self.Message1.configure(foreground="#000000")
        self.Message1.configure(highlightbackground="#d9d9d9")
        self.Message1.configure(highlightcolor="black")
        self.Message1.configure(textvariable=cheetah_update_support.update_msg)
        self.Message1.configure(width=337)

        self.TButton2 = ttk.Button(top)
        self.TButton2.place(relx=0.57, rely=0.71, height=27, width=87)
        self.TButton2.configure(command=cheetah_update_support.exit_update)
        self.TButton2.configure(takefocus="")
        self.TButton2.configure(text='''Cancel''') 
开发者ID:shmilylty,项目名称:cheetah-gui,代码行数:43,代码来源:cheetah_update.py

示例11: main

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def main():
    load_json()

    global root
    root = Tk()
    root.title(CONST_APP_VERSION)

    #style = ttk.Style(root)
    #style.theme_use('aqua')

    #root.configure(background='lightgray')
    # style configuration
    #style = Style(root)
    #style.configure('TLabel', background='lightgray', foreground='black')
    #style.configure('TFrame', background='lightgray')

    GUI = MainMenu(root)

    GUI_SIZE_WIDTH = 420
    GUI_SIZE_HEIGHT = 370
    GUI_SIZE_MACOS = str(GUI_SIZE_WIDTH) + 'x' + str(GUI_SIZE_HEIGHT)
    GUI_SIZE_WINDOWS=str(GUI_SIZE_WIDTH-60) + 'x' + str(GUI_SIZE_HEIGHT-20)

    GUI_SIZE =GUI_SIZE_MACOS
    import platform
    if platform.system() == 'Windows':
        GUI_SIZE =GUI_SIZE_WINDOWS
    root.geometry(GUI_SIZE)
    root.mainloop() 
开发者ID:max32002,项目名称:tixcraft_bot,代码行数:31,代码来源:settings.py

示例12: main

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def main():
	"""
	main function
	"""
	s = ttk.Style()
	s.theme_use('clam')
	ents = makeform(root)
	root.mainloop() 
开发者ID:nikhilkumarsingh,项目名称:content-downloader,代码行数:10,代码来源:gui.py

示例13: create_style

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def create_style(self):
        """create a Notebook style with close button"""
        # from https://github.com/python-git/python/blob/master/Demo/tkinter/
        #             ttk/notebook_closebtn.py
        # himself from http://paste.tclers.tk/896
        style = ttk.Style()

        style.element_create("close", "image", "img_close",
            ("active", "pressed", "!disabled", "img_closepressed"),
            ("active", "!disabled", "img_closeactive"), border=6, sticky='')

        style.layout("ButtonNotebook", [
            ("ButtonNotebook.client", {"sticky": "nswe"})])
        style.layout("ButtonNotebook.Tab", [
            ("ButtonNotebook.tab", {"sticky": "nswe", "children":
                [("ButtonNotebook.padding", {"side": "top", "sticky": "nswe",
                                     "children":
                  [("ButtonNotebook.focus", {"side": "top", "sticky": "nswe",
                                       "children":
                    [("ButtonNotebook.label", {"side": "left", "sticky": ''}),
                 ("ButtonNotebook.close", {"side": "left", "sticky": ''})]
                    })]
                })]
            })]
        )

        self.tk_win.bind_class("TNotebook", "<ButtonPress-1>",
                               self.btn_press, True)
        self.tk_win.bind_class("TNotebook", "<ButtonRelease-1>",
                               self.btn_release)
        self.tk_win.bind_class("TNotebook", "<B1-Motion>", self.btn_Movex)
        self.tk_win.bind_class("TNotebook", "<Double-1>", self.btn_presstwice) 
开发者ID:stonebig,项目名称:sqlite_bro,代码行数:34,代码来源:sqlite_bro.py

示例14: __init__

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def __init__(self, parent, **kwargs):
        """
        Construct a Tooltip with parent master.

        Keyword Options
        ---------------

        ttk.Label options,

        alpha: float. Tooltip opacity between 0 and 1.
        """
        tk.Toplevel.__init__(self, parent, padx=0, pady=0)
        self.transient(parent)
        self.overrideredirect(True)
        self.update_idletasks()
        self.attributes('-alpha', kwargs.pop('alpha', 0.8))
        if platform == 'linux':
            self.attributes('-type', 'tooltip')

        if not Tooltip._initialized:
            # default tooltip style
            style = ttk.Style(self)
            style.configure('tooltip.TLabel',
                            foreground='gray90',
                            background='black',
                            font='TkDefaultFont 9 bold')
            Tooltip._initialized = True

        # default options
        kw = {'compound': 'left', 'style': 'tooltip.TLabel', 'padding': 4}
        # update with given options
        kw.update(kwargs)

        self.label = ttk.Label(self, **kw)
        self.label.pack(fill='both')

        self.config = self.configure 
开发者ID:j4321,项目名称:tkcalendar,代码行数:39,代码来源:tooltip.py

示例15: initUI

# 需要导入模块: import ttk [as 别名]
# 或者: from ttk import Style [as 别名]
def initUI(self):
        self.parent.title(self.title)
        self.style=Style()
        #Choose from default, clam, alt, classic
        self.style.theme_use('alt')
        self.pack(fill=tk.BOTH,expand=True)
        self.centerWindow() 
开发者ID:Xunius,项目名称:Menotexport,代码行数:9,代码来源:menotexport-gui.py


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