Example #1
0
    def __init__(self, window, initial=' ', options=[], instance=str, command=None, width=None):

        if initial not in options:
            raise RuntimeError('DropDown menu: Not valid initial value ({0}).'.format(initial))

        self.variable = StringVar(window.root, value=initial)
        self.instance = instance
        self.command = command

        try:

            combostyle = Style()
            combostyle.theme_create('combostyle', parent='alt',
                                    settings={'TCombobox': {'configure':
                                                                {'selectbackground': 'white',
                                                                 'fieldbackground': 'white',
                                                                 'background': 'white'}}})
            combostyle.theme_use('combostyle')

        except:
            pass
        if width:
            widget = Combobox(window.main_frame, textvariable=self.variable, state='readonly', width=width)
        else:
            widget = Combobox(window.main_frame, textvariable=self.variable, state='readonly', width=int(window.log.entries_width * 0.8))

        options = [str(ff) for ff in options]
        widget['values'] = tuple(options)

        widget.bind('<<ComboboxSelected>>', self.internal_command)

        HOPSWidget.__init__(self, window, widget, 'DropDown')
Example #2
0
 def __init__(self, frame, options, stringvar=None, width=20, height=21):
     self.text_font = ('Microsoft Sans Serif', '10')
     combostyle = Style()
     combostyle.theme_create('combostyle',
                             parent='alt',
                             settings={
                                 "TCombobox": {
                                     "configure": {
                                         "selectbackground": "#F7A5D2",
                                         "fieldbackground": "#F7A5D2",
                                         "background": "#C0C0C0",
                                         "selectforeground": "black",
                                         "bordercolor": "#C0C0C0"
                                     }
                                 }
                             })
     combostyle.theme_use('combostyle')
     Combobox.__init__(self,
                       frame,
                       values=options,
                       textvariable=stringvar,
                       width=width,
                       height=height,
                       state="readonly",
                       font=self.text_font)
     frame.root.option_add('*TCombobox*Listbox.font', self.text_font)
     self.bind("<<ComboboxSelected>>", self.do)
Example #3
0
 def init():
     style = Style()
     style.theme_create('notebook', settings={
         "TNotebook": {"configure": {"background": Theme.BACKGROUND_COLOR}},
         "TNotebook.Tab": {
             "configure": {"padding": [5, 1], "background": Theme.DISABLED_COLOR, 'foreground': Theme.FONT_COLOR},
             "map": {"background": [("selected", Theme.FRAME_COLOR)],
                     "foreground": [("selected", Theme.FONT_COLOR), ("active", Theme.HIGHLIGHT_COLOR)]}
         }
     })
     style.theme_use('notebook')
Example #4
0
    def __init__(self, *args):
        Notebook.__init__(self, *args)
        self.pack(expand=True, fill=BOTH)

        style = Style()
        style.theme_create('CustomTapStyle',
                           settings={
                               'TNotebook.Tab': {
                                   'configure': {
                                       'padding': [50, 10],
                                       'borderwidth': 1,
                                   },
                                   "map": {
                                       'background': [("selected", '#00FF00')]
                                   }
                               }
                           })
        style.theme_use("CustomTapStyle")
img1 = PhotoImage("separator", file='../images/piratz/separator.png')
img2 = PhotoImage("separator-v", file='../images/piratz/separator-v.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
    'Horizontal.TSeparator': {'layout': [
        ('Horizontal.Separator.hseparator',{"sticky": "ew"},
        )]},
    
    'Vertical.TSeparator': {'layout': [
        ('Vertical.Separator.vseparator',{"sticky": "ns"},
        )]},

    'Separator.hseparator': {"element create":
        ('image', "separator",
         {'border':[3],'sticky': 'ew'})},

    'Separator.vseparator': {"element create":
        ('image', "separator-v",
         {'border':[3],'sticky': 'ns'})}
    
# end of theme extract - don't forget to add comma at end when inserting
     })

fr1 = Frame(fr, height=250, width=250)
fr1.grid(column=1,row=0,sticky='nsew', padx=5, pady=5)                    
style.theme_use('yummy') # 'default'
widg = Separator(fr1,orient="horizontal")
img1 = PhotoImage("check-nc", file='../images/piratz/check-nc.png')
img2 = PhotoImage("check-dc", file='../images/piratz/check-dc.png')
img3 = PhotoImage("check-du", file='../images/piratz/check-du.png')
img4 = PhotoImage("check-nu", file='../images/piratz/check-nu.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
     'Checkbutton.indicator': {"element create":
          ('image', "check-nu",
           ('pressed', 'selected', "check-nc"),
           ('pressed', "check-nu"),
           ('active', 'selected', "check-nc"),
           ('active', "check-nu"),
           ('selected', "check-nc"),
           ('disabled', "check-du"),
           ('disabled', 'selected', "check-dc"),
           {'width':24, 'sticky': "w"}) 
         }
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'
'''
widg = Label(fr,text='Piratz!')
widg.grid(column=0,row=11,sticky='nsew', padx=5, pady=5)
widg1 = Label(fr,text='Piratz!\nextra line')
widg1.grid(column=0,row=12,sticky='nsew', padx=5, pady=5)
'''
Example #7
0
    def __init__(self, **kw):
        self.log = logging.getLogger(__name__ + "." + self.__class__.__name__)

        super(TurnChangeWindows, self).__init__(**kw)

        style = Style()
        style.theme_create("st_app", parent="alt", settings={
            ".": {"configure": {"font": ("Calibri", 13, 'bold'),
                                "background": StColors.dark_grey,
                                "foreground": StColors.light_grey,
                                "relief": "flat",
                                "highlightcolor": StColors.bright_green, }, },
            "TLabel": {"configure": {"foreground": StColors.bright_green,
                                     "padding": 5,
                                     "font": ("Calibri", 11)}},

            "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),
                                      "background": StColors.black,
                                      "foreground": StColors.bright_green},
                        "map": {"background": [("active", StColors.bright_green), ("disabled", '#2d3234')],
                                "foreground": [("active", 'black'), ("disabled", '#919282')]}},

            "TEntry": {"configure": {"foreground": "black"}},
            "Horizontal.TProgressbar": {"configure": {"background": StColors.mid_grey}}
        })
        style.theme_use("st_app")

        self.title("Piternet")
        self.geometry("630x230")
        self.configure(background=StColors.black)

        s = Style()
        s.configure('My.TFrame', background=StColors.black)

        frame = Frame(self, style='My.TFrame')
        self._developmentFrame = DevelopmentFrame(master=frame)
        self._infoFrame = InfoFrame(master=self)
        self._turnChangeFrame = PiternetFrame(master=frame)

        # self.bind("<Button-1>", self.callback)
        self._refreshKey = False
        self.bind_all('<KeyPress>', self.keyPress)

        self._infoFrame.pack(expand=True, fill='x', **parameter.PADDING_FRAME_EXTERNAL_TOP)

        self._developmentFrame.pack(side=tkinter.LEFT, expand=False, **parameter.PADDING_FRAME_LEFT)
        self._turnChangeFrame.pack(side=tkinter.RIGHT, expand=False, **parameter.PADDING_FRAME_RIGHT)

        frame.pack(fill='x', **parameter.PADDING_FRAME_EXTERNAL_BOT)

        self.protocol("WM_DELETE_WINDOW", self.onExit)
        self._turnChangeFrame.refreshStatusPiternet()
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-d'),
                #('readonly', 'pressed', 'combo-rp'),
                #('readonly', 'focus', 'combo-rf'),
                #('readonly',  'combo-rn'),
                {
                    'sticky': 'ew',
                    'border': [4],
                    'padding': 1
                })
        },
        "Combobox.downarrow": {
            "element create":
            ("image", 'arrowdown-n', ('disabled', 'arrowdown-d'),
             ('pressed', 'arrowdown-p'), ('active', 'arrowdown-a'), {
                 'sticky': '',
                 'border': [1],
                 'padding': 4
             })
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Horizontal.Progressbar.trough': {
            "element create": ('image', "trough-pbar-horiz", {
                'border': 4
            })
        },
        'Horizontal.Progressbar.pbar': {
            "element create": ('image', "pbar-boat-a",
                               ('background', '!active', "pbar-boat-b"), {
                                   'border': [2, 9]
                               })
        },
        'Vertical.Progressbar.trough': {
            "element create": ('image', "trough-pbar-vert", {
                'border': 3
            })
        },
        'Vertical.Progressbar.pbar': {
            "element create":
            ('image', "pbar-gull-a", ('background', '!active', '!invalid',
                                      "pbar-gull-b"),
             ('invalid', '!active', '!background', "pbar-gull-b"), {
                 'border': [9, 2]
             })
        }
        # end of theme extract - don't forget to add comma at end when inserting
    })
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        "Horizontal.TScrollbar": {
            "layout": [("Horizontal.Scrollbar.trough", {
                "sticky":
                "ew",
                "children": [("Horizontal.Scrollbar.leftarrow", {
                    "side": "left"
                }), ("Horizontal.Scrollbar.rightarrow", {
                    "side": "right"
                }),
                             ("Horizontal.Scrollbar.thumb", {
                                 "side": "left",
                                 "expand": 1,
                                 "sticky": "ew"
                             })]
            })]
        },
        "Horizontal.Scrollbar.thumb": {
            "element create":
            ("image", 'slider-hn', ('disabled', 'slider-hd'),
             ('pressed', 'slider-ha'), ('active', 'slider-ha'), {
                 "border": [9, 2]
             })  #3 , 'sticky': 'ew', 'padding': [7,2] 
        },
        "Horizontal.Scrollbar.trough": {
            "element create": ('image', 'trough-horiz', {
                "border": 2,
                'width': 32,
                'height': 21
            })
        },  # , 'sticky': 'ew'
        'Scrollbar.leftarrow': {
            "element create":
            ("image", 'arrowleft-n', ('disabled', 'arrowleft-d'),
             ('pressed', 'arrowleft-p'), ('active', 'arrowleft-a'), {
                 "border": 1
             })
        },
        'Scrollbar.rightarrow': {
            "element create":
            ("image", 'arrowright-n', ('disabled', 'arrowright-d'),
             ('pressed', 'arrowright-p'), ('active', 'arrowright-a'), {
                 "border": 1
             })
        },
        "Vertical.TScrollbar": {
            "layout": [("Vertical.Scrollbar.trough", {
                "sticky":
                "ns",
                "children": [("Vertical.Scrollbar.uparrow", {
                    "side": "top"
                }), ("Vertical.Scrollbar.downarrow", {
                    "side": "bottom"
                }),
                             ("Vertical.Scrollbar.thumb", {
                                 "side": "top",
                                 "expand": 1,
                                 "sticky": "ns"
                             })]
            })]
        },
        "Vertical.Scrollbar.thumb": {
            "element create":
            ("image", 'slider-vn', ('disabled', 'slider-vd'),
             ('pressed', 'slider-va'), ('active', 'slider-va'), {
                 "border": [2, 9]
             })
        },
        "Vertical.Scrollbar.trough": {
            "element create": ('image', 'trough-vert', {
                "border": 2,
                'width': 21,
                'height': 32
            })
        },
        'Scrollbar.uparrow': {
            "element create":
            ("image", 'arrowup-n', ('disabled', 'arrowup-d'),
             ('pressed', 'arrowup-p'), ('active', 'arrowup-a'), {
                 "border": 1
             })
        },
        'Scrollbar.downarrow': {
            "element create":
            ("image", 'arrowdown-n', ('disabled', 'arrowdown-d'),
             ('pressed', 'arrowdown-p'), ('active', 'arrowdown-a'), {
                 "border": 1
             })
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })
Example #11
0
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('alt', {
        # start of theme extract
        "Spinbox.field": {
            "element create": (
                "image",
                'combo-n',
                ('readonly', 'disabled', 'combo-d'),
                {
                    'sticky': 'nsew',
                    'border': [4],
                    'padding': 0
                }  # 'padding': 0
            )
        },
        "Spinbox.downarrow": {
            "element create": (
                "image",
                'arrspd-n',
                ('disabled', 'arrspd-d'),
                ('pressed', 'arrspd-p'),
                ('active', 'arrspd-h'),
                {
                    'sticky': 'e',
                    'border': [0],
                    'padding': 4
                }  # 'border': [1]
            )
        },
        "Spinbox.uparrow": {
            "element create":
            ("image", 'arrspu-n', ('disabled', 'arrspu-d'),
             ('pressed', 'arrspu-p'), ('active', 'arrspu-h'), {
                 'sticky': 'e',
                 'border': [0],
                 'padding': 4
             })
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        # next line refers to common to all widgets
        ".": {
            "configure": {
                "background": colours['frame'],
                "troughcolor": colours['frame'],
                "selectbackground": colours['selectbg'],
                "selectforeground": colours['selectfg'],
                "fieldbackground": colours['frame'],
                "font": "TkDefaultFont",
                "borderwidth": 1
            },
            "map": {
                "foreground": [("disabled", colours['disabledfg'])]
            }
        },
        'TEntry': {
            'configure': {
                'selectborderwidth': 1,
                'padding': 2,
                'insertwidth': 2,
                'font': 'TkTextFont'
            }
        },
        'TCombobox': {
            'configure': {
                'selectborderwidth': 1,
                'padding': 2,
                'insertwidth': 2,
                'font': 'TkTextFont'
            }
        }
        # end of theme extract - don't forget to add comma at end when inserting
    })
Example #13
0
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Horizontal.Scale.trough': {
            "element create":
            ('image', "trough-tabletop", ('background', 'trough-beach'),
             ('focus', 'trough-beach'), ('invalid', 'trough-beach'),
             ('readonly', 'trough-sea'), ('selected', 'trough-sea'))
        },
        'Horizontal.Scale.slider': {
            "element create":
            ('image', "slider-horiz-map",
             ('background', "slider-horiz-c-chest"), ('invalid',
                                                      "slider-horiz-o-chest"),
             ('focus', 'slider-horiz-ben'), ('readonly', 'slider-horiz-wheel'),
             ('selected', 'slider-horiz-wheelp'), {
                 'border': 3
             })
        },
        'Vertical.Scale.trough': {
            "element create": (
                'image',
                "trough-scale-vert",
            )
        },
        'Vertical.Scale.slider': {
            "element create":
            ('image', "slider-s-vert", ('background', "slider-s-vert-b"),
             ('invalid', "slider-s-vert-i"), ('selected', 'slider-s-vert-s'), {
                 'border': 3
             })
        }
        # end of theme extract - don't forget to add comma at end when inserting
    })
