Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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.

DevOpsPorto

August 01, 2018
Tweet

More Decks by DevOpsPorto

Other Decks in Technology

Transcript

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

    View Slide

  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."

    View Slide

  3. Tkinter examples you may have seen...

    View Slide

  4. Tkinter examples you may have seen...

    View Slide

  5. With ttk, you get a nicer look.

    View Slide

  6. Themed widgets can match the platform.

    View Slide

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

    View Slide

  8. The boilerplate:

    View Slide

  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

    View Slide

  10. ...and some more in these modules
    • tkinter.scrolledtext
    • tkinter.colorchooser
    • tkinter.filedialog
    • tkinter.messagebox
    • turtle

    View Slide

  11. Let’s see it in action!

    View Slide

  12. So, should I use tkinter?

    View Slide

  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?

    View Slide

  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?

    View Slide

  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:

    View Slide

  16. Tkinter GUI Aplication
    Development Blueprints
    Bhaskar Chaudhary
    Packt Publishing, 2015
    Useful books:
    Python GUI Programming Cookbook
    Burkhard A. Meier
    Packt Publishing, 2017

    View Slide

  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...

    View Slide

  18. Thank you!

    View Slide