Ttk style support (work in-progress) #68
Replies: 6 comments 13 replies
-
Hello @jrezai,
Great, I already want to see more of your work.
Yes it's hard. I did several attempts but abandoned/postponed for now.
I like this approach.
I also agree with this.
It would be nice if you show me some of the contents that will have the files:
Some things that I would like to have/maintain:
Regards |
Beta Was this translation helpful? Give feedback.
-
Hi @alejandroautalan , I've uploaded a YouTube video which explains it in more detail (with audio): Style definition file: used for specifying the styles data (normal ttk style code)
That's interesting. That would explain where the 'Toolbutton' style was coming from for ttk.Button. I wondered where that came from. It's going to require some planning to decide how we can have both the style population file and styles from register_custom_property show up in the same combobox. I will upload all the changes I've done so far into my GitHub repository once I do some more testing (it's not ready to be considered for merging into your main GitHub page yet). We can maybe use my repository for some beta testing or perhaps we need a new 'testing' or 'beta' branch in your GitHub page? Any ideas / suggestions welcome. Thanks, |
Beta Was this translation helpful? Give feedback.
-
Hello @jrezai, Summary of changes:
More details in the commit history. Regards |
Beta Was this translation helpful? Give feedback.
-
Hello @jrezai, thanks for your tests and notes.
I think that the problem here is that I'm cropping the full widget functionality in the normal preview (The user cannot even click a button)
Yes, it is possible for this to happen. I still don't see a clear solution for this.
I think that it would be better to leave the Toplevel window the way it is. Regards |
Beta Was this translation helpful? Give feedback.
-
import tkinter as tk
from tkinter import ttk
root = tk.Tk()
root.bind("<<ThemeChanged>>", lambda e: print("event on root"))
tk_frame = tk.Frame()
tk_frame.pack()
tk_frame.bind("<<ThemeChanged>>", lambda e: print("event on tk frame"))
ttk_frame = ttk.Frame()
ttk_frame.pack()
ttk_frame.bind("<<ThemeChanged>>", lambda e: print("event on ttk frame"))
# not direct child
ttk_frame = ttk.Button(ttk_frame)
ttk_frame.pack()
ttk_frame.bind("<<ThemeChanged>>", lambda e: print("event on ttk button"))
def ch_theme():
print("---")
root.tk.call("ttk::style", "theme", "use", "clam")
# delay is needed, otherwise the bindings won't work
root.after(10, ch_theme)
root.mainloop() |
Beta Was this translation helpful? Give feedback.
-
@jrezai in regard to:
I agree. Feel free to add this if you have time.
Yes, when this last functionality is done, I will merge it with the master branch. Bye! |
Beta Was this translation helpful? Give feedback.
-
Ttk styles in Pygubu Designer
I have started the implementation of Ttk style support in Pygubu Designer. It's currently in its alpha stages. It's working, but more work is needed, such as error handling, testing, etc.
It would be a huge undertaking to support every single element that there is with ttk styles. Having the ability to change ttk styles using some kind of properties editor would make it hard to maintain (in my opinion) due to the versatility and flexibility of ttk styles. Therefore, my proposal is to make Pygubu Designer be aware of ttk styles by reading a user-defined Python script that contains the style definitions and then allowing the user to choose a style of a widget from the Style combobox.
I also think it's very important that the user should not need to restart Pygubu or re-open the UI project every time they make a Ttk style change, because creating Ttk styles is a lot about experimentation. With the new Ttk style implementation (work is in progress!), style changes will be detected automatically and reflected in the Preview canvas in real-time (live) so the user will not need to restart his/her project with every change that they make to the style definition file.
Here is a screenshot of some of the changes. I will share more information as more work gets done.
Any thoughts / comments are welcome.
Regards,
Jobin
Beta Was this translation helpful? Give feedback.
All reactions