style = Style()
fact = font.Font(font="TkDefaultFont").metrics('linespace')
style.configure('font.Treeview', rowheight=fact,
              font=font.nametofont("TkDefaultFont"))
test_size = font.Font(family="Times", size=12, weight="bold").measure('Test')
mult = int(test_size / 30)
# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
     'Treeheading.cell': {"element create":
          ('image', "sail",
           ('selected', "sail-s"),
           ('disabled', "sail-d"),
           ('pressed', "sail-s"),
           ('active', "sail-p"),
           {'border':[30, 17, 27, 32], 'padding':[13,8,18,21], 'sticky': "nsew"} 
        ) },
       'Treeview': {'configure': {'bordercolor': colours['bordercolor']}}, 
         
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'
dataCols = ('Name', 'hash')
treeData = (('alice blue', '#F0F8FF'),('azure', '#F0FFFF'), ('brown4', '#8B2323'))
widg = Treeview(fr, columns=dataCols, show='headings',height=6*mult,
                style='font.Treeview')
for col in dataCols:
    widg.heading(col, text=col.title())
Example #15
0
class App(tk.Frame):
    def __init__(self, master):
        #graph object and changed variable to keep track of save-state
        self.graphObj = Graph()
        self.flowObj = Flow()
        self.changed = []

        #get the application window, set title and basic attributes
        tk.Frame.__init__(self, master, background="#1d1d1d")
        self.pack()
        self.master.title("gmath")
        self.master.resizable(True, True)
        self.master.tk_setPalette(background="#222222", foreground="#2ecc71")

        #basic universal behaviors
        #if window closed by window manager, exit safely
        self.master.protocol("WM_DELETE_WINDOW", self.click_exit)

        #set of keybindings
        self.master.bind("<Control_L><Escape>", self.click_exit)
        self.master.bind("<Control_L>1", self.dependent_active)
        self.master.bind("<Control_L>2", self.dependency_active)
        self.master.bind("<Control_L>a", self.add_button_active)
        self.master.bind("<Control_L>t", self.top_sort_button_active)
        self.master.bind("<Control_L>3", self.vertex_active)
        self.master.bind("<Alt_L>1", self.arc_node_active)
        self.master.bind("<Alt_L>2", self.arc_neighbor_active)
        self.master.bind("<Alt_L>3", self.arc_capacity_active)
        self.master.bind("<Alt_L>4", self.node_active)
        self.master.bind("<Control_L>A", self.add_vertex_active)
        self.master.bind("<Control_L>R", self.remove_vertex_active)
        self.master.bind("<Control_L>r", self.remove_button_active)
        self.master.bind("<Control_L>s", self.menu_save)
        self.master.bind("<Control_L>o", self.menu_open)
        self.master.bind("<Control_L>f", self.flow_tab_active)
        self.master.bind("<Control_L>d", self.dep_tab_active)

        #Menu bar
        menubar = tk.Menu(self, background="#1d1d1d", foreground="#2ecc71")

        #File menu in menu bar: open, save, exit
        filemenu = tk.Menu(menubar,
                           tearoff=0,
                           background="#1d1d1d",
                           foreground="#2ecc71")
        filemenu.add_command(label="Open", command=self.menu_open)
        filemenu.add_command(label="Save", command=self.menu_save)
        filemenu.add_separator()
        filemenu.add_command(label="Exit Ctrl+Esc", command=self.click_exit)
        menubar.add_cascade(label="File", menu=filemenu)

        #slap the menubar altogether
        self.master.config(menu=menubar)

        #tab panes and ttk styling for notebook
        self.style = Style()
        self.style.theme_create("gmath",
                                parent="alt",
                                settings={
                                    "TNotebook": {
                                        "configure": {
                                            "background": "#1d1d1d"
                                        }
                                    },
                                    "TNotebook.Tab": {
                                        "configure": {
                                            "background": "#1d1d1d",
                                            "foreground": "#2ecc71",
                                            "padding": [4, 2]
                                        },
                                        "map": {
                                            "background":
                                            [("selected", "#222222")]
                                        }
                                    }
                                })
        self.style.theme_use("gmath")
        self.tabs = Notebook(self)
        self.tabs.pack()

        #dependency graph frame inside notebook
        dep_graph_frame = tk.Frame(self.tabs)
        dep_graph_frame.pack()

        #manipulation frame in dependency graph frame
        manipulation_frame = tk.Frame(dep_graph_frame, borderwidth=0)
        manipulation_frame.pack(padx=0, pady=10)

        #edge frame in manipulation frame
        #contains dependent and dependency labels and entries and
        #add and remove buttons for edges
        edge_frame = tk.Frame(manipulation_frame, borderwidth=0)
        edge_frame.pack(padx=15, pady=15, side="left")
        dependent_frame = tk.Frame(edge_frame, borderwidth=0)
        dependent_frame.pack()
        dependency_frame = tk.Frame(edge_frame, borderwidth=0)
        dependency_frame.pack()
        tk.Label(dependent_frame, text="Dependent:  ").pack(side="left")
        tk.Label(dependency_frame, text="Dependency:").pack(side="left")
        self.dependent_entry = tk.Entry(dependent_frame)
        self.dependent_entry.pack(pady=5, side="left")
        self.dependent_entry.focus_set()
        self.dependency_entry = tk.Entry(dependency_frame)
        self.dependency_entry.pack(pady=5, side="left")
        self.add_button = tk.Button(edge_frame,
                                    text="Add Edge",
                                    command=self.add_edge)
        self.add_button.bind("<Return>", self.add_edge)
        self.add_button.pack(side="left")
        self.remove_button = tk.Button(edge_frame,
                                       text="Remove Edge",
                                       command=self.remove_edge)
        self.remove_button.bind("<Return>", self.remove_edge)
        self.remove_button.pack(side="left")
        self.remove_button['state'] = 'disabled'

        #vertex frame in manipulation frame
        #contains a label and entry for vertex and
        #add and remove buttons for the vertex
        vertex_frame = tk.Frame(manipulation_frame, borderwidth=0)
        vertex_frame.pack(padx=15, pady=15, side="left")
        vertex_entry_frame = tk.Frame(vertex_frame, borderwidth=0)
        vertex_entry_frame.pack()
        tk.Label(vertex_entry_frame, text="Vertex: ").pack(side="left")
        self.vertex_entry = tk.Entry(vertex_entry_frame)
        self.vertex_entry.pack(pady=5, side="left")
        vertex_button_frame = tk.Frame(vertex_frame, borderwidth=0)
        vertex_button_frame.pack()
        self.add_vertex_button = tk.Button(vertex_button_frame,
                                           text="Add Vertex",
                                           command=self.add_vertex)
        self.add_vertex_button.bind("<Return>", self.add_vertex)
        self.add_vertex_button.pack(side="left")
        self.remove_vertex_button = tk.Button(vertex_button_frame,
                                              text="Remove Vertex",
                                              command=self.remove_vertex)
        self.remove_vertex_button.bind("<Return>", self.remove_vertex)
        self.remove_vertex_button.pack(side="left")
        self.remove_vertex_button['state'] = 'disabled'

        #lists frame, contains listbox for edges and vertices
        lists_frame = tk.Frame(dep_graph_frame, borderwidth=0)
        lists_frame.pack(padx=15, pady=15)

        #edge list scrollable listbox
        edge_list_frame = tk.Frame(lists_frame, borderwidth=0)
        edge_list_frame.pack(side="left", padx=15)
        tk.Label(edge_list_frame, text="Edge List: ").pack(padx=5, pady=5)
        edge_scrollbar = tk.Scrollbar(edge_list_frame, orient="vertical")
        self.edge_list = tk.Listbox(edge_list_frame,
                                    selectmode='multiple',
                                    selectbackground="#2ecc71",
                                    selectforeground="#222222",
                                    yscrollcommand=edge_scrollbar.set,
                                    height=10,
                                    borderwidth=1)
        edge_scrollbar.config(command=self.edge_list.yview)
        edge_scrollbar.pack(side="right", fill="y")
        self.edge_list.bind("<Delete>", self.remove_edge_list)
        self.edge_list.pack(side="left", fill="y", expand=1)

        #vertex list scrollable listbox
        vertex_list_frame = tk.Frame(lists_frame, borderwidth=0)
        vertex_list_frame.pack(side="right", padx=15)
        tk.Label(vertex_list_frame, text="Vertex List: ").pack(padx=5, pady=5)
        vertex_scrollbar = tk.Scrollbar(vertex_list_frame, orient="vertical")
        self.vertex_list = tk.Listbox(vertex_list_frame,
                                      selectmode='multiple',
                                      selectbackground="#2ecc71",
                                      selectforeground="#222222",
                                      yscrollcommand=vertex_scrollbar.set,
                                      height=10,
                                      borderwidth=1)
        vertex_scrollbar.config(command=self.vertex_list.yview)
        vertex_scrollbar.pack(side="right", fill="y")
        self.vertex_list.bind("<Delete>", self.remove_vertex_list)
        self.vertex_list.pack(side="left", fill="y", expand=1)

        #function frame in dependency graph frame
        function_frame = tk.Frame(dep_graph_frame, borderwidth=0)
        function_frame.pack(padx=15, pady=15)

        #output frame in function frame
        output_frame = tk.Frame(function_frame, borderwidth=0)
        output_frame.pack()

        #basic outputs such as vertex count, edge count, and if cycle was detected
        basic_output_frame = tk.Frame(output_frame, borderwidth=0)
        basic_output_frame.pack(padx=15, pady=15, side="left")
        basic_output_vertices = tk.Frame(basic_output_frame, borderwidth=0)
        basic_output_vertices.pack()
        basic_output_edges = tk.Frame(basic_output_frame, borderwidth=0)
        basic_output_edges.pack()
        basic_output_cycle = tk.Frame(basic_output_frame, borderwidth=0)
        basic_output_cycle.pack()
        tk.Label(basic_output_vertices, text="Vertices: ").pack(padx=5,
                                                                pady=5,
                                                                side="left")
        self.vertices_label = tk.Label(basic_output_vertices, text="")
        self.vertices_label.pack(padx=10, pady=5, side="left")
        tk.Label(basic_output_edges, text="Edges: ").pack(padx=5,
                                                          pady=5,
                                                          side="left")
        self.edges_label = tk.Label(basic_output_edges, text="")
        self.edges_label.pack(padx=10, pady=5, side="left")
        tk.Label(basic_output_cycle, text="Cycle Detected: ").pack(padx=5,
                                                                   pady=5,
                                                                   side="left")
        self.cycle_label = tk.Label(basic_output_cycle, text="")
        self.cycle_label.pack(padx=10, pady=5, side="left")

        #topological sort frame with scrollable listbox and button to call top sort function
        output_top_sort_frame = tk.Frame(output_frame, borderwidth=0)
        output_top_sort_frame.pack(padx=15, pady=15, side="right")
        tk.Label(output_top_sort_frame, text="Topological Sort: ").pack(padx=5,
                                                                        pady=0)
        top_sort_list_frame = tk.Frame(output_top_sort_frame, borderwidth=0)
        top_sort_list_frame.pack(pady=15)
        top_sort_scrollbar = tk.Scrollbar(top_sort_list_frame,
                                          orient="vertical")
        self.top_sort_list = tk.Listbox(top_sort_list_frame,
                                        yscrollcommand=top_sort_scrollbar.set,
                                        height=10,
                                        borderwidth=1)
        top_sort_scrollbar.config(command=self.top_sort_list.yview)
        top_sort_scrollbar.pack(side="right", fill="y")
        self.top_sort_list.pack(side="left", fill="y", expand=1)
        self.top_sort_button = tk.Button(output_top_sort_frame,
                                         text="Topological Sort",
                                         command=self.topological_sort)
        self.top_sort_button.bind("<Return>", self.topological_sort)
        self.top_sort_button.pack()
        self.top_sort_button['state'] = 'disabled'

        #add dependency graph frame tab to the notebook tab frame
        self.tabs.add(dep_graph_frame, text="Dep Graph")

        #network flow frame
        flow_frame = tk.Frame(self.tabs)
        flow_frame.pack()

        #arc and node content containter
        arc_and_node_frame = tk.Frame(flow_frame, borderwidth=0)
        arc_and_node_frame.pack(padx=0, pady=10)

        #arc frame content
        arc_frame = tk.Frame(arc_and_node_frame, borderwidth=0)
        arc_frame.pack(padx=15, pady=15, side="left")
        arc_node_frame = tk.Frame(arc_frame, borderwidth=0)
        arc_node_frame.pack()
        arc_neighbor_frame = tk.Frame(arc_frame, borderwidth=0)
        arc_neighbor_frame.pack()
        arc_capacity_frame = tk.Frame(arc_frame, borderwidth=0)
        arc_capacity_frame.pack()
        tk.Label(arc_node_frame, text="Node:     ").pack(side="left")
        tk.Label(arc_neighbor_frame, text="Neighbor:").pack(side="left")
        tk.Label(arc_capacity_frame, text="Capacity:").pack(side="left")
        self.arc_node_entry = tk.Entry(arc_node_frame)
        self.arc_node_entry.pack(pady=5, side="left")
        self.arc_node_entry.focus_set()
        self.arc_neighbor_entry = tk.Entry(arc_neighbor_frame)
        self.arc_neighbor_entry.pack(pady=5, side="left")
        self.arc_capacity_entry = tk.Entry(arc_capacity_frame)
        self.arc_capacity_entry.pack(pady=5, side="left")
        self.add_arc_button = tk.Button(arc_frame,
                                        text="Add Edge",
                                        command=self.add_arc)
        self.add_arc_button.bind("<Return>", self.add_arc)
        self.add_arc_button.pack(side="left")
        self.remove_arc_button = tk.Button(arc_frame,
                                           text="Remove Edge",
                                           command=self.remove_arc)
        self.remove_arc_button.bind("<Return>", self.remove_arc)
        self.remove_arc_button.pack(side="left")
        self.remove_arc_button['state'] = 'disabled'

        #node frame content
        node_frame = tk.Frame(arc_and_node_frame, borderwidth=0)
        node_frame.pack(padx=15, pady=15, side="left")
        node_entry_frame = tk.Frame(node_frame, borderwidth=0)
        node_entry_frame.pack()
        tk.Label(node_entry_frame, text="Node: ").pack(side="left")
        self.node_entry = tk.Entry(node_entry_frame)
        self.node_entry.pack(pady=5, side="left")
        node_button_frame = tk.Frame(node_frame, borderwidth=0)
        node_button_frame.pack()
        self.add_node_button = tk.Button(node_button_frame,
                                         text="Add Node",
                                         command=self.add_node)
        self.add_node_button.bind("<Return>", self.add_node)
        self.add_node_button.pack(side="left")
        self.remove_node_button = tk.Button(node_button_frame,
                                            text="Remove Node",
                                            command=self.remove_node)
        self.remove_node_button.bind("<Return>", self.remove_node)
        self.remove_node_button.pack(side="left")
        self.remove_node_button['state'] = 'disabled'

        #lists frame, contains listbox for nodes and arcs
        flow_lists_frame = tk.Frame(flow_frame, borderwidth=0)
        flow_lists_frame.pack(padx=15, pady=15)

        #arc list scrollable listbox
        arc_list_frame = tk.Frame(flow_lists_frame, borderwidth=0)
        arc_list_frame.pack(side="left", padx=15)
        tk.Label(arc_list_frame, text="Arc List: ").pack(padx=5, pady=5)
        arc_scrollbar = tk.Scrollbar(arc_list_frame, orient="vertical")
        self.arc_list = tk.Listbox(arc_list_frame,
                                   selectmode='multiple',
                                   selectbackground="#2ecc71",
                                   selectforeground="#222222",
                                   yscrollcommand=edge_scrollbar.set,
                                   height=10,
                                   borderwidth=1)
        arc_scrollbar.config(command=self.arc_list.yview)
        arc_scrollbar.pack(side="right", fill="y")
        self.arc_list.bind("<Delete>", self.remove_arc_list)
        self.arc_list.pack(side="left", fill="y", expand=1)

        #node list scrollable listbox
        node_list_frame = tk.Frame(flow_lists_frame, borderwidth=0)
        node_list_frame.pack(side="right", padx=15)
        tk.Label(node_list_frame, text="Node List: ").pack(padx=5, pady=5)
        node_scrollbar = tk.Scrollbar(node_list_frame, orient="vertical")
        self.node_list = tk.Listbox(node_list_frame,
                                    selectmode='multiple',
                                    selectbackground="#2ecc71",
                                    selectforeground="#222222",
                                    yscrollcommand=vertex_scrollbar.set,
                                    height=10,
                                    borderwidth=1)
        node_scrollbar.config(command=self.node_list.yview)
        node_scrollbar.pack(side="right", fill="y")
        self.node_list.bind("<Delete>", self.remove_node_list)
        self.node_list.pack(side="left", fill="y", expand=1)

        #flow output frame
        flow_output_frame = tk.Frame(flow_frame, borderwidth=0)
        flow_output_frame.pack(padx=15, pady=15)

        flow_output_nodes = tk.Frame(flow_output_frame, borderwidth=0)
        flow_output_nodes.pack()
        flow_output_arcs = tk.Frame(flow_output_frame, borderwidth=0)
        flow_output_arcs.pack()
        flow_output_max = tk.Frame(flow_output_frame, borderwidth=0)
        flow_output_max.pack()
        tk.Label(flow_output_nodes, text="Nodes: ").pack(padx=5,
                                                         pady=5,
                                                         side="left")
        self.nodes_label = tk.Label(flow_output_nodes, text="")
        self.nodes_label.pack(padx=10, pady=5, side="left")
        tk.Label(flow_output_arcs, text="Arcs: ").pack(padx=5,
                                                       pady=5,
                                                       side="left")
        self.arcs_label = tk.Label(flow_output_arcs, text="")
        self.arcs_label.pack(padx=10, pady=5, side="left")
        tk.Label(flow_output_max, text="Maximum Flow: ").pack(padx=5,
                                                              pady=5,
                                                              side="left")
        self.max_label = tk.Label(flow_output_max, text="")
        self.max_label.pack(padx=10, pady=5, side="left")

        self.tabs.add(flow_frame, text="Flow Graph")

        #update the geometry of the master frame
        self.master.geometry()
        self.master.update()

        #setup to put screen centered horizontally and starting at top third vertically
        x = int(
            (self.master.winfo_screenwidth() - self.master.winfo_width()) / 2)
        y = int(
            (self.master.winfo_screenheight() - self.master.winfo_height()) /
            3)
        self.master.geometry("{}x{}+{}+{}".format(self.master.winfo_width(),
                                                  self.master.winfo_height(),
                                                  x, y))

    def add_edge(self, event=None):
        ''' simple add edge to graph '''
        dependency_text = self.dependency_entry.get()
        dependent_text = self.dependent_entry.get()
        if dependency_text != "" and dependent_text != "" and dependency_text != dependent_text:
            if self.graphObj.add_edge(dependent_text, dependency_text):
                if 'dpg' not in self.changed:
                    self.changed.append('dpg')
                self.dependency_entry.delete(0, 'end')
                self.dependent_entry.delete(0, 'end')
                self.graphObj.is_cyclic()
                self.edge_list.insert(
                    tk.END,
                    str(dependent_text) + " -> " + str(dependency_text))
                self.update_output_labels()
                self.change_button_state()
                self.update_dep_lists()

    def add_arc(self, event=None):
        '''  add an arc to the flow '''
        arc_node_text = self.arc_node_entry.get()
        arc_neighbor_text = self.arc_neighbor_entry.get()
        arc_capacity_text = self.arc_capacity_entry.get()
        if arc_node_text != '' and arc_neighbor_text != '' and arc_capacity_text.isnumeric(
        ) and float(
                arc_capacity_text) >= 0 and arc_node_text != arc_neighbor_text:
            self.flowObj.add_arc(arc_node_text, arc_neighbor_text,
                                 float(arc_capacity_text))
            self.update_flow_labels()
            self.node_list.delete(0, 'end')
            for e in self.flowObj.nodes():
                self.node_list.insert(tk.END, str(e))
            self.arc_list.insert(
                tk.END,
                str(arc_node_text) + " -(" + str(arc_capacity_text) + ")-> " +
                str(arc_neighbor_text))
            self.arc_node_entry.delete(0, 'end')
            self.arc_neighbor_entry.delete(0, 'end')
            self.arc_capacity_entry.delete(0, 'end')
            if 'flw' not in self.changed:
                self.changed.append('flw')
            self.change_button_state()

    def remove_edge(self, event=None):
        ''' simple remove edge from graph '''
        dependency_text = self.dependency_entry.get()
        dependent_text = self.dependent_entry.get()
        if dependency_text != "" and dependent_text != "":
            if self.graphObj.remove_edge(dependent_text, dependency_text):
                self.graphObj.is_cyclic()
                if 'dpg' not in self.changed:
                    self.changed.append('dpg')
                self.dependency_entry.delete(0, 'end')
                self.dependent_entry.delete(0, 'end')
                self.update_output_labels()
                self.change_button_state()
                self.update_dep_lists()

    def remove_edge_list(self, event=None):
        ''' remove selected edges from edge list listbox '''
        selections = [
            self.edge_list.get(x).split("->")
            for x in self.edge_list.curselection()
        ]
        #edge_sel = [x.strip() for x in "".split("->")]
        values = []
        for y in selections:
            values.append([y[0].strip(), y[1].strip()])
        for e in values:
            if self.graphObj.remove_edge(e[0], e[1]):
                if 'dpg' not in self.changed:
                    self.changed.append('dpg')
                self.graphObj.is_cyclic()
                self.update_output_labels()
                self.change_button_state()
        self.graphObj.is_cyclic()
        self.update_output_labels()
        self.change_button_state()
        self.update_dep_lists()

    def remove_arc(self, event=None):
        '''  '''
        arc_node_text = self.arc_node_entry.get()
        arc_neighbor_text = self.arc_neighbor_entry.get()
        if arc_node_text != '' and arc_neighbor_text != '':
            if self.flowObj.remove_arc(arc_node_text, arc_neighbor_text):
                self.update_flow_labels()
                if 'flw' not in self.changed:
                    self.changed.append('flw')
                self.arc_list.delete(0, 'end')
                for e in self.flowObj.arcs():
                    self.arc_list.insert(
                        tk.END,
                        str(e[0]) + " -(" + str(e[2]) + ")-> " + str(e[1]))
                self.arc_node_entry.delete(0, 'end')
                self.arc_neighbor_entry.delete(0, 'end')
                self.arc_capacity_entry.delete(0, 'end')
                self.change_button_state()

    def remove_arc_list(self, event=None):
        '''  '''
        selections = [
            self.arc_list.get(x).split("-")
            for x in self.arc_list.curselection()
        ]
        values = []
        for y in selections:
            values.append([y[0].strip(), y[2][1:].strip()])
        for e in values:
            if self.flowObj.remove_arc(e[0], e[1]):
                if 'flw' not in self.changed:
                    self.changed.append('flw')
                self.update_flow_labels()
                self.change_button_state()
                self.update_flow_lists()

    def add_vertex(self, event=None):
        ''' simple add vertex to graph '''
        vertex_text = self.vertex_entry.get()
        if vertex_text != "":
            if self.graphObj.add_vertex(vertex_text):
                self.vertex_list.insert(tk.END, str(vertex_text))
                if 'dpg' not in self.changed:
                    self.changed.append('dpg')
                self.vertex_entry.delete(0, 'end')
                self.update_output_labels()
                self.change_button_state()

    def add_node(self, event=None):
        '''  '''
        node_text = self.node_entry.get()
        if node_text != '':
            if self.flowObj.add_node(node_text):
                if 'flw' not in self.changed:
                    self.changed.append('flw')
                self.node_entry.delete(0, 'end')
                self.change_button_state()
                self.update_flow_labels()
                self.node_list.insert(tk.END, str(node_text))

    def remove_vertex(self, event=None):
        ''' simple remove vertex from graph '''
        vertex_text = self.vertex_entry.get()
        if vertex_text != "":
            if self.graphObj.remove_vertex(vertex_text):
                if 'dpg' not in self.changed:
                    self.changed.append('dpg')
                self.vertex_entry.delete(0, 'end')
                self.graphObj.is_cyclic()
                self.update_output_labels()
                self.change_button_state()
                self.update_dep_lists()

    def remove_vertex_list(self, event=None):
        ''' removes all selected vertices from vertex listbox '''
        values = [
            self.vertex_list.get(x).strip()
            for x in self.vertex_list.curselection()
        ]
        for v in values:
            if self.graphObj.remove_vertex(v):
                if 'dpg' not in self.changed:
                    self.changed.append('dpg')
                self.graphObj.is_cyclic()
                self.update_output_labels()
                self.change_button_state()
        self.graphObj.is_cyclic()
        self.update_output_labels()
        self.change_button_state()
        self.update_dep_lists()

    def remove_node(self, event=None):
        '''  '''
        node_text = self.node_entry.get()
        if node_text != '':
            if self.flowObj.remove_node(node_text):
                self.update_flow_labels()
                if 'flw' not in self.changed:
                    self.changed.append('flw')
                self.node_entry.delete(0, 'end')
                self.change_button_state()
                self.update_flow_lists()

    def remove_node_list(self, event=None):
        '''  '''
        values = [
            self.node_list.get(x).strip()
            for x in self.node_list.curselection()
        ]
        for v in values:
            if self.flowObj.remove_node(v):
                if 'flw' not in self.changed:
                    self.changed.append('flw')
                self.update_flow_labels()
                self.change_button_state()
                self.update_flow_lists()

    def topological_sort(self):
        ''' outputs the topological sort in scrollable listbox in order '''
        if not self.graphObj.cycle_detected():
            self.top_sort_list.delete(0, 'end')
            for v in self.graphObj.topological_sort():
                self.top_sort_list.insert(tk.END, str(v))

    def click_exit(self, event=None):
        ''' exit program safely by asking if they want to save changes '''
        if len(self.changed) == 0:
            self.master.destroy()
        else:
            if 'dpg' in self.changed:
                graph_result = True
                while graph_result and 'dpg' in self.changed:
                    graph_result = askokcancel(
                        "Python",
                        "Would you like to save your changes to the dependency graph?"
                    )
                    if graph_result:
                        self.menu_save()
            if 'flw' in self.changed:
                graph_result = True
                while graph_result and 'flw' in self.changed:
                    graph_result = askokcancel(
                        "Python",
                        "Would you like to save your changes to the flow network?"
                    )
                    if graph_result:
                        self.menu_save()
            self.master.destroy()

    def menu_save(self, event=None):
        ''' opens a "save as" dialog to save the graph '''
        filename = asksaveasfilename(initialdir=".",
                                     title="Select file",
                                     filetypes=(("Dependency Graph", "*.dpg"),
                                                ("Flow Network", "*.flw")))
        try:
            with open(filename, 'wb') as output:
                if filename[-3:] == 'dpg':
                    pickle.dump(self.graphObj, output, pickle.HIGHEST_PROTOCOL)
                    self.changed.remove('dpg')
                elif filename[-3:] == 'flw':
                    pickle.dump(self.flowObj, output, pickle.HIGHEST_PROTOCOL)
                    self.changed.remove('flw')
                else:
                    raise
        except:
            print("Something went terribly wrong")

    def menu_open(self, event=None):
        ''' opens an "open file" dialog to open a graph file '''
        filename = askopenfilename(initialdir=".",
                                   title="Select file",
                                   filetypes=(("Dependency Graph", "*.dpg"),
                                              ("Flow Network", "*.flw")))
        try:
            if filename[-3:] == 'dpg' and 'dpg' in self.changed:
                result = askokcancel(
                    "Python",
                    "Would you like to save your changes to the dependency graph?"
                )
                while result == True:
                    self.menu_save()
                    if 'dpg' in self.changed:
                        result = askokcancel(
                            "Python",
                            "Would you like to save your changes to the dependency graph?"
                        )
                    else:
                        result = False
            elif filename[-3:] == 'flw' and 'flw' in self.changed:
                result = askokcancel(
                    "Python",
                    "Would you like to save your changes to the flow network?")
                while result == True:
                    self.menu_save()
                    if 'flw' in self.changed:
                        result = askokcancel(
                            "Python",
                            "Would you like to save your changes to the flow network?"
                        )
                    else:
                        result = False
            with open(filename, 'rb') as inputf:
                if filename[-3:] == 'dpg':
                    self.graphObj = pickle.load(inputf)
                    self.update_output_labels()
                    self.change_button_state()
                    self.update_dep_lists()
                    if 'dpg' in self.changed:
                        self.changed.remove('dpg')
                elif filename[-3:] == 'flw':
                    self.flowObj = pickle.load(inputf)
                    self.update_flow_labels()
                    self.change_button_state()
                    self.update_flow_lists()
                    if 'flw' in self.changed:
                        self.changed.remove('flw')
        except:
            print("Something went terribly wrong")

    def update_dep_lists(self):
        '''  '''
        self.vertex_list.delete(0, 'end')
        for e in self.graphObj.vertices():
            self.vertex_list.insert(tk.END, str(e))
        self.edge_list.delete(0, 'end')
        for e in self.graphObj.edges():
            self.edge_list.insert(tk.END, str(e[0]) + " -> " + str(e[1]))
        self.topological_sort()

    def update_flow_lists(self):
        '''  '''
        self.node_list.delete(0, 'end')
        for e in self.flowObj.nodes():
            self.node_list.insert(tk.END, str(e))
        self.arc_list.delete(0, 'end')
        for e in self.flowObj.arcs():
            self.arc_list.insert(
                tk.END,
                str(e[0]) + " -(" + str(e[2]) + ")-> " + str(e[1]))

    def update_output_labels(self):
        ''' update the vertex and edge count labels and the cycle detected label '''
        self.vertices_label['text'] = str(self.graphObj.order())
        self.edges_label['text'] = str(self.graphObj.size())
        self.cycle_label['text'] = str(self.graphObj.cycle_detected())

    def update_flow_labels(self):
        ''' update arc and node count labels and max flow label '''
        self.nodes_label['text'] = str(self.flowObj.order())
        self.arcs_label['text'] = str(self.flowObj.size())
        mf = self.flowObj.max_flow()
        if mf != False:
            self.max_label['text'] = str(mf)
        else:
            self.max_label['text'] = 'Insufficient conditions'

    def change_button_state(self):
        ''' enable and disable buttons according to their ability to be used
            based on the current state of the graph
        '''
        if self.graphObj.order() > 0:
            self.top_sort_button['state'] = 'normal'
            self.remove_vertex_button['state'] = 'normal'
        else:
            self.top_sort_button['state'] = 'disabled'
            self.remove_vertex_button['state'] = 'disabled'
        if self.graphObj.size() > 0:
            self.remove_button['state'] = 'normal'
        else:
            self.remove_button['state'] = 'disabled'
        if self.flowObj.order() > 0:
            self.remove_node_button['state'] = 'normal'
        else:
            self.remove_node_button['state'] = 'disabled'
        if self.flowObj.size() > 0:
            self.remove_arc_button['state'] = 'normal'
        else:
            self.remove_arc_button['state'] = 'disabled'

    def dependency_active(self, event=None):
        ''' set dependency text entry field active '''
        self.dependency_entry.focus_set()

    def dependent_active(self, event=None):
        ''' set dependent text entry field active '''
        self.dependent_entry.focus_set()

    def arc_node_active(self, event=None):
        ''' set arc node text entry field active '''
        self.arc_node_entry.focus_set()

    def arc_neighbor_active(self, event=None):
        ''' set arc neighbor text entry field active '''
        self.arc_neighbor_entry.focus_set()

    def arc_capacity_active(self, event=None):
        ''' set arc capacity text entry field active '''
        self.arc_capacity_entry.focus_set()

    def add_button_active(self, event=None):
        ''' set add edge button active and add edge '''
        self.add_button.focus_set()
        self.add_edge()

    def remove_button_active(self, event=None):
        ''' set remove edge button active and remove edge '''
        self.remove_button.focus_set()
        self.remove_edge()

    def add_vertex_active(self, event=None):
        ''' set add vertex button active and add vertex '''
        self.add_vertex_button.focus_set()
        self.add_vertex()

    def remove_vertex_active(self, event=None):
        ''' set the remove vertex button active and call remove vertex '''
        self.remove_vertex_button.focus_set()
        self.remove_vertex()

    def vertex_active(self, event=None):
        ''' set the vertex entry field active '''
        self.vertex_entry.focus_set()

    def node_active(self, event=None):
        ''' set the node entry field active '''
        self.node_entry.focus_set()

    def top_sort_button_active(self, event=None):
        ''' set the topological sort button active and call topological sort '''
        self.top_sort_button.focus_set()
        self.topological_sort()

    def dep_tab_active(self, event=None):
        ''' show the dependency graph tab '''
        self.tabs.select(0)

    def flow_tab_active(self, event=None):
        ''' show the flow network tab '''
        self.tabs.select(1)
