18
GUI programming on Python with tkinter notitle.victordomingos.com

GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

  • Upload
    others

  • View
    119

  • Download
    2

Embed Size (px)

Citation preview

Page 1: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

GUI programmingon Python with tkinter

no­title.victordomingos.com

Page 2: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

What is tkinter?

"Tkinter is Python's de­facto standardGUI (Graphical User Interface) package.

It is a thin object­oriented layeron top of Tcl/Tk."

Page 3: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

Tkinter examples you may have seen...

Page 4: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

Tkinter examples you may have seen...

Page 5: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

With ttk, you get a nicer look.

Page 6: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

Themed widgets can match the platform.

Page 7: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

And it can grow, if you need it.

Page 8: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

The boilerplate:

Page 9: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

• 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

Page 10: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

...and some more in these modules

• tkinter.scrolledtext• tkinter.colorchooser• tkinter.filedialog• tkinter.messagebox• turtle

Page 11: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

Let’s see it in action!

Page 12: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

So, should I use tkinter?

Page 13: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

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?

Page 14: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

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?

Page 15: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

• 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:

Page 16: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

Tkinter GUI AplicationDevelopment BlueprintsBhaskar ChaudharyPackt Publishing, 2015

Useful books:

Python GUI Programming CookbookBurkhard A. MeierPackt Publishing, 2017

Page 17: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

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

Page 18: GUI programming on Python with tkinter · What is tkinter? "Tkinter is Python's defacto standard GUI (Graphical User Interface) package. It is a thin objectoriented layer

Thank you!