Python ttk.Style() Examples

The following are code examples for showing how to use ttk.Style(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: AcidSloth   Author: frankcash   File: generatekey.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def initUI(self):
     
        self.parent.title("Send Message")
        self.style = Style()
        self.style.theme_use("default")
        self.e = Text(self)
        self.e.pack(expand = 1, fill= BOTH)
        #frame = Frame(self, relief=RAISED, borderwidth=1)
        #frame.pack(fill=BOTH, expand=1)
        
        self.pack(fill=BOTH, expand=1)
        
        createButton = Button(self, text="New User", command=self.create_key)
        createButton.pack(side=RIGHT, padx=5, pady=5)
        closeButton = Button(self, text="Clear", command=self.clear_text)
        closeButton.pack(side=RIGHT, padx=5, pady=5)
        okButton = Button(self, text="Send", command=self.send_text)
        okButton.pack(side=RIGHT) 
Example 2
Project: StochOPy   Author: keurfonluu   File: gui.py    MIT License 6 votes vote down vote up
def main():
    """
    Start StochOPy Viewer window.
    """
    import matplotlib
    matplotlib.use("TkAgg")
    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() 
Example 3
Project: FdiGenerator   Author: zxjsdp   File: fdi_generator.py    Apache License 2.0 6 votes vote down vote up
def set_style(self):
        """Set custom style for widget."""
        s = ttk.Style()
        # Configure button style
        s.configure('TButton', padding=(3, 10))
        s.configure(
            'execute.TButton',
            foreground='red',
        )

        s.configure('TLable', padding=(3, 10))
        s.configure(
            'status.TLabel',
            padding=10,
            foreground='#2E64FE'
        )

        s.configure('TEntry', padding=(3, 10)) 
Example 4
Project: SecretKeeper   Author: jonathanimb   File: SecretKeeper.py    GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent):
		ttk.Frame.__init__(self, parent)
		self.parent = parent

		self.parent.title("Password")
		self.style = ttk.Style()
		self.style.theme_use("default")
		self.pack(fill=tk.BOTH, expand=1)

		self.label = ttk.Label(self, text="Enter your Password")
		self.label.pack()
		self.entry = ttk.Entry(self, show='*')
		self.entry.bind("<KeyRelease-Return>", self.store_pass)
		self.entry.pack()
		self.entry.focus()
		button = ttk.Button(self, text="Submit", command=self.store_pass)
		button.pack() 
