Cross Platform Python Desktop GUI Using Tkinter

Build GUI For Desktop Applications Using Python And Tkinter

Python is a programming language and Tkinter is a lightweight GUI framework.

Tkinter comes bundled with Python version 3 on Linux, macOS and Windows. It is the Python interface to the Tk GUI toolkit.

Tkinter needs to be imported as a module to create a GUI application main window.

Tkinter will be used for a future desktop only version of Learning PHP eBook.

This tutorial will create a simple multiplatform GUI application that can be used as a starting template.

For this example, I will assume that Python 3 is installed with the default Tkinter module. You do not need to know Python programming, as it is easy to grasp the basic tasks and follow along.


GUI Window

# Import Tkinter Module
import tkinter
# Create Instance Of Tkinter's Tk Class
window = tkinter.Tk()
# Run Tkinter Event Loop
window.mainloop()

Build And Run

python3 gui.py

View

You will see a window open that resembles other desktop applications.


Other GUI Widgets

Tkinter (Ttk) Widgets
Name Description Usage
Button Displays buttons b = Button ( master, option=value, … )
Checkbutton Displays options and multiple select cb = Checkbutton ( master, option, … )
Entry Displays one line text field e = Entry( master, option, … )
Frame Organize other widgets f = Frame (master, option, … )
Label One line caption l = Label ( master, option, … )
LabelFrame Spatial container with label similar to HTML fieldset and legend lf = LabelFrame( master, option, … )
Menubutton Displays menus mb = Menubutton ( master, option, … )
PanedWindow Container arranged vertically or horizontally pw = PanedWindow( master, option, … )
Radiobutton Display options as radio buttons rb = Radiobutton ( master, option, … )
Scale Provides slider s = Scale ( master, option, … )
Scrollbar Adds scrolling capability sb = Scrollbar ( master, option, … )
Spinbox Built-in Up and Down buttons sp = Spinbox( master, option, … )
Combobox Combined Listbox and Entry field co = Combobox( master, option, … )
Notebook Manages a collection of windows and displays one at a time nb = Notebook( master, option, … )
Progressbar Displays status of long-running operation pb = Progressbar( master, option, … )
Separator Partition widgets sp = Separator( master, option, … )
Sizegrip Allows user to resize toplevel window sg = Sizegrip( master, option, … )
Treeview Displays a hierarchical collection of items tv = Treeview( master, option, … )
master Represents parent window
options can be comma-separated key-value pairs

# Import Tkinter Module
import tkinter
# Create Instance Of Tkinter's Tk Class
window = tkinter.Tk()

# Create Button
b = tkinter.Button ( window, text="Click Me" )
b.pack()

# Create Label
l = tkinter.Label( window, text="Name" )
l.pack()

# Create Entry
e = tkinter.Entry( window, Width=20 )
e.pack()

# Run Tkinter Event Loop
window.mainloop()

You will see a window open that resembles other desktop applications.


Screenshots:

Cross Platform Python Tkinter GUI Window
Cross Platform Python Tkinter GUI Window

Cross Platform Python Tkinter GUI Window Widgets
Cross Platform Python Tkinter GUI Window Widgets

Conclusion:

In summary, Python Tkinter can be used to create cross platform GUI applications. Python with Tkinter can be used for the GUI portion and the rest of the application can use another platform or programming language.


References:

About Edward

Edward is a software engineer, web developer, and author dedicated to helping people achieve their personal and professional goals through actionable advice and real-world tools.

As the author of impactful books including Learning JavaScript, Learning Python, Learning PHP, Mastering Blender Python API, and fiction The Algorithmic Serpent, Edward writes with a focus on personal growth, entrepreneurship, and practical success strategies. His work is designed to guide, motivate, and empower.

In addition to writing, Edward offers professional "full-stack development," "database design," "1-on-1 tutoring," "consulting sessions,", tailored to help you take the next step. Whether you are launching a business, developing a brand, or leveling up your mindset, Edward will be there to support you.

Edward also offers online courses designed to deepen your learning and accelerate your progress. Explore the programming on languages like JavaScript, Python and PHP to find the perfect fit for your journey.

📚 Explore His Books – Visit the Book Shop to grab your copies today.
💼 Need Support? – Learn more about Services and the ways to benefit from his expertise.
🎓 Ready to Learn? – Check out his Online Courses to turn your ideas into results.