python - Setting Tkinter default widgets kwargs -


how change default tkinter kwargs values widgets?

i know can set general tkinter theme tk_setpalette(theme) computes , overwrites default values , tries use colors best matches new theme more control.

for example, let's want change background color of tkinter widgets, i'd like:

import tkinter tk color = 'blue' #this in constant or setting modules  class custombutton(tk.button):     def __init__(self, root, **options):         tk.button.__init__(self, root, bg=color, **options) 

then if @ point want change background color blue red i'd need edit setting.py module. (background example, want change **kwargs)

i'm sure there's better way , somewhere let's set default widgets values without overriding every single widget in wrapper class...

i know asked couple of years back, same issue stumbles upon thread, here example of how incorporate generalised settings widgets:

my_options = {"bg" : "gray60", "font" : ("tahoma", 20)}  tk.label(root, text = "same background", **my_options).grid(row = 1, column = 1) tk.button(root, text = "and font.", **my_options).grid(row = 1, column = 2, padx = (5, 0)) 

take note option must string, value usual (i.e. string colour, integer height).


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -