Normally, when I use the TTk styles, I define a style object by object. If I had many forms and windows I define a setStyle()
method to do that. But, in this new application make sense to have just a setStyle()
method in the App main class. The problem is that it ignores the settings in the App.setStyle()
method. Any suggestion?
class App(Tk):
...
def setStyles(self):
self.s = ttk.Style()
self.s.theme_use('alt')
padding = "12 12 12 12"
self.s.configure('frmWin.TFrame', padding=padding)
self.s.configure('big.TButton', font=(None, 24, "bold"))
self.s.configure('TLabel', font=(None, 28), anchor=W, justify=LEFT, sticky=W)
self.s.configure('TLabelframe', borderwidth=40, bordercolr="blue", labelmargins=(40,0))
self.s.configure('TLabelframe.Label', font=(None, 20), sticky=W)
# [MM] formNewPlayer
self.s.configure("frmNewPlayer.Treeview", rowheight=72, highlightthickness=0, bd=0, font=('Calibri', 24,'bold')) # Modify the font of the body
self.s.configure("frmNewPlayer.Treeview.Heading", font=('Calibri', 13,'bold')) # Modify the font of the headings
self.s.configure("frmNewPlayer.TLabel", font=("Calibri", 16))
self.s.configure("frmNewPlayer.Tentry", font=("Calibri", 22), width=16)
self.s.configure('frmNewPlayer.TButton', font=("Calibri", 24, "bold"))
# [MM] AskDialog
self.s.configure("AskDlg.TButton",foreground="black",
background="white",
width=4,
padding=[10, 10, 10, 10],
font = "Verdana 48 bold")
self.s.configure("AskDlg.TLabel", foreground="black",
background="white",
image="",
padding=[50, 50, 50, 50],
font = "Verdana 48")
self.s.configure("AskDlg.TFrame", foreground="black",
background="white",
borderwidth = 8,
font = "Verdana 48 underline")
CodePudding user response:
Well, you may check:
- First you have to make sure that you called the settings file correctly, and you imported it. (for
import settings
, you call the class like this:settings.setStyle()
, and forfrom settings import setStyle
you simply call it withsetStyle()
); - The second thing is that you probably forgot to call the
setStyle()
class; - And the third thing may be that you didn't gave the arguments correctly.
If you checked everything and it's still not working, please message me in a comment.
CodePudding user response:
OK guys, thanks for the help. I found the bug, if some debug options are set to True the call to setStyles()
in App __init__()
is bypassed. It was a wrong implementation of a complex debug field of flags... everyting works as expected now.