Example 5
Project: AIPycker   Author: keurfonluu   File: gui.py    MIT License 6 votes vote down vote up
def main():
    """
    Start Pycker Viewer window.
    """
    import matplotlib
    matplotlib.use("TkAgg")
    from sys import platform as _platform
    
    root = tk.Tk()
    root.max_width, root.max_height = root.maxsize()
    PyckerGUI(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() 
Example 6
Project: allmyservos   Author: allmyservos   File: TkResourceManager.py    GNU General Public License v2.0 6 votes vote down vote up
def addTaskManager(self):
		""" view - tasks ui
		"""
		row = 4
		self.widgets['taskframe'] = Frame(self.widget,bg=self.colours['bg'])
		self.widgets['taskframe'].grid(column=0,row=row,columnspan=2, sticky='EW')
		self.taskwidgets = {}
		self.notestyle = ttk.Style()
		self.notestyle.configure("TNotebook", background=self.colours['bg'], borderwidth=0)
		self.notestyle.configure("TNotebook.Tab", background=self.colours['buttonbg'], foreground='#000000', borderwidth=0)
		self.gridrows['tasks'] = 0
		self.taskwidgets['frameLabel'] = Tkinter.Label(self.widgets['taskframe'],text='Tasks / Network', anchor=NW, bg=self.colours['bg'], fg=self.colours['headingfg'], font=self.fonts['heading2'])
		self.taskwidgets['frameLabel'].grid(column=0,row=self.gridrows['tasks'], columnspan=1,sticky='EW')
		self.gridrows['tasks'] += 1
		self.taskwidgets['tasksnotebook'] = ttk.Notebook(self.widgets['taskframe'], style="TNotebook")
		self.taskwidgets['tasksnotebook'].grid(column=0,row=self.gridrows['tasks'],sticky='EW')
		self.addThreadManager()
		self.addProcessManager()
		self.addTrafficManager()
		self.addConnectionManager()
		self.taskwidgets['tasksnotebook'].add(self.widgets['processframe'], text="Processes")
		self.taskwidgets['tasksnotebook'].add(self.widgets['threadframe'], text="Threads")
		self.taskwidgets['tasksnotebook'].add(self.netwidgets['trafficwrap'], text="Traffic")
		self.taskwidgets['tasksnotebook'].add(self.netwidgets['connectionwrap'], text="Connections") 
Example 7
Project: RocketLeagueReplayHandler   Author: Zednosius   File: ReplayEditFrame.py    GNU General Public License v2.0 6 votes vote down vote up
def prepare_table(self):
        #Adjust table row height
        style = ttk.Style(self)
        style.configure('Treeview', rowheight=40)

        self.allcols = ["#1","#2","#3","#4","#5","#6","#7"]
        self.table["columns"] = self.allcols      
        self.table['show'] = 'headings'
        self.table_headings = ["Player","Team","Goals","Saves","Shots","Assists","Score"]

        #Create table headings
        for (idx,txt) in enumerate(self.table_headings):
            self.table.heading("#"+str(idx+1), text=txt)

        #Adjust column sizes
        for col in self.allcols:
            self.table.column(col,anchor='center',minwidth=75,width=75)

        self.table.column('#1',anchor='center',minwidth=100,width=160)
        self.table.bind("<<TreeviewSelect>>",self.edit_row) 
Example 8
Project: RocketLeagueReplayHandler   Author: Zednosius   File: ReplayInfoFrame.py    GNU General Public License v2.0 6 votes vote down vote up
def make_table(self):

        self.allcols = ["#1","#2","#3","#4"]
        self.table["columns"] =["#1","#2","#3","#4"]
        style = ttk.Style(self)
        style.configure('Treeview', rowheight=40)
        self.table['show'] = 'headings'
        #Set up headings
        self.table.heading("#1", text="Player",command=lambda:treeview_sort_column(self.table, "#1", False,unicode))
        self.table.heading("#2", text="Team"  ,command=lambda:treeview_sort_column(self.table ,"#2", False,int))
        self.table.heading("#3", text="Goals" ,command=lambda:treeview_sort_column(self.table, "#3", False,int))
        self.table.heading("#4", text="Saves" ,command=lambda:treeview_sort_column(self.table, "#4", False,int))
        for col in self.allcols:
            self.table.column(col,anchor='center',minwidth=75,width=75,stretch=True)
        self.table.column("#1",anchor='center',minwidth=100,width=100,stretch=True)
        #Remove the first column
        self.table.column("#0",width=0,minwidth=0)
        # self.table_insert_values()
        logger.info("Made table") 
Example 9
Project: EDMarketConnector   Author: Marginal   File: myNotebook.py    GNU General Public License v2.0 6 votes vote down vote up
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) 
Example 10
Project: EDMarketConnector   Author: Marginal   File: myNotebook.py    GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, master, variable, default=None, *values, **kw):
        if platform == 'darwin':
            variable.set(default)
            bg = kw.pop('background', PAGEBG)
            tk.OptionMenu.__init__(self, master, variable, *values, **kw)
            self['background'] = bg
        elif platform == 'win32':
            # OptionMenu derives from Menubutton at the Python level, so uses Menubutton's style
            ttk.OptionMenu.__init__(self, master, variable, default, *values, style='nb.TMenubutton', **kw)
            self['menu'].configure(background = PAGEBG)
            # Workaround for https://bugs.python.org/issue25684
            for i in range(0, self['menu'].index('end')+1):
                self['menu'].entryconfig(i, variable=variable)
        else:
            ttk.OptionMenu.__init__(self, master, variable, default, *values, **kw)
            self['menu'].configure(background = ttk.Style().lookup('TMenu', 'background'))
            # Workaround for https://bugs.python.org/issue25684
            for i in range(0, self['menu'].index('end')+1):
                self['menu'].entryconfig(i, variable=variable) 
Example 11
Project: pyblish-win   Author: pyblish   File: test_style.py    GNU Lesser General Public License v3.0 5 votes vote down vote up
def setUp(self):
        super(StyleTest, self).setUp()
        self.style = ttk.Style(self.root) 
Example 12
Project: thewarden   Author: pxsocs   File: PySimpleGUI.py    MIT License 5 votes vote down vote up
def DrawArc(self, top_left, bottom_right, extent, start_angle, style=None, arc_color='black'):
        """
        Draws different types of arcs.  Uses a "bounding box" to define location

        :param top_left: Union[Tuple[int, int], Tuple[float, float]] the top left point of bounding rectangle
        :param bottom_right: Union[Tuple[int, int], Tuple[float, float]] the bottom right point of bounding rectangle
        :param extent: (float) Andle to end drawing. Used in conjunction with start_angle
        :param start_angle: (float) Angle to begin drawing. Used in conjunction with extent
        :param style: (str) Valid choices are One of these Style strings- 'pieslice', 'chord', 'arc', 'first', 'last',
                        'butt', 'projecting', 'round', 'bevel', 'miter'
        :param arc_color: (str) color to draw arc with
        :return: Union[int, None] id returned from tkinter that you'll need if you want to manipulate the arc
        """
        converted_top_left = self._convert_xy_to_canvas_xy(top_left[0], top_left[1])
        converted_bottom_right = self._convert_xy_to_canvas_xy(bottom_right[0], bottom_right[1])
        tkstyle = tk.PIESLICE if style is None else style
        if self._TKCanvas2 is None:
            print('*** WARNING - The Graph element has not been finalized and cannot be drawn upon ***')
            print('Call Window.Finalize() prior to this operation')
            return None
        try:  # in case closed with X
            id = self._TKCanvas2.create_arc(converted_top_left[0], converted_top_left[1], converted_bottom_right[0],
                                            converted_bottom_right[1], extent=extent, start=start_angle, style=tkstyle,
                                            outline=arc_color)
        except:
            id = None
        return id 
