tkinter themes - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: General (https://python-forum.io/forum-1.html) +--- Forum: Code sharing (https://python-forum.io/forum-5.html) +--- Thread: tkinter themes (/thread-5157.html) |
tkinter themes - metulburr - Sep-20-2017 This isnt mine, i just thought it was nice to display the available themes import random import tkinter from tkinter import ttk from tkinter import messagebox class App(object): def __init__(self): self.root = tkinter.Tk() self.style = ttk.Style() available_themes = self.style.theme_names() random_theme = random.choice(available_themes) self.style.theme_use(random_theme) self.root.title(random_theme) frm = ttk.Frame(self.root) frm.pack(expand=True, fill='both') # create a Combobox with themes to choose from self.combo = ttk.Combobox(frm, values=available_themes) self.combo.pack(padx=32, pady=8) # make the Enter key change the style self.combo.bind('<Return>', self.change_style) # make a Button to change the style button = ttk.Button(frm, text='OK') button['command'] = self.change_style button.pack(pady=8) def change_style(self, event=None): """set the Style to the content of the Combobox""" content = self.combo.get() try: self.style.theme_use(content) except tkinter.TclError as err: messagebox.showerror('Error', err) else: self.root.title(content) app = App() RE: tkinter themes - Larz60+ - Sep-20-2017 The problem is that they don't look the same on all operating systems, and some don't work at all in MS windows. This is one of the reasons why I am now using wxpython phoenix. So far, they seem consistent and very easy to use. Though not as complete as Qt, I'm really impressed with this release. wx formbuilder (https://github.com/wxFormBuilder/wxFormBuilder) continues to evolve (last change 3 days ago), and may someday be as good as qt designer. RE: tkinter themes - metulburr - Sep-21-2017 I know they dont look the same on all OS's. I thought it was different themes based on python version and OS's as well. RE: tkinter themes - loombago - Mar-28-2019 Hi, this code doesn't work properly on Python 3.x unless you add self.root.mainloop() to App class __init__ function. |