Beispiel #1
0
 def set_theme_defaults(cls, master, theme_name='default', style_name=None):
     style = Style(master)
     if style_name is None:
         style_name = cls.STYLE_NAME
     style.theme_settings(theme_name, {
         style_name: cls.STYLE_DEFAULTS
     })
Beispiel #2
0
    def __init__(self, darkmode=True):
        self._darkMode = darkmode

        if self.isDark():
            s = Style()
            s.theme_settings("default", dark_theme())
            s.theme_use("default")
        else:
            raise NotImplementedError("Light mode is not supported")
from tkinter.ttk import Style, Combobox, Label
from tkinter import Tk
root = Tk()
style = Style()
# this is needed even though we are using 'default' in theme_settings
style.theme_use('default')
style.theme_settings(
    "default",
    {
        "TCombobox": {  # widget class name
            # note how style.configure and style.map are formatted
            "configure": {
                "padding": 5
            },
            "map": {
                # background refers to downarrow
                "background": [("active", "sky blue"), ("!disabled", "cyan")],
                # on first selecting from list the text background is grey,
                # inherited from default theme
                # fieldbackground refers to field
                "fieldbackground": [("!disabled", "green3")],
                "foreground": [("focus", "OliveDrab1"),
                               ("!disabled", "OliveDrab2")]
            }
        }
    })
