The Label Frame widget allows us to design your GUI in an organized fashion. By using Label Frame widgets, you get much more control over your GUI design. You can have a look.
- [Narrator] Hey There! And welcome to the second section of this course, on Layout Management. Last time, we saw how to create a GUI form and adding widgets. In this section, we will explore how to arrange widgets, within widgets, to create our Python GUI. Learning the fundamentals of GUI layout design will enable us to create great looking GUI's. There's certain techniques that will help us to achieve this layout design.
The grid layout manager is one of the most important layout tools, built into Tkinter, that we will be using. We can very easily create menu bars, tabbed controls, also known as notebooks, and many more widgets, using Tk. One widget, that is missing out of the box, from Tk, is a status bar. In this section, we will not bother to handcraft this widget. But be sure that it can be done. Now, straight on to the first video of this section.
Here, we will look at arranging labels, within a label frame widget. We will take a look at the label frame widget, and play around with the row and column variables, to arrange the widgets horizontally and vertically. The label frame widget allows us to design our GUI in an organized fashion. We're still using the grid layout manager as our main layout design tool, yet by using label frame widgets, we get much more control over our GUI design. We're starting to add more and more widgets to our GUI, and we will make the GUI fully functional in the coming videos.
Here, we're starting to use the label frame widget. We will reuse the GUI, from the last video of Section One. I created a new file: ArrangingLabels.py. What I've done here is I've added this code just above the main event loop, toward the bottom of the Python module. Here, we've created our first ttk label frame widget, and given the frame a name. The parent container is win, our main window.
The name ttk stands for Themed Tk. The Tk themed widget set was introduced in Tk 8.5. The three lines following comment to create label names and place them in the label frame. We're using the important grid layout tool to arrange the labels within the label frame. The column and row properties of this layout manager gives us the power to control our GUI layout.
The parent of our labels is the label frame, not the win instance variable of the main window. We can see the beginning of the layout hierarchy here. Now, let's check the output of this code. As you can see, the labels have been arranged horizontally. Great! We can easily change the layout of the labels to be arranged vertically using the column and the row variables. Let's see the effect...
and voila! The labels are arranged vertically. See how easy it is to change our layout, via the column and row properties? We just changed the column to zero and we layered our labels vertically, by numbering the row values sequentially. Excellent! That brings us to the end of this short video, on arranging labels, using the label frame widget. In the next video, we'll see the use of padding to add space around widgets.
Join me there!
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Creating buttons and widgets
- Adding labels and features
- Expanding a GUI dynamically
- Aligning frames and embedding frames
- Creating menu bars, message boxes, and tooltips
- Using module-level global variables
- Coding in classes
- Using Matplotlib to create charts
- Working with multiple threads, queues, and TCP/IP
- Using URLOpen to read data from websites
- Localizing a GUI and preparing for internationalization
- Testing a GUI using unit tests and Eclipse PyDev IDE
- Using the wxPython library
- Using Tkinter, PyOpenGL, and Pyglet
Skill Level Intermediate
Python GUI Development with Tkinterwith Barron Stone4h 55m Intermediate
1. Creating the GUI Form and Adding Widgets
2. Layout Management
3. Look and Feel Customization
4. Data and Classes
Using the StringVar() type8m 14s
5. Matplotlib Charts
6. Threads and Networking
7. Storing Data in Our MySQL Database via Our GUI
8. Internationalization and Testing
9. Extending Our GUI with the wxPython Library
10. Creating Amazing 3D GUIs with PyOpenGL and Pyglet
11. Best Practices
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.