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.
Best Answer:
Thestyle
option requires the name of a style as a string. Since your function test
returns None
, it’s the same as if you did ttk.Label(..., style=None)
One solution is to have your
test
function return the style name:test
function, however, so that the style is initialized.style
parameter of a ttk widget.If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review