Example #16
0
img3 = PhotoImage("tab-p", file='../images/lime/tab-px.png')
img4 = PhotoImage("tab-h", file='../images/lime/tab-hx.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
        # tabmargins allow enough space for expand
    'TNotebook': {'configure': {'tabmargins': [0,3,0,0]}}, # [2,7,5,5]
    'TNotebook.tab': {
        'configure': { 'foreground': '#8b0a50'},
        "map":  
        {'expand': [('selected', [0,3,0,0]),('!selected', [0,0,2])]}}, 
         
    
     'tab': {"element create":
          ('image', "tab-n",
           ('active', "tab-h"),
           ('selected', "tab-p"),
           ('disabled', "tab-d"),
           {'border':[4, 15, 4, 15], 'padding':[7,3],'sticky': "nsew"} # ,'height':12 
        ) }
        
         
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'
widg = Notebook(fr)
page1 = Frame(widg, width=150, height=150)
page2 = Frame(widg, width=150, height=150)
style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Treeheading.cell': {
            "element create": ('image', "slider-hn", ('pressed', "slider-hp"),
                               ('active', "slider-ha"), ('focus', "slider-ha"),
                               ('disabled', "slider-hd"), {
                                   'border': [4, 12, 4, 12],
                                   'padding': 4,
                                   'sticky': "nsew"
                               })
        },
        'Treeview': {
            'map': {
                'background': [('selected', colours['selectbg'])],
                'foreground': [('selected', colours['selectfg'])]
            }
        }

        #'Treeview': {'configure': {'bordercolor': colours['bordercolor']}},

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

