Python Forum
[Tkinter] Theme does not change globally
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Theme does not change globally
#1
I was trying to use a Tkinter theme in Python 3.x.

Here is my code:
s = ttk.Style()
s.theme_use('clam')
But in
Toplevel()
windows, the theme disappears.

Does anyone know how to do a theme for all windows ? Thanks! :)
Reply
#2
I figured it out:

I had to write this
from tkinter.ttk import *
to override all widgets to TTK widgets because the default widgets don't support theming...
I had been using a TTK Notebook and therefore in my main window it was working, but not elsewhere.
I hope this helps someone.
Reply
#3
In the future use:
import tkinter as tk
import tkinter.ttk as ttk
Then there will be no confusion about which widgets are tk and which widgets are themed tk. As you write more complex programs that use more packages, using "from package import *" is eventually going to lead to a namespace collision. You will think you are calling a function from one package and instead you are calling a different function from a different package. That sort of bug is really difficult to trace.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can I get Colors of current GTK theme? ondoho 2 6,391 May-26-2017, 03:32 PM
Last Post: ondoho
  pygtk3, how to change application theme ? harun2525 7 7,304 May-10-2017, 08:42 PM
Last Post: harun2525
  [Tutorial] PyGtk3 How To Change Applicaton Theme harun2525 0 3,589 Apr-15-2017, 11:16 AM
Last Post: harun2525

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020