Dodu
Dodu

Reputation: 139

How to smoothly go from tkinter widgets to tkinter.ttk widgets without much of a hassle [Closed, But could answer if wanted]

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.

Here is tkinter: enter image description here

And tkinter.ttk enter image description here

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())

enter image description here

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

Answers (0)

Related Questions