DEV Community

Cover image for Create Tkinter GUI’s using Tkinter GUI Builder — PyUiBuilder
Paul
Paul

Posted on

6 1 1 2

Create Tkinter GUI’s using Tkinter GUI Builder — PyUiBuilder

If your starting out with tkinter, it can be overwhelming without prior understanding of GUIs. Whether you are trying to make a simple school project or are trying to create an internal application for your company, Tkinter GUI Builder will make this entire process easier.

PyUI Builder demo

PyUiBuilder — An Introduction

PyUiBuilder is a framework agnostic GUI builder tool. Meaning you can use the same GUI builder tool to make GUI’s in tkinter, customtk and others. The best part is that it can generate editable Python code.

Basics of GUI

Before we jump right into the GUI builder it is vital for you to understand some basics of GUI, especially if you have never created a GUI before.

Widgets — widgets are individual components such as labels, buttons, frames etc, that help you build your interface.

Layouts — Layouts define how widgets are arranged within a window or container. They help structure your interface by positioning widgets in a logical and visually appealing way. In Tkinter, you can manage layouts using different geometry managers like:

  1. pack() — Stacks widgets vertically or horizontally. Watch this video to understand how tkinter pack geometry works
  2. grid() — Arranges widgets in a table-like structure using rows and columns.
  3. place() — Positions widgets at exact coordinates. Choosing the right layout method ensures your interface adapts well to different window sizes and screen resolutions.

Here's a video to follow along

Building with PyUiBuilder

Lets start by trying to replicate the Signup form you see above.

step 1: From the sidebar open the widgets tab and drag and drop a frame into the main window.

dnd frame

step 2: By default all the widgets use place layout, meaning they will be added where you drop them, but this won’t be responsive, so we’ll change the flex/pack, by clicking on the main window and from the righ toolbar layout dropdown

responsive

step 3: While this is great, the frame is not at the top, but we need to center it. To center it click back on the frame and from the toolbar go down to Pack Manager and click on expand and set anchor to center.

center the frame

step 4: Now lets set the frame layout (from layouts dropdown) to be flex and add a label widget.

add label

step 5: Now select the label widget and change the label to signup. We can also center this text by going under the styling accordion and changing Text align to center

center the text

step 6: Lets change the background color of the base Frame so there is much more contrast.

Change color

step 7: Now let us add another frame inside that base frame and set its layout to Grid.

Add Base frame

step 8: Let’s give it a margin in the y direction so there’s a space between Frame and Signup label.

margin

step 9: Let’s no configure the Frame’s grid to be 2 rows and 2 cols.

Frame

step 10: Add a 2 labels and 2 Entry widget in the order label -> Entry -> Label -> Entry and you’ll have the following.

Entry

step 11: To finish it off add a button in the main Frame and vola you have a sign up form. Now all you have to do is click on Export code button on top right corner and execute the code and you’ll have something like below.

Button

(Note: tkinter is OS dependent, so if you are on Mac, or windows you’ll see something a bit more different than if you are on a Linux.)

That’s all for now. More tutorial on PyUiBuilder will soon be added. Until then feel free to experiment and try building the UIs


If you have questions or need help her’s an invite to join the Discord server for PyUiBuilder

Top comments (0)

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay