def text_widget(master, ttip="", modal=False): t = Text(master) tooltip(t, ttip) if modal: a,b = pallet("DIALOG-BG"), pallet("DIALOG-FG") else: a,b = bg(), fg() t.config(background=a, foreground=b) return t
def text_widget(master, ttip="", modal=False): t = Text(master) tooltip(t, ttip) if modal: a,b = pallet("DIALOG-BG"), pallet("DIALOG-FG") else: a,b = bg(), fg() t.config(background=a, foreground=b) return t
def button(master, text, command=None, ttip=""): b = Button(master, text=text) if command: b.config(command=command) tooltip(b, ttip) b.config(background=pallet("button-bg"), foreground=pallet("button-fg")) b.config(activebackground=pallet("ACTIVE-BG")) b.config(activeforeground=pallet("ACTIVE-FG")) b.config(highlightbackground=bg()) return b
def button(master, text, command=None, ttip=""): b = Button(master, text=text) if command: b.config(command=command) tooltip(b, ttip) b.config(background=pallet("button-bg"), foreground=pallet("button-fg")) b.config(activebackground=pallet("ACTIVE-BG")) b.config(activeforeground=pallet("ACTIVE-FG")) b.config(highlightbackground=bg()) return b
def label(master, text, var=None, modal=False): w = Label(master, text=text) w.config(justify=LEFT) if var: w.config(textvariable=var) if modal: a, b = pallet("DIALOG-BG"), pallet("DIALOG-FG") else: a, b = bg(), fg() w.config(background=a, foreground=b) return w
def radio(master, text, var, value, ttip="", modal=False, command=None): rb = Radiobutton(master, text=text, variable=var, value=value) tooltip(rb, ttip) if modal: rb.config(background=pallet("DIALOG-BG")) rb.config(foreground=pallet("DIALOG-FG")) else: rb.config(background=bg(), foreground=fg()) rb.config(highlightbackground=bg()) rb.config(selectcolor=pallet("radio-select")) rb.config(activebackground=pallet("active-bg")) rb.config(activeforeground=pallet("active-fg")) rb.config(command=command) return rb
def radio(master, text, var, value, ttip="", modal=False, command=None): rb = Radiobutton(master, text=text, variable=var, value=value) tooltip(rb, ttip) if modal: rb.config(background=pallet("DIALOG-BG")) rb.config(foreground=pallet("DIALOG-FG")) else: rb.config(background=bg(), foreground=fg()) rb.config(highlightbackground=bg()) rb.config(selectcolor=pallet("radio-select")) rb.config(activebackground=pallet("active-bg")) rb.config(activeforeground=pallet("active-fg")) rb.config(command=command) return rb
def checkbutton(master, text, var=None, command = None, ttip="", modal=False): cb = Checkbutton(master, text=text, variable=var) if modal: cb.config(background=pallet("DIALOG-BG")) cb.config(foreground=pallet("DIALOG-FG")) else: cb.config(background=bg(), foreground=fg()) cb.config(highlightbackground=bg()) cb.config(selectcolor=pallet("radio-select")) cb.config(activebackground=pallet("active-bg")) cb.config(activeforeground=pallet("active-fg")) cb.config(command = command) return cb
def checkbutton(master, text, var=None, command = None, ttip="", modal=False): cb = Checkbutton(master, text=text, variable=var) if modal: cb.config(background=pallet("DIALOG-BG")) cb.config(foreground=pallet("DIALOG-FG")) else: cb.config(background=bg(), foreground=fg()) cb.config(highlightbackground=bg()) cb.config(selectcolor=pallet("radio-select")) cb.config(activebackground=pallet("active-bg")) cb.config(activeforeground=pallet("active-fg")) cb.config(command = command) return cb
def frame(master, modal=False): f = Frame(master) if modal: f.config(background=pallet("DIALOG-BG")) else: f.config(background = bg()) return f
def frame(master, modal=False): f = Frame(master) if modal: f.config(background=pallet("DIALOG-BG")) else: f.config(background = bg()) return f
def scrollbar(master, xclient=None, yclient=None, orientation=VERTICAL): # if orientation == VERTICAL: # cls = __widget_class_name("Vertical.TScrollbar") # else: # cls = __widget_class_name("Horizontal.TScrollbar") # sb = Scrollbar(master, class_ = cls) sb = Scrollbar(master) sb.config(orient=orientation) if xclient: xclient.config(xscrollcommand=sb.set) sb.config(command = xclient.xview) if yclient: yclient.config(yscrollcommand=sb.set) sb.config(command = yclient.yview) sb.config(background=pallet("scrollbar-background")) sb.config(troughcolor=pallet("scrollbar-trough")) return sb
def label_frame(master, text, modal=False): f = LabelFrame(master, text=text) if modal: f.config(background=pallet("DIALOG-BG")) f.config(foreground=fg()) else: f.config(background=bg(), fg=fg()) return f
def label_frame(master, text, modal=False): f = LabelFrame(master, text=text) if modal: f.config(background=pallet("DIALOG-BG")) f.config(foreground=fg()) else: f.config(background=bg(), fg=fg()) return f
def scrollbar(master, xclient=None, yclient=None, orientation=VERTICAL): # if orientation == VERTICAL: # cls = __widget_class_name("Vertical.TScrollbar") # else: # cls = __widget_class_name("Horizontal.TScrollbar") # sb = Scrollbar(master, class_ = cls) sb = Scrollbar(master) sb.config(orient=orientation) if xclient: xclient.config(xscrollcommand=sb.set) sb.config(command = xclient.xview) if yclient: yclient.config(yscrollcommand=sb.set) sb.config(command = yclient.yview) sb.config(background=pallet("scrollbar-background")) sb.config(troughcolor=pallet("scrollbar-trough")) return sb
def scale(master, from_=200, to=0, command=None, orientation=VERTICAL, var=None, resolution = 1, ttip=""): s = Scale(master, from_=from_, to=to, orient=orientation, resolution = resolution) s.config(command=command) s.config(showvalue=False) s.config(width = 12) s.config(length = 150) s.config(sliderrelief="raised") s.config(sliderlength=20) s.config(borderwidth=0) s.config(troughcolor=pallet("slider-trough")) s.config(highlightthickness=1) # 0 to hide trough s.config(highlightbackground=pallet("slider-outline")) tooltip(s, ttip) if var: s.configure(variable=var) return s
def label(master, text, var=None, modal=False, justify=LEFT): ''' Creates Tk label widget master - Tk container text - var - Optional Tk var modal - flag, set True is this widget is for use in pop up dialog. justify - String, default LEFT ''' w = Label(master, text=text) w.config(justify=justify) if var: w.config(textvariable=var) if modal: a, b = pallet("DIALOG-BG"), pallet("DIALOG-FG") else: a, b = bg(), fg() w.config(background=a, foreground=b) return w
def scale(master, from_=200, to=0, command=None, orientation=VERTICAL, var=None, resolution = 1, ttip=""): s = Scale(master, from_=from_, to=to, orient=orientation, resolution = resolution) s.config(command=command) s.config(showvalue=False) s.config(width = 12) s.config(length = 150) s.config(sliderrelief="raised") s.config(sliderlength=20) s.config(borderwidth=0) s.config(troughcolor=pallet("slider-trough")) s.config(highlightthickness=1) # 0 to hide trough s.config(highlightbackground=pallet("slider-outline")) tooltip(s, ttip) if var: s.configure(variable=var) return s
def _init_theme(): global _style try: if not _style: _style = Style() try: _style.theme_use("alt") except TclError: _style.theme_use("default") _style.theme_create("Llia", parent="alt", settings = { "TNotebook" : {"configure" : {"tabmargins" : [2,5,2,0]}}, "TNotebook.Tab" : {"configure" : {"padding" : [5,1], "background" : pallet("TAB-BG"), "foreground" : pallet("TAB-FG")}, "map" : {"background" : [("selected", pallet("TAB-SELECTED-BG"))], "foreground" : [("selected", pallet("TAB-SELECTED-FG"))], "expand" : [("selected", [1,1,1,0])] }}}) _style.theme_use("Llia") except TclError: # Raised if Llia theme already exists pass
def _init_theme(): global _style try: if not _style: _style = Style() try: _style.theme_use("alt") except TclError: _style.theme_use("default") _style.theme_create("Llia", parent="alt", settings = { "TNotebook" : {"configure" : {"tabmargins" : [2,5,2,0]}}, "TNotebook.Tab" : {"configure" : {"padding" : [5,1], "background" : pallet("TAB-BG"), "foreground" : pallet("TAB-FG")}, "map" : {"background" : [("selected", pallet("TAB-SELECTED-BG"))], "foreground" : [("selected", pallet("TAB-SELECTED-FG"))], "expand" : [("selected", [1,1,1,0])] }}}) _style.theme_use("Llia") except TclError: # Raised if Llia theme already exists pass
def bg(): return pallet("bg")
def fg(): return pallet("fg")
def fg(): return pallet("fg")
def bg(): return pallet("bg")
def warning_label(master, text=" ", var=None, modal=True): w = label(master, text, var, modal) w.config(foreground=pallet("warning-fg")) return w
def warning_label(master, text=" ", var=None, modal=True): w = label(master, text, var, modal) w.config(foreground=pallet("warning-fg")) return w