Search code examples
python-3.xtkinterttk

How to install Python ttk themes


This is my first post on SO, so please feel free to correct me if I'm doing anything wrong!

I am making a simple GUI for my Raspberry Pi (that runs Raspbian stretch) on Windows (because I can use PyCharm on there). I am would like to install third party themes from this site and have followed the instructions on the wiki. However, on both Windows and Raspbian, it appears to install properly without any errors, but when I check for ttk by doing this:

import tkinter.ttk
tkinter.ttk.Style().theme_names()

it still displays the default themes for the respective operating systems.

I have also looked at this SO post (How to find or install themes tkinter ttk for Python), but there are no relevant answers on there.

Edit: I now know how to use the themes in a regular tkinter/ttk GUI, but I would like to install these themes so they act like the built in ones, as I am using the appJar module that uses tkinter and ttk.

Any help and guidance would be much appreciated!


Solution

  • appJar's support for ttk is still in development, but you can try overriding the default style:

    from ttkthemes import ThemedStyle
    app = gui(useTtk=True)
    app.ttkStyle = ThemedStyle(app.topLevel)
    app.ttkStyle.set_theme("plastik")
    

    This tells appJar to use ttk, but then replaces the style appJar is using, with the style you request.