In this post, we will see how to resolve How do I to call a custom object with custom style methods and use it as a style for a label(and widgets in general) in tkinter?
Question:So I am trying to import my own custom style methods into my main app to then use as a custom style in ttk.Label(), by calling the class method, but I’m having trouble finding a way to call it. Below is the example code of the main app.
I’m honestly just looking to understand a way to call the methods w/o putting them in the same file, but I just don’t know how to.
styleoption requires the name of a style as a string. Since your function
None, it’s the same as if you did
One solution is to have your
testfunction return the style name:
testfunction, however, so that the style is initialized.
styleparameter of a ttk widget.
If you have better answer, please add a comment about this, thank you!