Jul-24-2020, 03:25 AM
Hi all,
I am working on a project with a GUI and I am going to make the interface have multiple possible styles like "Dark Mode". So I thought the best way to store the style is in the form of a string, thinking I could pass the entire string into the configure method. Is this possible? Is there an other way to do this? Please see code below for examples.
I am working on a project with a GUI and I am going to make the interface have multiple possible styles like "Dark Mode". So I thought the best way to store the style is in the form of a string, thinking I could pass the entire string into the configure method. Is this possible? Is there an other way to do this? Please see code below for examples.
strStyle='activebackground="#ff8040", activeforeground="#000000", background="#c0c0c0", font="-family {Segoe UI} -size 14 -weight bold -slant roman", foreground="#000000"'
#Passing the style string s a whole is what I would like to do, but does no work
self.btn.configure(strStyle)
#---------------------------------
#so I tried to split the string into the individual options with their values, still not working
self.btn = tk.Button(top)
self.btn.place(x=rowCnt*97, y=0, height=42, width=97)
self.btn.configure(text=rowTab[1])
arrayArgAndVal=strStyle.split(",")
for itemArgAndVal in arrayArgAndVal:
#the first itemArgAndVal='activebackground="#ff8040"'
self.btn.configure(itemArgAndVal)
#---------------------------------
#then I tried splitting the option from the value, still not working
self.btn = tk.Button(top)
self.btn.place(x=rowCnt*97, y=0, height=42, width=97)
self.btn.configure(text=rowTab[1])
arrayArgAndVal=strStyle.split(",")
for itemArgAndVal in arrayArgAndVal:
#the first itemArgAndVal='activebackground="#ff8040"'
itemArgAndVal=itemArgAndVal.split("=")
self.btn.configure(itemArgAndVal[0]=itemArgAndVal[1])
#---------------------------------