Example 13
Project: thewarden   Author: pxsocs   File: PySimpleGUI.py    MIT License 5 votes vote down vote up
def __setup_styles(self):
        """ """
        # custom ttk styles
        style = ttk.Style(self.master)
        arrow_layout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', arrow_layout('left'))
        style.layout('R.TButton', arrow_layout('right')) 
Example 14
Project: Blockly-rduino-communication   Author: technologiescollege   File: sqlite_bro.py    GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 15
Project: TreeASCIIView   Author: zxjsdp   File: asciitree.py    Apache License 2.0 5 votes vote down vote up
def set_style(self):
        s = ttk.Style()

        s.configure('title.TLabel', padding='0 15 0 0')
        s.configure('title.TLabel', font=('Helvetica', 11)) 
Example 16
Project: oss-ftp   Author: aliyun   File: test_style.py    MIT License 5 votes vote down vote up
def setUp(self):
        super(StyleTest, self).setUp()
        self.style = ttk.Style(self.root) 
Example 17
Project: Telize-GeoIP-API   Author: killswitch-GUI   File: GeoIp-GUI.py    GNU General Public License v2.0 5 votes vote down vote up
def initUI(self):

        self.parent.title("Paste IP's Here:")
        self.style = Style()
        self.style.theme_use("aqua")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        self.rowconfigure(3, weight=1)
        self.rowconfigure(5, pad=7)

        lbl = Label(self, text="Paste IP's Here:")
        lbl.grid(sticky=W, pady=4, padx=5)

        area = Text(self)
        area.grid(row=1, column=0, columnspan=2, rowspan=4,
            padx=5, sticky=E+W+S+N)

        abtn = Button(self, text="Open", command=self.onOpen())
        abtn.grid(row=1, column=3)

        cbtn = Button(self, text="Close")
        cbtn.grid(row=2, column=3, pady=4)

        hbtn = Button(self, text="Help")
        hbtn.grid(row=5, column=0, padx=5)

        obtn = Button(self, text="OK")
        obtn.grid(row=5, column=3) 
Example 18
Project: FSMD   Author: praneetmehta   File: gui.py    MIT License 5 votes vote down vote up
def __init__(self, parent):
		Tk.__init__(self, parent)
		self.parent = parent
		self.font = tkFont.Font(family="Times")
		self.style = ttk.Style().configure('.', font=self.font)
		self.file_ = None
		self.initialize() 
Example 19
Project: Smart-Trader   Author: i-sultan   File: st_main_view.py    GNU General Public License v3.0 5 votes vote down vote up
def set_app_style():
    style = ttk.Style()
    style.theme_create( "st_app", parent="alt", settings={
        ".":             {"configure": {"background"      : StColors.dark_grey,
                                        "foreground"      : StColors.light_grey,
                                        "relief"          : "flat",
                                        "highlightcolor"  : StColors.bright_green}},

        "TLabel":        {"configure": {"foreground"      : StColors.bright_green,
                                        "padding"         : 10,
                                        "font"            : ("Calibri", 12)}},

        "TNotebook":     {"configure": {"padding"         : 5}},
        "TNotebook.Tab": {"configure": {"padding"         : [25, 5], 
                                        "foreground"      : "white"},
                            "map"      : {"background"      : [("selected", StColors.mid_grey)],
                                        "expand"          : [("selected", [1, 1, 1, 0])]}},

        "TCombobox":     {"configure": {"selectbackground": StColors.dark_grey,
                                        "fieldbackground" : "white",
                                        "background"      : StColors.light_grey,
                                        "foreground"      : "black"}},

        "TButton":       {"configure": {"font"            :("Calibri", 13, 'bold'),
                                        "background"      : "black",
                                        "foreground"      : StColors.bright_green},
                            "map"      : {"background"      : [("active", StColors.bright_green)],
                                        "foreground"      : [("active", 'black')]}},
            
        "TEntry":        {"configure": {"foreground"      : "black"}},
        "Horizontal.TProgressbar":{"configure": {"background": StColors.mid_grey}}
    })
    style.theme_use("st_app")

#.----------------.
#|    classes     |
#'----------------' 
Example 20
Project: cfa   Author: rhsdevelop   File: ttkcalendar.py    GNU General Public License v3.0 5 votes vote down vote up
def __setup_styles(self):
        # custom ttk styles
        style = ttk.Style(self.master)
        arrow_layout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', arrow_layout('left'))
        style.layout('R.TButton', arrow_layout('right')) 
Example 21
Project: cfa   Author: rhsdevelop   File: ttkcalendar.py    GNU General Public License v3.0 5 votes vote down vote up
def test():
    import sys
    root = Tkinter.Tk()
    root.title('Ttk Calendar')
    ttkcal = Calendar(firstweekday=calendar.SUNDAY, locale='pt_BR.utf8')
    ttkcal.pack(expand=1, fill='both')

    if 'win' not in sys.platform:
        style = ttk.Style()
        style.theme_use('clam')

    root.mainloop() 
