Reputation: 139
I have coded a tkinter application using the usual tk widgets. I have learned that the tkinter.ttk widgets have a more modern look and make everything better. But now alot of my code does not work. Here is a small one which I don't understand why.
The difference is Type of Project is not there... I got around this by just putting Type of Project
in the options it doesn't show it either(But how would I be able to like preset it).
Here is tk code:
om1str = StringVar()
om1str.set('Type of Project')
om1list = ['Photo Editing', 'Video Editing']
om1 = OptionMenu(new, om1str, *om1list, command = Create_New.more_options)
And ttk code:
om1str = StringVar()
om1list = ['Type of Project', 'Photo Editing', 'Video Editing']
om1 = OptionMenu(new, om1str, *om1list, command = Create_New.more_options)
Here is another example. Before swapping from tkinter to tkinter.ttk this piece of code worked but now does not. (I had this exact same code for the photo editing option two)
if choice == 'Video Editing':
print('hi')
for widgets in new.winfo_children():
if widgets.winfo_class() == 'Frame' or widgets.winfo_class() == 'Button':
widgets.destroy()
And now this kinda happens (The name does not duplicate because it is not in the same def
Create_New.more_options()
)
How would I be able to delete the frame and the button without removing all contents of the tk.Toplevel()
I know how to set the bg and fg color(was really confused) after some quick google searches.
Is there any smooth way to go from tkinter to the tkinter.ttk widget styles without having to do a little 2 much work.
Upvotes: 2
Views: 253