style.theme_use('yummy')  # 'default'
dataCols = ('Name', 'hash')
Example #18
0
img2 = PhotoImage("combo-p", file='../figures/09combo.png')
img9 = PhotoImage("comboarrow-n", file='../images/comboarrow-n.png')
img11 = PhotoImage("comboarrow-p", file='../figures/09comboarrow5.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        "Combobox.field": {
            "element create": ("image", 'combo-p', ('alternate', 'combo-n'), {
                'sticky': 'ew',
                'border': [4]
            })
        },
        "Combobox.downarrow": {
            "element create":
            ("image", 'comboarrow-p', ('alternate', 'comboarrow-n'), {
                'sticky': '',
                'border': [1]
            })
        }
    })

style.theme_use('yummy')  # 'clam' 'yummy'
sv = StringVar()
widg = Combobox(fr, values=['ubuntu', 'banana', 'orange'])
widg.grid(column=0, row=10, padx=5, pady=5)
sv.set('ubuntu')
class UI(Frame):
	def __init__(self):
		super().__init__()

		# Variables
		self.currentTimeSheet = ""
		self.currentEmployee = ""

		# Config
		self.master.title(AccountConfig['Name'])
		self.master.geometry("450x500")
		#self.master.resizable(width = False, height = False)
		self.master.configure(background = '#f2f2f2')
		self.master.option_add('*tearOff', False)
		self.combostyle = Style()
		self.combostyle.theme_create('combostyle', parent='alt', settings = {'TCombobox': {'configure': {'selectforeground': '#3b3b3b', 'selectbackground': '#ffffff', 'fieldbackground': '#ffffff', 'background': '#ffffff'}}})
		self.combostyle.theme_use('combostyle')
		self.build()

	def build(self):
		# Variables
		menu = Menu(self.master)
		dataMenu = Menu(menu)
		removeMenu = Menu(dataMenu)
		newSubMenu = Menu(dataMenu)
		removeSubMenu = Menu(removeMenu)
		exportSubMenu = Menu(menu)

		# Attributes
		exportSubMenu.add_command(label = "Timesheet", command = self.exportPopup)
		newSubMenu.add_command(label = "Employee", command = self.createEmployeePopup)
		newSubMenu.add_command(label = "Month", command = self.createTimesheetPopup)
		removeSubMenu.add_command(label = "Employee", command = self.removeEmployeePopup)
		dataMenu.add_cascade(label = 'New', menu = newSubMenu, underline = 0)
		dataMenu.add_cascade(label = 'Remove', menu = removeSubMenu, underline = 0)
		menu.add_cascade(label = "Data", underline = 0, menu = dataMenu)
		menu.add_cascade(label = "Export", underline = 0, menu = exportSubMenu)

		# UI
		self.master.config(menu = menu)
		self.buildUI()

	def buildUI(self):
		# Variables
		topFrame = Frame(window)
		statusFrame = Frame(topFrame, bg = "#3b3b3b")
		inputFrame = Frame(topFrame, bg = UIConfig['Color_Blue'])
		status = Label(statusFrame, text = getHeaderText(), height = "2", background = "#3b3b3b", fg = "#ffffff", anchor = "w", padx = 8, font=("Sans-serif", 11, "normal"))
		self.TSSelect = Combobox(inputFrame, values = getTimesheets(True), state = "readonly", height = "4", width = "10")
		self.employeeSelect = Combobox(inputFrame, values = getEmployees(True), state = "readonly", height = "4", width = "38")
		self.scrollFrame = self.buildFrame()

		# Attributes
		status.grid(column = 0, columnspan = 2, row = 0)
		self.TSSelect.grid(column = 0, row = 1, pady = 16, padx = 8, sticky = "w")
		self.employeeSelect.grid(column = 1, row = 1, pady = 16, padx = 8, sticky = "w")
		statusFrame.pack(side = "top", fill = "x", expand = True, anchor = "n")
		inputFrame.pack(side = "top", fill = "x", expand = True, anchor = "n")
		topFrame.pack(side = "top", fill = "x", expand = True, anchor = "n")
		self.TSSelect.current(0)
		self.employeeSelect.current(0)

		# Events
		self.TSSelect.bind("<<ComboboxSelected>>", self.selectTimeSheet)
		self.employeeSelect.bind("<<ComboboxSelected>>", self.selectEmployee)

	def buildFrame(self):
		# Variables
		sf = ScrollFrame(window, "#f2f2f2")

		# Events
		sf.canvas.bind_all("<MouseWheel>", self.mw)
		sf.canvas.bind_all("<Button-4>", self.mw)
		sf.canvas.bind_all("<Button-5>", self.mw)

		# Return
		return sf

	def mw(self, event):
		# Checks
		if (event.num and event.num == 5):
			self.scrollFrame.canvas.yview_scroll(1, "units")
		elif (event.num and event.num == 4):
			self.scrollFrame.canvas.yview_scroll(-1, "units")
		elif (event.delta and event.delta < 0):
			self.scrollFrame.canvas.yview_scroll(1, "units")
		elif (event.delta and event.delta > 0):
			self.scrollFrame.canvas.yview_scroll(-1, "units")

	def focus(self, event):
		# Checks
		if (not event): return False
		if (not event.widget): return False
		if (not event.widget.get()): return False
		if (event.widget.get().lower() in ["start time", "end time"]):
			event.widget.delete(0, END)

	def blur(self, event, type = 0):
		# Checks
		if (not event): return False
		if (not event.widget): return False
		if (len(event.widget.get().strip()) <= 0):
			event.widget.insert(0, ("Start time" if type == 0 else "End time"))

	def selectTimeSheet(self, event):
		# Checks
		if (not self.TSSelect.get()): return False
		if (self.TSSelect.get().lower() == "month"): return False

		self.currentTimeSheet = self.TSSelect.get()

	def selectEmployee(self, event):
		# Checks
		if (not self.employeeSelect.get()): return False
		if (self.employeeSelect.get().lower() == ""): return False
		if (self.employeeSelect.get().lower() == "select a employee"): return False

		# Variables
		row = 0
		self.currentEmployee = self.employeeSelect.get()
		self.scrollFrame.pack_forget()
		self.scrollFrame = self.buildFrame()
		self.scrollFrame.pack(side = "top", fill = "both", expand = True)

		# Loops
		for date in calendar.itermonthdates(currentYear, currentMonth):
			# Checks
			if (not date.month == currentMonth): continue
			if (date.weekday() in AccountConfig['SkipDays']): continue

			# Variables
			bg = "#f2f3f5" if (row % 2 == 0) else "#ffffff"
			frame = Frame(self.scrollFrame.viewPort, bg = bg, bd = 1, relief = "solid")
			topFrame = Frame(frame, bg = bg)
			middleFrame = Frame(frame, bg = bg)
			bottomFrame = Frame(frame, bg = bg)
			date = Label(topFrame, text = date.strftime("%a, %B %d %Y"), height = "2", fg = "#3b3b3b", bg = bg, font=("Sans-serif", 11, "normal"))
			start = Entry(middleFrame)
			end = Entry(middleFrame)
			commentLabel = Label(bottomFrame, text = "Date Comments", height = "2", fg = "#3b3b3b", bg = bg, anchor = "w", font=("Sans-serif", 9, "normal"))
			comment = Text(bottomFrame, height = 2)

			# Attributes
			start.insert(0, "Start time")
			end.insert(0, "End time")
			date.grid(column = 0, row = 0, pady = 0, padx = 8, sticky = "w")
			start.grid(column = 0, row = 0, pady = 8, padx = 8, sticky = "w")
			end.grid(column = 1, row = 0, pady = 8, padx = 8, sticky = "w")
			commentLabel.pack(side = "top", fill = "x", expand = True, anchor = "w") #grid(column = 0, row = 0)
			comment.pack() #grid(column = 0, row = 1, pady = (0, 8), padx = 8)
			topFrame.pack(side = "top", fill = "x", expand = True)
			middleFrame.pack(side = "top", fill = "x", expand = True)
			bottomFrame.pack(side = "top", fill = "x", expand = True)
			frame.pack(side = "top", fill = "x", expand = True, anchor = "n")

			# Events
			start.bind("<FocusIn>", self.focus)
			start.bind("<FocusOut>", lambda e: self.blur(e, 0))
			end.bind("<FocusIn>", self.focus)
			end.bind("<FocusOut>", lambda e: self.blur(e, 1))

			# Increment
			row = row+1

	def exportPopup(self):
		print("Present month & employee selection, then build pdf")

	def createEmployeePopup(self):
		# Functions
		def create():
			if (not textbox.get(1.0, 25.0)): return False
			if (not len(textbox.get(1.0, 25.0).strip()) > 0): return False
			createEmployee(textbox.get(1.0, 25.0).strip())
			popup.destroy()
			self.buildUI()

		# Variables
		popup = self.createPopup("Create Employee")
		status = Label(popup, text = "Create new employee", width = UIConfig['PopupWidthPX'], height = "2", background = "#3b3b3b", fg = "#ffffff", anchor = "w")
		textbox = Text(popup, width = str(UIConfig['PopupWidthPX'] - 3), height = 2)
		btn = Button(popup, text = "Create", width = str(UIConfig['PopupWidthPX'] - 6), command = create)

		# Attributes
		status.grid(column = 0, row = 0)
		textbox.grid(column = 0, row = 1, pady = 8, padx = 8, sticky = "w")
		btn.grid(column = 0, row = 2, pady = 8, padx = 8, sticky = "w")

	def removeEmployeePopup(self):
		pass

	def createTimesheetPopup(self):
		# Functions
		def create():
			if (not monthSelect.get()): return False
			if (not yearSelect.get()): return False
			if (monthSelect.get().lower() == "month"): return False
			if (yearSelect.get().lower() == "year"): return False

			createTimesheet(monthSelect.get(), yearSelect.get())
			popup.destroy()
			self.buildUI()

		# Variables
		months = getMonths()
		years = getYears()
		popup = self.createPopup("Create Timesheet")
		status = Label(popup, text = "Create new timesheet", width = UIConfig['PopupWidthPX'], height = "2", background = "#3b3b3b", fg = "#ffffff", anchor = "w")
		employeeSelectFrame = Frame(popup, bg = "#f2f2f2")
		monthSelect = Combobox(employeeSelectFrame, values = months[0], state = "readonly", height = "4", width = UIConfig['PopupWidthPX'] - 19)
		yearSelect = Combobox(employeeSelectFrame, values = years[0], state = "readonly", height = "4", width = 10)
		btn = Button(popup, text = "Create", width = str(UIConfig['PopupWidthPX'] - 6), command = create)

		# Attributes
		status.grid(column = 0, row = 0)
		monthSelect.grid(column = 0, row = 1, pady = 16, padx = 8, sticky = "w")
		monthSelect.current(months[1])
		yearSelect.grid(column = 1, row = 1, pady = 16, padx = 8, sticky = "w")
		yearSelect.current(years[1])
		employeeSelectFrame.grid(column = 0, row = 1, pady = 0, padx = 0, sticky = "w")
		btn.grid(column = 0, row = 2, pady = 8, padx = 8, sticky = "w")

	def createPopup(self, title):
		# Variables
		popup = Toplevel()

		# Attributes
		popup.title(title)
		popup.geometry("350x150")
		popup.resizable(width = False, height = False)
		popup.configure(background = '#f2f2f2')
		popup.lift()
		popup.focus_force()
		popup.attributes('-topmost', True)

		return popup
