Fresh tkinter and ttk tutorial for Python 3

Where can I find the most modern tutorial that teaches tkinter along with ttk

tkinter seems to be the only way out in Python 3 (don't offer Python 2), and ttk gave me hope for a nice GUI.

+54
tkinter ttk
Jul 28 2018-11-21T00:
source share
4 answers

I found TkDocs tutorial to be very useful. It describes how to build Tk interfaces using Python and Tkinter and ttk and makes notes about the differences between Python 2 and 3. It also has examples in Perl, Ruby, and Tcl, since the goal is to teach Tk on its own, not bindings for a specific language.

I did not go through all this from beginning to end, but used only a few topics as examples of what I was stuck in, but it is very educational and conveniently written. Today, reading the introductory and first few sections, I think that I will begin to work on the rest.

Finally, it is current and the site has a very beautiful appearance. It also has tons of other pages worth checking out (Widgets, Resources, Blog). This guy does a lot to not only teach Tk, but also to improve people's understanding that this is not the ugly beast that once was.

+52
Jul 29 '11 at 16:53
source share

I recommend the NMT Tkinter 8.5 link .

Some examples use module names that are used in Python 2.7.
Here is the link to change the name in Python 3: link

One of the benefits of ttk is that you can choose an existing one topic
This is the complete set of styles applied to ttk widgets.

Here is an example I wrote (for Python 3) that allows you to select any available topic from a combo box:

 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() app.root.mainloop() 

Note: I noticed that when using Python 3.3, the "vista" theme is available (but not 2.7).

+20
Feb 26 '13 at 5:27
source share

I recommend reading the documentation. It is simple and authoritative, and good for beginners.

+3
Apr 25 '14 at 13:13
source share

This is not very fresh, but it is concise, and from what I saw is valid for Python 2 and 3.

0
Jan 6 2018-12-12T00:
source share



All Articles