DevOpsPorto Meetup19: GUI programming on Python with Tkinter by Vitor Domingos

DevOpsPorto Meetup19: GUI programming on Python with Tkinter by Vitor Domingos

One of the most overlooked packages from The Python Standard Library is tkinter and it's child ttk. Tkinter allows us to build graphic user interfaces without adding external dependencies, and with a bit of care, it allows for a good user experience. While learning Python programming, I have been exploring tkinter/ttk as a tool for building user-friendly graphical interfaces. I would like to share that experience and some of the insights that have arisen during that process. Tkinter may not be able to replace a native GUI toolkit, but can certainly be an important addition to any developers toolbox, both for personal use or for bridging our code to less technical users.

A2c14a1c4e16aa337c7d36abe7d1cf8f?s=128

DevOpsPorto

August 01, 2018
Tweet

Transcript

  1. GUI programming on Python with tkinter no­title.victordomingos.com

  2. What is tkinter? "Tkinter is Python's de­facto standard GUI (Graphical

    User Interface) package. It is a thin object­oriented layer on top of Tcl/Tk."
  3. Tkinter examples you may have seen...

  4. Tkinter examples you may have seen...

  5. With ttk, you get a nicer look.

  6. Themed widgets can match the platform.

  7. And it can grow, if you need it.

  8. The boilerplate:

  9. • Text • Scale • Scrollbar • Spinbox • Progressbar

    • Treeview • Separator Available widgets (incl. ttk) • Label • Entry • Button • Checkbutton • Menubutton • Radiobutton • Combobox • Toplevel (+windows) • Frame • LabelFrame • PanedWindow • Notebook • Sizegrip • Canvas
  10. ...and some more in these modules • tkinter.scrolledtext • tkinter.colorchooser

    • tkinter.filedialog • tkinter.messagebox • turtle
  11. Let’s see it in action!

  12. So, should I use tkinter?

  13. PROS • It’s simple to learn. • Bundled with Python.

    • Highly portable. • Can look [kind of] native. • It’s fast enough. • Mature and stable. • Free for commercial use. So, should I use tkinter?
  14. PROS • It’s simple to learn. • Bundled with Python.

    • Highly portable. • Can look [kind of] native. • It’s fast enough. • Mature and stable. • Free for commercial use. CONS • Limited widget set (e.g. no date picker, no webview). • No UI designer. • Doesn’t look totally native. • It’s not as fast as a native Swift or C++ GUI. • Usually, no new features. So, should I use tkinter?
  15. • https://docs.python.org/3/library/tk.html • https://tkdocs.com • http://effbot.org/tkinterbook/tkinter­index.htm • http://infohost.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdf If you

    speak Tcl, explore Tcl/tk docs too. More info:
  16. Tkinter GUI Aplication Development Blueprints Bhaskar Chaudhary Packt Publishing, 2015

    Useful books: Python GUI Programming Cookbook Burkhard A. Meier Packt Publishing, 2017
  17. • https://stackoverflow.com/questions/tagged/tkinter Sooner or later, you will probably find, on

    StackOverflow, some insightful answers from a guy named Brian Oakley. You definitely should trust him. In case you get stuck...
  18. Thank you!