chart1Canvas.get_tk_widget().grid(row=0, column=0)
chart1Canvas.mpl_connect('button_press_event', lambda event: showFig(event, 1))

chart2Canvas = FigureCanvasTkAgg(chart2Fig, chart2Frame)
chart2Canvas._tkcanvas.grid(row=0, column=0)
chart2Canvas.get_tk_widget().grid(row=0, column=0)
chart2Canvas.mpl_connect('button_press_event', lambda event: showFig(event, 2))

#create combobox sytle
combostyle = Style()
combostyle.theme_create('combostyle',
                        parent='alt',
                        settings={
                            'TCombobox': {
                                'configure': {
                                    'selectbackground': 'red',
                                    'fieldbackground': 'red',
                                    'background': 'white'
                                }
                            }
                        })
combostyle.theme_use('combostyle')

#add selection boxes
mapChoices = [
    'Map', 'Altitude', 'Battery Temp', '3V3 Rail Voltage', '5V Rail Voltage',
    'VBATT'
]
chartChoices = [
    'Altitude', 'Battery Temp', '3V3 Rail Voltage', '5V Rail Voltage', 'VBATT',
    'Acceleration', 'Pressure'
img1 = PhotoImage("entry-n", file='../images/piratz/entry-n.png')
img2 = PhotoImage("entry-f", file='../images/piratz/entry-f.png')
img3 = PhotoImage("entry-d", file='../images/piratz/entry-d.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Entry.field': {
            "element create": ('image', "entry-n", ('focus', 'entry-f'),
                               ('disabled', 'entry-d'), {
                                   'height': 18,
                                   'border': [10, 10],
                                   'padding': [5, 4],
                                   'sticky': 'nsew'
                               })
        }

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

style.theme_use('yummy')  # 'default'
sv = StringVar()
widg = Entry(fr, textvariable=sv)
widg.grid(column=0, row=10, padx=5, pady=5)
sv.set('first')
sv1 = StringVar()
Example #22
0
style.theme_create( "yummy", parent="clam", settings={
    #style.theme_settings('default', {
    # start of theme extract
        "Horizontal.TScrollbar": {"layout": [
            ("Horizontal.Scrollbar.trough", { "children": # "sticky": "ew",
                 [("Horizontal.Scrollbar.leftarrow", {"side": "left"}),
                 ("Horizontal.Scrollbar.rightarrow", {"side": "right"}),
                 ("Horizontal.Scrollbar.thumb", {"side": "left","expand": 1,"sticky": "ew"})]
            })]},

     "Horizontal.Scrollbar.thumb": {"element create":
            ("image", 'slider-hn',
             ('disabled', 'slider-hd'),
             ('pressed', 'slider-hp'),
             ('active', 'slider-ha'),
             {"border": 3}) #[9,2] , 'sticky': 'ew', 'padding': [7,2] 
        },

     'Scrollbar.leftarrow': {"element create":
            ("image", 'arrowleft-n',
             ('disabled', 'arrowleft-d'),
             ('pressed', 'arrowleft-p'),
             ('active', 'arrowleft-a'),
             {"border": 1})
            },

     'Scrollbar.rightarrow': {"element create":
            ("image", 'arrowright-n',
             ('disabled', 'arrowright-d'),
             ('pressed', 'arrowright-p'),
             ('active', 'arrowright-a'),
             {"border": 1})
            },

     "Vertical.TScrollbar": {"layout": [
            ("Vertical.Scrollbar.trough", {"sticky": "ns", "children":
                 [("Vertical.Scrollbar.uparrow", {"side": "top"}),
                 ("Vertical.Scrollbar.downarrow", {"side": "bottom"}),
                 ("Vertical.Scrollbar.thumb", {"side": "top","expand": 1,"sticky": "ns"})]
            })]},

     "Vertical.Scrollbar.thumb": {"element create":
            ("image", 'slider-vn',
             ('disabled', 'slider-vd'),
             ('pressed', 'slider-vp'),
             ('active', 'slider-va'),
             {"border": [2,9]})
        },

     'Scrollbar.uparrow': {"element create":
            ("image", 'arrowup-n',
             ('disabled', 'arrowup-d'),
             ('pressed', 'arrowup-p'),
             ('active', 'arrowup-a'),
             {"border": 1})
            },

     'Scrollbar.downarrow': {"element create":
            ("image", 'arrowdown-n',
             ('disabled', 'arrowdown-d'),
             ('pressed', 'arrowdown-p'),
             ('active', 'arrowdown-a'),
             {"border": 1})
            },

    'TCombobox': {
        'configure': {'selectborderwidth': 1, 'padding': 2,
                      'insertwidth': 2, 'font': 'TkTextFont'}}

    # end of theme extract - don't forget to add comma at end when inserting
     })
fr = Frame(root)
fr.grid(column=0, row=0, sticky='nsew')

img2 = PhotoImage("frame-d", file='../images/piratz/frame-d.png')
img1 = PhotoImage("frame", file='../images/piratz/frame.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Labelframe.border': {
            "element create": ('image', "frame", ('disabled', "frame-d"), {
                'border': 5,
                'sticky': "nsew"
            })
        }  #'padding':5,
        # end of theme extract - don't forget to add comma at end when inserting
    })

style.theme_use('yummy')  # 'default'
widg = LabelFrame(fr, text='Piratz!')
widg.grid(column=0, row=11, sticky='nsew', padx=5, pady=5, ipadx=5, ipady=5)
f0 = Label(widg, text='Something to say')
f0.grid()
widg1 = LabelFrame(fr, text='Piratz!\nextra line')
widg1.grid(column=0, row=12, sticky='nsew', padx=5, pady=5, ipadx=5,
           ipady=5)  #  ipadx=5, ipady=5
Example #24
0
state_val = StringVar()
for iy, state in enumerate(states):
    st_rb = Radiobutton(fr, value=state, text=state,
            variable=state_val, command=change_state)
    st_rb.grid(column=0,row=iy,padx=5,pady=5, sticky='nw')

img1 = PhotoImage("label", file='../images/piratz/label.png')
img2 = PhotoImage("label-d", file='../images/piratz/label-d.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
     'Label.border': {"element create":
          ('image', "label",
           ('disabled', "label-d"),
           {'border':[19, 9, 7, 7], 'padding':[17,5,3,3], 'sticky': "nsew"}) # 17,3,3,3 
        }
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'
widg = Label(fr,text='Piratz! make it long')
widg.grid(column=0,row=11,sticky='nsew', padx=5, pady=5)
widg1 = Label(fr,text='Piratz!\nextra line')
widg1.grid(column=0,row=12,sticky='nsew', padx=5, pady=5)

root.mainloop()
    st_rb.grid(column=0, row=iy, padx=5, pady=5, sticky='nw')

img1 = PhotoImage("separator", file='../images/piratz/separator.png')
img2 = PhotoImage("separator-v", file='../images/piratz/separator-v.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Separator.separator': {
            "element create": (
                'image',
                "separator",
                #('invalid', "separator-v"), ## uncomment when using 2nd state
                {
                    'border': [3],
                    'sticky': 'nsew'
                })
        }  # 'border':[2], ## change from 3 to 2
        # end of theme extract - don't forget to add comma at end when inserting
    })

fr1 = Frame(fr, height=250, width=250)
fr1.grid(column=1, row=0, sticky='nsew', padx=5, pady=5)
style.theme_use('yummy')  # 'default'
widg = Separator(fr1, orient="horizontal")
widg.place(x=5, y=5, width=150)
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('alt', {
        # start of theme extract
        'TSpinbox': {
            'layout': [('Spinbox.field', {
                'side':
                'left',
                'sticky':
                'we',
                'children': [('null', {
                    'side':
                    'right',
                    'sticky':
                    '',
                    'children': [('Spinbox.uparrow', {
                        'side': 'top',
                        'sticky': 'e'
                    }), ('Spinbox.downarrow', {
                        'side': 'bottom',
                        'sticky': 'e'
                    })]
                }),
                             ('Spinbox.padding', {
                                 'sticky':
                                 'nswe',
                                 'children': [('Spinbox.textarea', {
                                     'sticky': 'nswe'
                                 })]
                             })]
            })]
        },
        "Spinbox.field": {
            "element create":
            ("image", 'combo-n', ('readonly', 'disabled', 'combo-d'), {
                'sticky': 'ew',
                'border': [4],
                'padding': 0
            })
        },
        "Spinbox.downarrow": {
            "element create": (
                "image",
                'arrowdown-n',
                ('disabled', 'arrowdown-d'),
                ('pressed', 'arrowdown-p'),
                ('active', 'arrowdown-a'),
                {
                    'sticky': 'e',
                    'border': [0],
                    'padding': 4
                }  # 'border': [1]
            )
        },
        "Spinbox.uparrow": {
            "element create":
            ("image", 'arrowup-n', ('disabled', 'arrowup-d'),
             ('pressed', 'arrowup-p'), ('active', 'arrowup-a'), {
                 'sticky': 'e',
                 'border': [0],
                 'padding': 4
             })
        }

        # end of theme extract - don't forget to add comma at end when inserting
    })
Example #27
0
def load(style: ttk.Style) -> None:
    style.theme_create(
        THEME_DARK,
        "clam",
        {
            ".": {
                "configure": {
                    "background": Colors.frame,
                    "foreground": Colors.white,
                    "bordercolor": Colors.darkest,
                    "darkcolor": Colors.dark,
                    "lightcolor": Colors.lighter,
                    "troughcolor": Colors.darker,
                    "selectbackground": Colors.selectbg,
                    "selectforeground": Colors.selectfg,
                    "selectborderwidth": 0,
                    "font": "TkDefaultFont",
                },
                "map": {
                    "background": [
                        ("disabled", Colors.frame),
                        ("active", Colors.lighter),
                    ],
                    "foreground": [("disabled", Colors.disabledfg)],
                    "selectbackground": [("!focus", Colors.darkest)],
                    "selectforeground": [("!focus", Colors.white)],
                },
            },
            "TButton": {
                "configure": {
                    "width": 8,
                    "padding": (5, 1),
                    "relief": tk.RAISED,
                    "anchor": tk.CENTER,
                },
                "map": {
                    "relief": [("pressed", tk.SUNKEN)],
                    "shiftrelief": [("pressed", 1)],
                },
            },
            "TMenubutton": {"configure": {"padding": (5, 1), "relief": tk.RAISED}},
            "TCheckbutton": {
                "configure": {
                    "indicatorbackground": Colors.white,
                    "indicatormargin": (1, 1, 4, 1),
                }
            },
            "TRadiobutton": {
                "configure": {
                    "indicatorbackground": Colors.white,
                    "indicatormargin": (1, 1, 4, 1),
                }
            },
            "TEntry": {
                "configure": {
                    "fieldbackground": Colors.white,
                    "foreground": Colors.black,
                    "padding": (2, 0),
                },
                "map": {"fieldbackground": [("disabled", Colors.frame)]},
            },
            "TSpinbox": {
                "configure": {
                    "fieldbackground": Colors.white,
                    "foreground": Colors.black,
                    "padding": (2, 0),
                },
                "map": {"fieldbackground": [("disabled", Colors.frame)]},
            },
            "TCombobox": {
                "configure": {
                    "fieldbackground": Colors.white,
                    "foreground": Colors.black,
                    "padding": (2, 0),
                }
            },
            "TLabelframe": {"configure": {"relief": tk.GROOVE}},
            "TNotebook.Tab": {
                "configure": {"padding": (6, 2, 6, 2)},
                "map": {"background": [("selected", Colors.lighter)]},
            },
            "Treeview": {
                "configure": {
                    "fieldbackground": Colors.white,
                    "background": Colors.white,
                    "foreground": Colors.black,
                },
                "map": {
                    "background": [("selected", Colors.selectbg)],
                    "foreground": [("selected", Colors.selectfg)],
                },
            },
            Styles.tooltip: {
                "configure": {"justify": tk.LEFT, "relief": tk.SOLID, "borderwidth": 0}
            },
            Styles.tooltip_frame: {"configure": {}},
            Styles.service_checkbutton: {
                "configure": {
                    "background": Colors.listboxbg,
                    "foreground": Colors.black,
                }
            },
        },
    )
Example #28
0
    st_rb = Radiobutton(fr,
                        value=state,
                        text=state,
                        variable=state_val,
                        command=change_state)
    st_rb.grid(column=0, row=iy, padx=5, pady=5, sticky='nw')

img1 = PhotoImage("sizegrip", file='../images/piratz/sizegrip.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'sizegrip': {
            "element create": ('image', "sizegrip")
        }
        # end of theme extract - don't forget to add comma at end when inserting
    })

