Home > other >  Personalize an awhemes theme on Tkinter ttk - Python (Solved)
Personalize an awhemes theme on Tkinter ttk - Python (Solved)

Time:01-26

I'm developing a python application with Tkinter and I'm using the awdark theme from awthemes to give my app a standout look. The theme look really good but I realized by looking at the awthemes website that it's possible to personalize the themes by changing for example the graphics color with setHighlightColor. There seems to be a lot of customization possible but they don't show concrete examples in python, just some piece of code like this:

package require awthemes
::themeutils::setHighlightColor awdark #007000
package require awdark

After several tries I didn't manage to customize the theme and I didn't find anything on google either, so I'm asking for your help.

Here is my python code:

from tkinter import *
from tkinter import ttk

root = Tk()

# Create some random widgets to see the changes
notebook = ttk.Notebook(root)
notebook.grid(row=0, column=0, sticky='nsew')
global_frame = ttk.Frame(notebook)
global_frame.grid(row=0, column=0)
notebook.add(global_frame, text="Tab1")
ttk.Radiobutton(global_frame, text="Radio 1").grid(row=0, column=0)
ttk.Radiobutton(global_frame, text="Radio 2").grid(row=0, column=1)
ttk.Progressbar(global_frame, value=75).grid(row=1, column=0, columnspan=2)

# Create a style and import the awdark theme
style = ttk.Style()
root.tk.call('lappend', 'auto_path', '/Users/marinnagy/Downloads/awthemes-10.4.0')
root.tk.call('package', 'require', 'awdark')
style.theme_use('awdark')

root.mainloop()

The current GUI look like this, how to change the graphics color to green like in this picture?

CodePudding user response:

Try:

...
# Create a style and import the awdark theme
style = ttk.Style()
root.tk.call('lappend', 'auto_path', '/Users/marinnagy/Downloads/awthemes-10.4.0')
root.tk.call('package', 'require', 'awthemes')
root.tk.call('::themeutils::setHighlightColor', 'awdark', '#007000')
root.tk.call('package', 'require', 'awdark')
style.theme_use('awdark')
...
  •  Tags:  
  • Related