Exploring Python for next desktop GUI Project

Zachary Ware zachary.ware+pylist at gmail.com
Thu Jul 24 22:13:42 CEST 2014

On Thu, Jul 24, 2014 at 2:02 PM, Chris “Kwpolska” Warrick
<kwpolska at gmail.com> wrote:
> Pretty much everyone in the world hates Tcl and Tk.  Ask your favorite
> search engine for some results.

Whee, I'm an alien! ;)

I'm not saying Tk is the best thing since sliced bread, I just don't
see what so many people seem to hate about it.

> i’ve tried to write a Tkinter thing once.  I don’t have a copy anymore
> (consciously deleted), but I vaguely remember some issues with widgets
> that do not work.  I also remember that the list of widgets is quite
> small and not enough for many projects.

I have had no issues with widgets not working.  I will admit that the
widget set is fairly small, though.  You can get more from Tix (which
is also distributed with tkinter), but I haven't had any need for that

> The best way to handle this is just choose one of the two (wxwidgets
> chose GTK 2, for example) and be considered native enough by most, as
> people don’t really mind mixing them (as there are no good Qt web
> browsers, and VLC uses Qt and not GTK)

That's fair, and I agree that Tk should probably provide "close to
GTK" and "close to QT" themes for ttk[1].  As I understand it, though,
ttk gives almost complete control over the look of individual widgets,
so if you really don't like how your widget looks, change it!

> ttk on Linux doesn’t change a thing.  It still uses the ugly, ancient,
> motif-esque style:
> https://www.google.com/search?q=tk+linux&tbm=isch
> (also, off by 10 years, motif is actually from the 1980s.)

Motif is indeed ugly, but your search for 'tk linux' doesn't tell me
anything about 'ttk linux'.  I would be interested in the results of
the script below on Linux, which I may or may not be able to try for
myself later (but can't right now).


[1] Such themes might already exist, I haven't checked.  If anyone
wants to see what themes are available and how they look, try this
(2/3 compatible, also attached in case Gmail messes it up):

import sys

    import tkinter as tk
    from tkinter import ttk
except ImportError:
    import Tkinter as tk
    import ttk

class App(object):
    def __init__(self, root):
        self.root = root
        self.root.title('Theme tester')
        self.info_label = ttk.Label(self.root,
            text="Python {}.{} with Tcl/Tk {} on {}".format(
                sys.version_info[0], sys.version_info[1],
                self.root.tk.eval('info patchlevel'),
        self.theme_idx = 0
        self.change_btn = ttk.Button(self.root,
                                     text='Change theme',
        self.rb_var = tk.StringVar(self.root)
        self.radiobtn = ttk.Radiobutton(self.root,
                                        text='Radio button option 1',
        self.radiobtn2 = ttk.Radiobutton(self.root,
                                         text='Radio button option 2',
        self.checkbtn = ttk.Checkbutton(self.root, text='Checkbutton')
        self.entry = ttk.Entry(self.root)
        self.entry.insert(0, 'Entry')

        self.style = ttk.Style(self.root)
        self.available_themes = self.style.theme_names()

        self.theme_label = ttk.Label(self.root, text='Platform default')

    def change_theme(self):
            theme = self.available_themes[self.theme_idx]
        except IndexError:
            theme = self.available_themes[0]
            self.theme_idx = 0

        self.theme_idx += 1

root = tk.Tk()
app = App(root)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tk_themes.py
Type: text/x-python
Size: 2199 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20140724/5de602d3/attachment.py>

More information about the Python-list mailing list