style.theme_use('yummy')  # 'default'
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
widg = Sizegrip(root)
widg.grid(row=1, column=1, sticky='se')

root.mainloop()
img1 = PhotoImage("radio-n", file='../images/lime/radio-n.png')
img2 = PhotoImage("radio-s", file='../images/lime/radio-s.png')
img3 = PhotoImage("radio-d", file='../images/lime/radio-d.png')
img4 = PhotoImage("radio-ds", file='../images/lime/radio-ds.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create(
    "yummy",
    parent="clam",
    settings={
        #style.theme_settings('default', {
        # start of theme extract
        'Radiobutton.indicator': {
            "element create":
            ('image', "radio-n", ('disabled', 'selected', "radio-ds"),
             ('disabled', "radio-d"), ('selected', "radio-s"), {
                 'width': 20,
                 'sticky': "w"
             })
        }
        # end of theme extract - don't forget to add comma at end when inserting
    })

style.theme_use('yummy')  # 'default'
happy = ['Great', 'Good', 'OK', 'Poor', 'Awful']
happiness = StringVar()
for ix, s in enumerate(happy):
    widg = Radiobutton(fr, text=s, value=s, variable=happiness)
    widg.grid(column=0, row=11 + ix, sticky='nw')
img1 = PhotoImage("sail", file='../images/piratz/sail.png')
img2 = PhotoImage("sail-d", file='../images/piratz/sail-d.png')
img3 = PhotoImage("sail-p", file='../images/piratz/sail-p.png')
img4 = PhotoImage("sail-s", file='../images/piratz/sail-s.png')

style = Style()
# both theme_create and theme_settings worked
style.theme_create( "yummy", parent="clam", settings={
#style.theme_settings('default', {
# start of theme extract
     'tab': {"element create":
          ('image', "sail",
           ('pressed', "sail-p"),
           ('selected', "sail-s"),
           ('disabled', "sail-d"),
           {'border':[30, 17, 27, 32], 'padding':[13,8,12,13], 'sticky': "nsew"} 
        ) },
       'TNotebook': {'configure': {'bordercolor': colours['bordercolor']}}, 
         
     #'TNotebook.tab': {"map":  
            #{'expand': [('selected', [0,3,2,2])]}} 
     
# end of theme extract - don't forget to add comma at end when inserting
     })

style.theme_use('yummy') # 'default'
widg = Notebook(fr)
page1 = Frame(widg, width=150, height=150)
page2 = Frame(widg, width=150, height=150)
widg.add(page1,text='Piratz!')
widg.add(page2,text='Piratz!\nextra longish line\nor two')