Example 22
Project: FdiGenerator   Author: zxjsdp   File: fdi_generator.py    Apache License 2.0 5 votes vote down vote up
def set_style(self):
        """Set custom style for widget."""
        s = ttk.Style()
        s.configure('color.TButton', padding=0) 
Example 23
Project: cheetah-gui   Author: shmilylty   File: cheetah_update.py    GNU General Public License v3.0 5 votes vote down vote up
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''') 
Example 24
Project: tixcraft_bot   Author: max32002   File: settings.py    Apache License 2.0 5 votes vote down vote up
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() 
Example 25
Project: PyClASVi   Author: FraMuCoder   File: pyclasvi.py    MIT License 5 votes vote down vote up
def _set_style(self):
        s = ttk.Style()
        # center text in toolbuttons
        s.configure('Toolbutton', anchor='center', padding=s.lookup('TButton', 'padding'))

    # [parse] button is clicked 
Example 26
Project: Periscope   Author: 0xPoly   File: gui.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, master=None, **kw):
        npages = kw.pop('npages', 3)
        kw['style'] = 'Wizard.TNotebook'
        ttk.Style(master).layout('Wizard.TNotebook.Tab', '')
        ttk.Notebook.__init__(self, master, **kw)

        self._children = {}

        for page in range(npages):
            self.add_empty_page()

        self.current = 0
        self._wizard_buttons() 
Example 27
Project: linux-cross-gcc   Author: nmercier   File: test_style.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def setUp(self):
        super(StyleTest, self).setUp()
        self.style = ttk.Style(self.root) 
Example 28
Project: SerialScope   Author: dilawar   File: PySimpleGUI.py    GNU General Public License v3.0 5 votes vote down vote up
def __setup_styles(self):
        """ """
        # custom ttk styles
        style = ttk.Style(self.master)
        arrow_layout = lambda dir: (
            [('Button.focus', {'children': [('Button.%sarrow' % dir, None)]})]
        )
        style.layout('L.TButton', arrow_layout('left'))
        style.layout('R.TButton', arrow_layout('right')) 
Example 29
Project: NodeFinderGUI   Author: zxjsdp   File: nodefinder_gui.py    Apache License 2.0 5 votes vote down vote up
def set_style(self):
        """Set custom style for widget."""
        s = ttk.Style()

        # Configure button style
        s.configure('TButton', padding=5)
        s.configure(
            'execute.TButton',
            foreground='red',
        )
        s.configure(
            'newline.TButton',
            padding=6),
        s.configure(
            'clear.TButton',
            foreground='#2AA198',
        )

        # Configure Combobox style
        s.configure('TCombobox', padding=6)
        s.configure('config.TCombobox', )

        # Configure Title Frame
        s.configure(
            'title.TLabel',
            padding=10,
            font=('helvetica', 11, 'bold'),
        )
        s.configure(
            'config.TLabel',
            padding=1,
            font=('arial', 9),
        ) 
Example 30
Project: EDMarketConnector   Author: Marginal   File: myNotebook.py    GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, master=None, **kw):
        if platform in ['darwin', 'win32']:
            kw['foreground'] = kw.pop('foreground', PAGEFG)
            kw['background'] = kw.pop('background', PAGEBG)
        else:
            kw['foreground'] = kw.pop('foreground', ttk.Style().lookup('TLabel', 'foreground'))
            kw['background'] = kw.pop('background', ttk.Style().lookup('TLabel', 'background'))
        tk.Label.__init__(self, master, **kw)	# Just use tk.Label on all platforms 
Example 31
Project: EDMarketConnector   Author: Marginal   File: ttkHyperlinkLabel.py    GNU General Public License v2.0 5 votes vote down vote up
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 
Example 32
Project: XimaExport   Author: ryankomodo   File: ximaexport-gui.py    GNU General Public License v3.0 5 votes vote down vote up
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() 
Example 33
Project: scl_jamf_tools   Author: univ-of-utah-marriott-library-apple   File: tugboat.py    MIT License 5 votes vote down vote up
def button_state(self):
        """
        sets buttons to the correct state
        """

        #
        # This method is used to enable/disable specific buttons, based on OS, etc.
        #
        # You want to use the Combobox option of state='disabled'.
        #
        # There are three options for state as follows:
        #
        #     state='normal' which is the fully functional Combobox.
        #     state='readonly' which is the Combobox with a value, but can't be changed (directly).
        #     state='disabled' which is where the Combobox cannot be interacted with.
        #
        # self.highlight_button = ttk.Style()
        # self.highlight_button.configure('Highlight.TButton', foreground='red')
        # ttk.Button(self.mainframe, text="Query this system", style='Highlight.TButton', command= lambda: self.query_jamf_me()).grid(column=2, row=20, padx =3, sticky=W)

        self.logger.info("%s: activated" % inspect.stack()[0][3])

        if self.platform == "Mac" and self.access_level == 'full':
            self.jamf_management_btn.configure(state="normal")

        else:
            self.jamf_management_btn.configure(state="disabled") 
Example 34
Project: scl_jamf_tools   Author: univ-of-utah-marriott-library-apple   File: cargo_ship.py    MIT License 5 votes vote down vote up
def __init__(self, root, logger, jamf_hostname, jamf_username, jamf_password):
        """
        Initialize object and variables
        """
        self.root = root
        self.logger = logger
        self.jamf_hostname = jamf_hostname
        self.jamf_username = jamf_username
        self.jamf_password = jamf_password
        self.local_jamf_id = None

        self.computer_name_string = StringVar()
        self.fullname_string = StringVar()
        self.search_string = StringVar()
        self.status_string = StringVar()
        self.checkin_string = StringVar()
        self.id_string = StringVar()
        self.inventory_string = StringVar()

        self.status_string.set("Ready.")

        self.status_warning = ttk.Style()
        self.status_warning.configure('Warning.TLabel', foreground='red')

        self.status_normal = ttk.Style()
        self.status_normal.configure('Normal.TLabel', foreground='black')

        #
        # These methods are time intensive based on the number of each in your database
        self.jamf_policies = self.build_policies()
        self.jamf_profiles = self.build_profiles()

        self.build_ui() 
Example 35
Project: SpecimenInfo   Author: zxjsdp   File: specimen_info_gui.py    Apache License 2.0 5 votes vote down vote up
def set_style(self):
        """Set style for widgets."""
        s = ttk.Style()

        s.configure('TButton', padding='10 5')
        s.configure('exe.TButton', foreground='red')
        s.configure('TCombobox', padding='7')
        s.configure('TLabel', padding='3 7')
        s.configure('log.TLabel', foreground='blue')
        s.configure('TEntry', padding='5 7') 
Example 36
Project: thewarden   Author: pxsocs   File: PySimpleGUI.py    MIT License 4 votes vote down vote up
def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], style=DEFAULT_PROGRESS_BAR_STYLE,
                 relief=DEFAULT_PROGRESS_BAR_RELIEF, border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH,
                 orientation='horizontal', BarColor=(None, None), key=None):
        """

        :param root: Union[tk.Tk, tk.TopLevel] The root window bar is to be shown in
        :param max: (int) Maximum value the bar will be measuring
        :param length: (int) length in pixels of the bar
        :param width:  (int) width in pixels of the bar
        :param style:  (str) Progress bar style defined as one of these 'default', 'winnative', 'clam', 'alt', 'classic', 'vista', 'xpnative'
        :param relief: (str) relief style. Values are same as progress meter relief values.  Can be a constant or a string: `RELIEF_RAISED RELIEF_SUNKEN RELIEF_FLAT RELIEF_RIDGE RELIEF_GROOVE RELIEF_SOLID` (Default value = DEFAULT_PROGRESS_BAR_RELIEF)
        :param border_width: (int) The amount of pixels that go around the outside of the bar
        :param orientation: (str) 'horizontal' or 'vertical' ('h' or 'v' work) (Default value = 'vertical')
        :param BarColor:  Tuple[str, str] The 2 colors that make up a progress bar. One is the background, the other is the bar
        :param key: (Any) Used with window.FindElement and with return values to uniquely identify this element to uniquely identify this element
        """

        self.Length = length
        self.Width = width
        self.Max = max
        self.Orientation = orientation
        self.Count = None
        self.PriorCount = 0

        if orientation[0].lower() == 'h':
            s = ttk.Style()
            s.theme_use(style)
            if BarColor != COLOR_SYSTEM_DEFAULT:
                s.configure(str(key) + "my.Horizontal.TProgressbar", background=BarColor[0], troughcolor=BarColor[1],
                            troughrelief=relief, borderwidth=border_width, thickness=width)
            else:
                s.configure(str(key) + "my.Horizontal.TProgressbar", troughrelief=relief, borderwidth=border_width,
                            thickness=width)

            self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max,
                                                        style=str(key) + 'my.Horizontal.TProgressbar', length=length,
                                                        orient=tk.HORIZONTAL, mode='determinate')
        else:
            s = ttk.Style()
            s.theme_use(style)
            if BarColor != COLOR_SYSTEM_DEFAULT:
                s.configure(str(length) + str(width) + "my.Vertical.TProgressbar", background=BarColor[0],
                            troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width)
            else:
                s.configure(str(length) + str(width) + "my.Vertical.TProgressbar", troughrelief=relief,
                            borderwidth=border_width, thickness=width)
            self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max,
                                                        style=str(length) + str(width) + 'my.Vertical.TProgressbar',
                                                        length=length, orient=tk.VERTICAL, mode='determinate') 
Example 37
Project: stalta   Author: PALab   File: stalta.py    MIT License 4 votes vote down vote up
def main(argv=None):
    if argv is None:
        argv = sys.argv

    options = "ht:l"

    theme = "alt"
    list_all = False

    try:
        try:
            opts, datafiles = getopt.getopt(argv[1:], options, ["help"])
        except getopt.error, msg:
            raise Usage(msg)

        # process options
        for o, a in opts:
            if o in ("-h", "--help"):
                print __doc__ + "\nversion: " + version
                sys.exit(0)
            elif o == "-l":
                list_all = True
            elif o == "-t":
                theme = a
            else:
                print "unknown argument: " + a
                print __doc__ + "\nversion: " + version
                sys.exit(1)

        if list_all:
            style = ttk.Style()
            print "available themes:"
            for t in style.theme_names():
                print "    " + t
            return 0

        app = App(theme)
        app.root.mainloop()
        try:
            app.root.destroy()
        except:
            pass 
Example 38
Project: PcapXray   Author: Srinivas11789   File: userInterface.py    GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, base):
        # Base Frame Configuration
        self.base = base
        base.title("PcapXray")
        Label(base, text="PcapXray Tool - A LAN Network Analyzer")

        # Style Configuration
        style = ttk.Style()
        style.configure("BW.TLabel", foreground="black")
        style.configure("BW.TEntry", foreground="black")

        # 1st Frame - Initial Frame
        InitFrame = ttk.Frame(base,  width=50, padding="10 10 10 10",relief= GROOVE)
        InitFrame.grid(column=10, row=10, sticky=(N, W, E, S))
        InitFrame.columnconfigure(10, weight=1)
        InitFrame.rowconfigure(10, weight=1)

        # Pcap File Entry
        self.pcap_file = StringVar()
        self.filename = ""
        ttk.Label(InitFrame, text="Enter pcap file path: ",style="BW.TLabel").grid(column=0, row=0, sticky="W")
        self.filename_field = ttk.Entry(InitFrame, width=30, textvariable=self.pcap_file, style="BW.TEntry").grid(column=1, row=0, sticky="W, E")
        self.progressbar = ttk.Progressbar(InitFrame, orient="horizontal", length=200,value=0, maximum=200,  mode="indeterminate")
        # Browse button
        #self.filename = StringVar()
        ttk.Button(InitFrame, text="Browse", command=self.browse_directory).grid(column=2, row=0, padx=10, pady=10,sticky="E")
        ttk.Button(InitFrame, text="Analyze!", command=self.pcap_analyse).grid(column=3, row=0, padx=10, pady=10,sticky="E")
        self.progressbar.grid(column=4, row=0, padx=10, pady=10, sticky="E")

        # Second Frame with Options
        SecondFrame = ttk.Frame(base,  width=50, padding="10 10 10 10",relief= GROOVE)
        SecondFrame.grid(column=10, row=20, sticky=(N, W, E, S))
        SecondFrame.columnconfigure(10, weight=1)
        SecondFrame.rowconfigure(10, weight=1)
        ttk.Label(SecondFrame, text="Options: ", style="BW.TLabel").grid(row=10,column=0,sticky="W")
        self.option = StringVar()
        self.options = {'All','HTTP','HTTPS','Tor','Malicious'}
        #self.option.set('Tor')
        ttk.OptionMenu(SecondFrame,self.option,"Select",*self.options).grid(row=10,column=1,sticky="W")
        self.zoom = [900,900]
        self.img = ""
        ttk.Button(SecondFrame, text="zoomIn", command=self.zoom_in).grid(row=10,column=10,padx=5,sticky="E")
        ttk.Button(SecondFrame, text="zoomOut", command=self.zoom_out).grid(row=10,column=11,sticky="E")

        # Third Frame with Results and Descriptioms
        self.ThirdFrame = ttk.Frame(base,  width=100, height=100, padding="10 10 10 10",relief= GROOVE)
        description = """It is a tool aimed to simplyfy the network analysis and speed the process of analysing the network traffic.\nThis prototype aims to accomplish 4 important modules,
                        \n 1. Web Traffic\n 2. Tor Traffic \n 3. Malicious Traffic \n 4. Device/Traffic Details\n\nPlease contact me @ [email protected] for any bugs or problems !
                      """
        self.label = ttk.Label(self.ThirdFrame, text="Description: \nPcapXray tools is an aid for Network Forensics or Any Network Analysis!\n"+description, style="BW.TLabel")
        self.label.grid(column=10, row=10,sticky="W")
        self.xscrollbar = Scrollbar(self.ThirdFrame, orient=HORIZONTAL)
        self.xscrollbar.grid(row=100, column=0, sticky=E + W)
        self.yscrollbar = Scrollbar(self.ThirdFrame, orient=VERTICAL)
        self.yscrollbar.grid(row=0, column=100, sticky=N + S)
        self.ThirdFrame.grid(column=10, row=30, sticky=(N, W, E, S))
        self.ThirdFrame.columnconfigure(0, weight=1)
        self.ThirdFrame.rowconfigure(0, weight=1)
        self.name_servers = "" 
Example 39
Project: cheetah-gui   Author: shmilylty   File: cheetah_dictionary.py    GNU General Public License v3.0 4 votes vote down vote up
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'
        _ana2color = '#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', _ana2color)])

        top.geometry("398x150+490+300")
        top.title("Cheetah Dictionary Setting")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")
        top.resizable(0, 0)

        self.Label1 = Label(top)
        self.Label1.place(relx=0.05, rely=0.27, height=27, width=36)
        self.Label1.configure(background="#d9d9d9")
        self.Label1.configure(foreground="#000000")
        self.Label1.configure(text='''Path :''')

        self.Button1 = Button(top)
        self.Button1.place(relx=0.89, rely=0.27, height=24, width=24)
        self.Button1.configure(takefocus="")
        self.Button1.configure(text='''...''')
        self.Button1.configure(command=cheetah_dictionary_support.set_pwd_file)

        self.TButton2 = ttk.Button(top)
        self.TButton2.place(relx=0.21, rely=0.6, height=27, width=98)
        self.TButton2.configure(takefocus="")
        self.TButton2.configure(text='''Dereplicat''')
        self.TButton2.configure(command=cheetah_dictionary_support.dereplicat_pwd_file)

        self.TButton3 = ttk.Button(top)
        self.TButton3.place(relx=0.54, rely=0.6, height=27, width=98)
        self.TButton3.configure(takefocus="")
        self.TButton3.configure(text='''OK''')
        self.TButton3.configure(command=cheetah_dictionary_support.exit_dict_setting)

        self.TCombobox1 = ttk.Combobox(top)
        self.TCombobox1.place(relx=0.15, rely=0.27, relheight=0.18, relwidth=0.74)
        self.TCombobox1.configure(values=cheetah_dictionary_support.dict_list)
        self.TCombobox1.configure(textvariable=cheetah_dictionary_support.dict_path_var)
        self.TCombobox1.configure(takefocus="")
        # self.TCombobox1.set(cheetah_dictionary_support.dict_path) 
Example 40
Project: SecretKeeper   Author: jonathanimb   File: SecretKeeper.py    GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, parent):
		self.tab_delim = "\n=====++++++=====\n"
		self.tabs = []
		self.dirty = False

		ttk.Frame.__init__(self, parent)
		self.parent = parent
		self.parent.title(title)
		self.style = ttk.Style()
		self.style.theme_use("default")
		self.pack(fill=tk.BOTH, expand=1)
		self.nb = ttk.Notebook(self)
		self.nb.pack(fill=tk.BOTH, expand=1)

		self.saveButton = ttk.Button(self, text="Close", command=self.save)
		self.saveButton.pack(side=tk.RIGHT, padx=5, pady=5)
		# I don't feel like making a rekey dialog atm
		#~ rekeyButton = ttk.Button(self, text="Re-Key", command=self.rekey)
		#~ rekeyButton.pack(side=tk.RIGHT, padx=5, pady=5)
		addButton = ttk.Button(self, text="Add Tab", command=self.add_tab)
		addButton.pack(side=tk.LEFT, padx=5, pady=5)
		delButton = ttk.Button(self, text="Delete Tab", command=self.rem_tab)
		delButton.pack(side=tk.LEFT, padx=5, pady=5)
		passButton = ttk.Button(self, text="new password", command=self.randpass)
		passButton.pack(side=tk.LEFT, padx=5, pady=5)
		self.randpass_ent = tk.Entry(self, width=30)
		self.randpass_ent.pack(side=tk.LEFT, padx=5, pady=5)

		#add search tab
		f = ttk.Frame(self.nb)
		self.search = ttk.Entry(f)
		self.search.focus()
		self.search.pack(fill=tk.BOTH)
		self.search.bind("<KeyRelease>", self.search_key_press)
		self.search_result = ScrolledText(f, relief=tk.RAISED, wrap=tk.WORD, state=tk.DISABLED)
		self.search_result.pack(fill=tk.BOTH, expand=1)
		self.nb.add(f, text='search')

		#add other tabs
		for text in self.parent.secret.split(self.tab_delim):
			self.add_tab(text, dirty=False)
		self.nb.select(self.nb.tabs()[0]) #select search tab

		self.dictionary = dictionary.split()
		self.randpass()

		parent.geometry(geometry)
		parent.minsize(600, 460) 
Example 41
Project: SerialScope   Author: dilawar   File: PySimpleGUI.py    GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, root, max, length=400, width=DEFAULT_PROGRESS_BAR_SIZE[1], style=DEFAULT_PROGRESS_BAR_STYLE,
                 relief=DEFAULT_PROGRESS_BAR_RELIEF, border_width=DEFAULT_PROGRESS_BAR_BORDER_WIDTH,
                 orientation='horizontal', BarColor=(None, None), key=None):
        """

        :param root: 
        :param max: 
        :param length:  (Default value = 400)
        :param width:  (Default value = DEFAULT_PROGRESS_BAR_SIZE[1])
        :param style:  (Default value = DEFAULT_PROGRESS_BAR_STYLE)
        :param relief:  (Default value = DEFAULT_PROGRESS_BAR_RELIEF)
        :param border_width:  (Default value = DEFAULT_PROGRESS_BAR_BORDER_WIDTH)
        :param orientation:  (Default value = 'horizontal')
        :param BarColor:  (Default value = (None, None))
        :param key: (common_key) Used with window.FindElement and with return values (Default value = None)

        """

        self.Length = length
        self.Width = width
        self.Max = max
        self.Orientation = orientation
        self.Count = None
        self.PriorCount = 0

        if orientation[0].lower() == 'h':
            s = ttk.Style()
            s.theme_use(style)
            if BarColor != COLOR_SYSTEM_DEFAULT:
                s.configure(str(key) + "my.Horizontal.TProgressbar", background=BarColor[0], troughcolor=BarColor[1],
                            troughrelief=relief, borderwidth=border_width, thickness=width)
            else:
                s.configure(str(key) + "my.Horizontal.TProgressbar", troughrelief=relief, borderwidth=border_width,
                            thickness=width)

            self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max,
                                                        style=str(key) + 'my.Horizontal.TProgressbar', length=length,
                                                        orient=tk.HORIZONTAL, mode='determinate')
        else:
            s = ttk.Style()
            s.theme_use(style)
            if BarColor != COLOR_SYSTEM_DEFAULT:
                s.configure(str(length) + str(width) + "my.Vertical.TProgressbar", background=BarColor[0],
                            troughcolor=BarColor[1], troughrelief=relief, borderwidth=border_width, thickness=width)
            else:
                s.configure(str(length) + str(width) + "my.Vertical.TProgressbar", troughrelief=relief,
                            borderwidth=border_width, thickness=width)
            self.TKProgressBarForReal = ttk.Progressbar(root, maximum=self.Max,
                                                        style=str(length) + str(width) + 'my.Vertical.TProgressbar',
                                                        length=length, orient=tk.VERTICAL, mode='determinate') 
Example 42
Project: qcri   Author: douville   File: gui.py    BSD 2-Clause "Simplified" License 4 votes vote down vote up
def __init__(self, cfg):
        tk.Tk.__init__(self)
        self.cfg = cfg  # ConfigParser

        self.qcc = None  # the Quality Center connection
        self.valid_parsers = {}
        self._cached_tests = {}  # for the treeview
        self._results = {}  # test results
        self.dir_dict = {}
        self.bug_dict = {}

        self.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.title('QC Results Importer')
        center(self, 1200, 700)

        # tkinter widgets
        self.menubar = None
        self.remote_path = None
        self.choose_parser = None
        self.choose_results_button = None
        self.qcdir_tree = None
        self.upload_button = None
        self.choose_results_entry = None
        self.runresults_tree = None
        self.runresultsview = None
        self.header_frame = None
        self.qc_connected_frm = None
        self.qc_disconnected_frm = None
        self.link_bug = None

        self.qc_domain = tk.StringVar()
        self.attach_report = tk.IntVar()
        self.qc_project = tk.StringVar()
        self.runresultsvar = tk.StringVar()
        self.qc_conn_status = tk.BooleanVar()

        # build the gui        
        self._make()

        # style = ttk.Style()
        # style.theme_settings("default", {
        #     "TCombobox": {
        #         "configure": {"padding": 25}
        #     }
        # }) 
Example 43
Project: EDMarketConnector   Author: Marginal   File: theme.py    GNU General Public License v2.0 4 votes vote down vote up
def _colors(self, root, theme):
        style = ttk.Style()
        if platform == 'linux2':
            style.theme_use('clam')

        # Default dark theme colors
        if not config.get('dark_text'):
            config.set('dark_text', '#ff8000')	# "Tangerine" in OSX color picker
        if not config.get('dark_highlight'):
            config.set('dark_highlight', 'white')

        if theme:
            # Dark
            (r, g, b) = root.winfo_rgb(config.get('dark_text'))
            self.current = {
                'background'         : 'grey4',	# OSX inactive dark titlebar color
                'foreground'         : config.get('dark_text'),
                'activebackground'   : config.get('dark_text'),
                'activeforeground'   : 'grey4',
                'disabledforeground' : '#%02x%02x%02x' % (r/384, g/384, b/384),
                'highlight'          : config.get('dark_highlight'),
                # Font only supports Latin 1 / Supplement / Extended, and a few General Punctuation and Mathematical Operators
                'font'               : (theme > 1 and not 0x250 < ord(_('Cmdr')[0]) < 0x3000 and
                                        tkFont.Font(family='Euro Caps', size=10, weight=tkFont.NORMAL) or
                                        'TkDefaultFont'),
            }
        else:
            # (Mostly) system colors
            style = ttk.Style()
            self.current = {
                'background'         : (platform == 'darwin' and 'systemMovableModalBackground' or
                                        style.lookup('TLabel', 'background')),
                'foreground'         : style.lookup('TLabel', 'foreground'),
                'activebackground'   : (platform == 'win32' and 'SystemHighlight' or
                                        style.lookup('TLabel', 'background', ['active'])),
                'activeforeground'   : (platform == 'win32' and 'SystemHighlightText' or
                                        style.lookup('TLabel', 'foreground', ['active'])),
                'disabledforeground' : style.lookup('TLabel', 'foreground', ['disabled']),
                'highlight'          : 'blue',
                'font'               : 'TkDefaultFont',
            }


    # Apply current theme to a widget and its children, and register it for future updates