l = Label(text='Use the right down arrow to see choice then select')
l.pack(padx=5, pady=5)
combo = Combobox(values=['apple', 'banana', 'orange']).pack(padx=5, pady=5)
root.mainloop()
Beispiel #4
0
style.theme_settings(
    'default',
    {
        # start of theme extract
        'TButton': {
            'configure': {
                'anchor': 'center',
                'font': pirate_font
            },
            'layout': [('Button.focus', {
                'children': [('Button.button', {
                    'children': [('Button.padding', {
                        'children': [('Button.label', {
                            'expand': 0
                        })]
                    })]
                })]
            })]
        },
        'Button.button': {
            "element create":
            ('image', "button", ('pressed', "button-p"),
             ('selected', "button-s"), ('active', "button-s"),
             ('disabled', "button-d"), {
                 'border': [52, 65, 47, 17],
                 'padding': [12, 54, 8, 16],
                 'sticky': "nsew"
             })
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })
style = Style()
# both theme_create and theme_settings worked
#style.theme_create( "yummy", parent="clam", settings={
style.theme_settings(
    'alt',
    {
        # start of theme extract
        "Combobox.field": {
            "element create":
            ("image", 'combo-n', ('readonly', 'disabled', 'combo-rd'),
             ('readonly', 'pressed', 'combo-rp'),
             ('readonly', 'focus', 'combo-rf'), ('readonly', 'combo-rn'), {
                 'sticky': 'ew',
                 'border': [4]
             })
        },
        "Combobox.downarrow": {
            "element create":
            ("image", 'comboarrow-n', ('disabled', 'comboarrow-d'),
             ('pressed', 'comboarrow-p'), ('active', 'comboarrow-a'), {
                 'sticky': '',
                 'border': [1]
             })
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })

style.theme_use('alt')  # 'yummy'
sv = StringVar()
widg = Combobox(fr, values=['apple', 'banana', 'orange'], textvariable=sv)
Beispiel #6
0
    draw.polygon([ST0[0], ST0[1], 0, HEIGHT - 1, WIDTH - 1, HEIGHT - 1],
                 fill=LIGHT)
    draw.polygon([ST0[0], ST0[1], ST0[0], 0, 0, HEIGHT - 1], fill=DARK)
    draw.polygon([ST0[0], ST0[1], WIDTH - 1, HEIGHT - 1, ST0[0], 0],
                 fill=MEDIUM)
    sliderp = ImageTk.PhotoImage(imp)

    style = Style()
    style.theme_settings(
        'default', {
            'Horizontal.Scale.trough': {
                "element create": ('image', trough, {
                    'border': 0,
                    'sticky': 'wes'
                })
            },
            'Horizontal.Scale.slider': {
                "element create": ('image', slider, ('pressed', sliderp), {
                    'border': 3,
                    'sticky': 'n'
                })
            }
        })

    style.theme_use('default')

    fra0 = Frame(root)
    fra0.grid(row=0, column=0, sticky='nsew')
    HsvSelect(fra0)
    root.mainloop()
Beispiel #7
0
    def panel(self):
        self.ballb.grid(row=0, column=1, sticky="e")
        self.ballb2.grid(row=0, column=2, sticky="e")
        self.username = self.loginContainer.username
        mycursor.execute(
            f"SELECT AcNo FROM profile WHERE username = '******';")
        self.acno = mycursor.fetchone()[0]
        style = Style(self)
        style.configure("leftTab.TNotebook", tabposition="s")
        style.theme_settings(
            self.theme,
            {"TNotebook.Tab": {
                "configure": {
                    "padding": [10, 10]
                }
            }})
        self.notebook = Notebook(self.MainFrame,
                                 style="leftTab.TNotebook",
                                 width=800,
                                 height=500)
        self.notebook.pack(expand=True, fill="both")
        self.notebook.bind("<<NotebookTabChanged>>", self.logout)
        self.tabs = {
            "Dasboard":
            Dasboard.dasboard(self.notebook, self.username),
            "Transactions":
            Transaction.transaction(self.notebook, self.acno, self.TkBal),
            "Pay":
            Pay.pay(self.notebook, self.acno, self.TkBal),
            "Change Password":
            ChangePsswd.change(self.notebook, self.username),
            "Settings":
            Admin.user(self.notebook, self.username),
        }
        self.syncFunc = [
            Dasboard.dasboard,
            Transaction.transaction,
            Pay.pay,
            ChangePsswd.change,
            Admin.user,
        ]
        mycursor.execute(
            f"SELECT Admin FROM profile WHERE username = '******';")
        self.images = {}
        self.Tkimages = {}
        self.ImageIter = 0
        for image in [
                "Dasboard",
                "Transactions",
                "Pay",
                "Change Password",
                "Settings",
                "add_user",
                "view",
                "leave",
        ]:
            self.images[image] = Image.open(f".//assets//{image}.png")
            self.images[image].thumbnail((30, 30), Image.ANTIALIAS)
            self.Tkimages[image] = ImageTk.PhotoImage(self.images[image])

        for tab in self.tabs.keys():
            self.notebook.add(
                self.tabs[tab],
                text=tab,
                image=self.Tkimages[tab.strip()],
                compound="top",
            )
            self.ImageIter += 1

        if mycursor.fetchone()[0]:
            self.notebook.add(
                Admin.admin(self.notebook, self.username),
                text="Add/Edit Ac",
                image=self.Tkimages["add_user"],
                compound="top",
            )
            self.syncFunc.append(Admin.admin)
            self.notebook.add(
                Transaction.view(self.notebook),
                text="View Clients",
                image=self.Tkimages["view"],
                compound="top",
            )
            self.syncFunc.append(Transaction.view)

        self.notebook.add(Frame(),
                          text="Logout",
                          image=self.Tkimages["leave"],
                          compound="top")
Beispiel #8
0
 def set_theme_defaults(cls, master, theme_name='default', style_name=None):
     style = Style(master)
     if style_name is None:
         style_name = cls.STYLE_NAME
     style.theme_settings(theme_name, {style_name: cls.STYLE_DEFAULTS})
style.theme_settings(
    'default',
    {
        # start of theme extract
        'TButton': {
            'configure': {
                "anchor": "center",
                'padding': [10, 0],
                'foreground': '#8b0a50'
            },  # "width": 10,,
            'layout': [('Button.focus', {
                'children': [('Button.button', {
                    'children': [('Button.padding', {
                        'children': [('Button.label', {
                            "side": "left",
                            'expand': 1
                        })]
                    })]
                })]
            })]
        },
        'Button.button': {
            "element create":
            ('image', "slider-hn", ('pressed', "slider-hp"),
             ('active', "slider-ha"), ('selected', "button-sa"),
             ('disabled', "slider-hd"), {
                 'border': [5, 12, 5, 12],
                 'padding': 4,
                 'sticky': "nsew"
             })  # "nsew"
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })