Python GUI Programming Solutions
3.5 (67 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
632 students enrolled

Python GUI Programming Solutions

Over 80 object-oriented tasks to help you create mind-blowing GUIs in Python
3.5 (67 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
632 students enrolled
Created by Packt Publishing
Last updated 2/2018
English [Auto-generated]
Current price: $57.99 Original price: $89.99 Discount: 36% off
7 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 6 hours on-demand video
  • 1 downloadable resource
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Create amazing GUIs with Python’s built-in Tkinter module
  • Customize the GUIs by using layout managers to arrange the GUI widgets
  • Advance to an object-oriented programming style using Python
  • Develop beautiful charts using the free Matplotlib Python module
  • Use threading in a networked environment to make the GUIs responsive
  • Discover ways to connect the GUIs to a database
  • Understand how unit tests can be created and internationalize the GUI
  • Extend the GUIs with free Python frameworks using best practices
Course content
Expand all 70 lectures 06:06:35
+ Creating the GUI Form and Adding Widgets
6 lectures 30:15

Python is a very powerful programming language. So powerful that we can build a GUI in only a few lines of code. Let's see how.

Preview 04:45

The aim of this video is to add a label widget to our GUI.

Adding a Label to the GUI Form

Let's add more features to our GUI, namely buttons and text boxes.

Creating Buttons and Text Box Widgets

While our GUI is nicely improving, it would be more convenient to add a little functionality to our widgets.

Exploring Widgets

The aim of this video is to add more functionality to our GUI.

Adding Extra Features

Copy-pasting code from the previous videos and making local changes to it is cumbersome. We'll restructure our code to make it less redundant.

Adding Several Widgets in a Loop
+ Layout Management
7 lectures 36:52

The Label Frame widget allows us to design our GUI in an organized fashion. By using Label Frame widgets, we get much more control over our GUI design. Let's have a look.

Preview 03:54

The aim of this video is to improve the visual aspects of our GUI.

Using Padding to Add Space Around Widgets

Using tkinter, this dynamic capability creates both an advantage and a little bit of a challenge, because sometimes our GUI dynamically expands when we would prefer it rather not to be so dynamic.

Expanding the GUI Dynamically Using Widgets

The dynamic behavior of Python and its GUI modules can create a little bit of a challenge to really get our GUI looking the way we want. We will see how to embed frames within frames to get more control of our layout.

Aligning the GUI Widgets by Embedding Frames within Frames

The aim of this video is to explore all there is to know about menu bars.

Creating Menu Bars

In order to organize our expanding GUI, we need to create tabs. Let's see how.

Creating Tabbed Widgets

The grid layout manager is one of the most useful layout tools at our disposal. We have already used it in many videos because it is just so powerful.

Using the Grid Layout Manager
+ Look and Feel Customization
5 lectures 24:19

A message box is a pop-up window that gives feedback to the user. It can be informational, hinting at potential problems, and even catastrophic errors. Let's see the difference between each of them.

Preview 04:45

We might customize our message boxes and reuse them in several of our GUIs. This video will take us through creating a small reusable component, which we can then import into different Python GUIs.

Creating Independent Message Boxes

This video takes us through customizing our GUI.

Creating the Title and Icon of the Main Root Window

The aim of this video is to create Spinbox widgets and to control the appearance of our Spinbox widgets.

Using a Spinbox Control

This video will take us through adding more useful functionality to our GUI.

Creating Tooltips and Using the Canvas Widget
+ Data and Classes
4 lectures 23:06

We'll learn how to save data from the tkinter GUI into variables so that we can use that data. After that, we'll see how to capture data from a widget.

Preview 08:14

Global variables can be very useful when programming small applications. They can help to make the data available across methods and functions within the same Python module. Let's check how to do it.

Using Module-Level Global Variables

Once our code gets larger, we need to advance to coding in OOP. This is because OOP gives us great flexibility in organizing our code. Once we use classes, we no longer have to physically place code above the code that calls it.

Improving the GUI by Coding in Classes

The aim of this video is to create reusable components so that we don't have to copy-paste the code right from scratch.

Creating Reusable GUI Components
+ Matplotlib Charts
7 lectures 29:55

The Matplotlib Python Module enables us to create visual charts using Python 3.

Preview 03:55

The aim of this video is to download Python modules that we need for creating Matplotlib charts.

Downloading Modules for Matplotlib

We can create charts from only a few lines of Python code. Let's find out how.

Creating Our First Chart

So far, we have used the default Matplotlib GUI. Now let's find out how to create some tkinter GUIs using Matplotlib.

Placing Labels on Charts

Once we start plotting more than one line of data points, things might become a little bit unclear. By adding a legend to our graphs, we can easily understand a complicated chart.

Giving the Chart a Legend

Hard-coding the scaling of how values are visually represented is not advisable since we'll often plot charts from very large databases. Let's improve our code from the previous video to tackle this.

Scaling Charts

The aim of this video is to use core Python to control scaling of charts dynamically.

Adjusting the Scale Dynamically
+ Threads and Networking
8 lectures 45:50

A tkinter GUI is single-threaded. Every function that involves sleep or wait time has to be called in a separate thread; otherwise, the tkinter GUI freezes. Let's see how to create multiple threads.

Preview 04:56

If we don't call methods of our GUI class to start the threads, the thread gets created but just sits there waiting for us to run its target method. Let's see how to tackle this.

Starting a Thread

We have to start a thread to actually make it do something by calling the start() method, so intuitively we would expect there to be a matching stop() method; but there is no such thing. We'll see how to stop a thread then.

Stopping a Thread

As our GUI is ever-increasing in its functionality and usefulness, it starts to talk to networks, processes, and websites, and will eventually have to wait for data to be made available for the GUI to represent. Creating queues in Python solves the problem of waiting for data to be displayed inside our GUI.

Using Queues

As our GUI code increases in complexity, we want to separate the GUI components from the business logic, separating them out into different modules. This is what we'll do in this video.

Passing Queues among Different Modules

The aim of this video is to use tkinter built-in dialog widgets to copy files from our local hard drive to a network location.

Using Dialog Widgets to Copy Files to Your Network

In this video, we will create our own local TCP/IP server and, as a client, learn how to connect to it and read data from a TCP/IP connection. We will integrate this networking capability into our GUI by using the queues we created in previous videos.

Using TCP/IP to Communicate via Networks

This video shows how we can easily read entire web pages by using Python's built-in modules.

Using URLOpen to Read Data from Websites
+ Storing Data in Our MySQL Database via Our GUI
6 lectures 35:19

In this video, we will see how to connect to a MySQL database server using Python connector driver.

Preview 06:34

Instead of hard-coding the credentials required for authentication, a much safer way to get authenticated by a MySQL server is by storing the credentials in a configuration file, which is what we will do in this video.

Configuring the MySQL Connection

Designing our GUI MySQL database means first thinking about what we want our Python application to do with it and then choose names for our tables that match the intended purpose.

Designing the Python GUI Database

This video will show the Python code to create and drop MySQL databases and tables, as well as how to display the existing databases, tables, columns, and data of our MySQL instance.

Using the SQL INSERT Command

In order to update data we have previously inserted into our MySQL database tables, we use the SQL UPDATE command. This video will take us through it.

Using the SQL UPDATE Command

While deleting data might at first sight sound trivial, once we get a rather large database design in production, things might not be that easy any more.

Using the SQL DELETE Command
+ Internationalization and Testing
11 lectures 01:03:15

The aim of this video is to internationalize our GUI by changing the window's title from English to another language.

Preview 05:47

It is a good practice to avoid hard-coding any strings that our GUI displays. We can separate the GUI code from the text that the GUI displays. Designing our GUI in such a modular way makes internationalizing it much easier. Let's check out how it's done.

Changing the Entire GUI Language All at Once

While we are "internationalized" to a particular country, we work according to our own time zone schedule. This is where localization is used. Let's localize our GUI code.

Localizing the GUI

Internationalization and working with foreign language Unicode characters is often not as straightforward as we would wish. Sometimes, we have to find workarounds. Let's see what those are.

Preparing the GUI for Internationalization

As our code grows in complexity, we might want to refactor our functions into methods of a class. Let's see how it's done.

Designing a GUI in an Agile Fashion

We need to test our code both in the design and implementation stages. Here's how to do it.

Do We Need to Test the GUI Code?

Debug watches help us to create solid code. Stepping through our own code even when not hunting down bugs ensures that we understand our code and can lead to improving our code via refactoring. Let's see how to do it.

Setting Debug Watches

While Python ships with a Logging module, it is very easy to create our own, which gives us absolute control over our logging format.

Configuring Different Debug Output Levels

Python comes with a nice feature that enables each module to self-test. After a few months or years, we sometimes forget what our code is doing, so having an explanation written in the code itself is indeed a great help.

Creating Self-Testing Code Using Python's __main__ Section

Python comes with a built-in unit testing framework, and in this video, we will start to use this framework to test our Python GUI code.

Creating Robust GUIs Using Unit Tests

Python's unit tests are executed with a textural unit test runner, from a console window and even PyDev's graphical unit test feature. Let's explore all of this in the video.

Writing Unit Tests Using the Eclipse PyDev IDE
+ Extending Our GUI with the wxPython Library
6 lectures 32:25

The wxPython library does not ship with Python, so in order to use it, we first have to install it.

Preview 05:36

Running a demo script will give us a basic GUI. We'll need to customize it in order to create our own GUI.

Creating Our GUI

Comparing different libraries gives us the choice of which toolkits to use for our own Python GUI development, and we can combine several of those toolkits in our own Python code. Let's recreate the GUI of the previous sections using wxPython.

Adding Controls

Both the wxPython and the tkinter libraries have their own advantages. We'll see what they are by embedding the GUIs into each other.

Embedding the tkinter and wxPython GUIs into Each Other

When we created an instance of a wxPython GUI from our tkinter GUI, we could no longer use the tkinter GUI controls until we closed the one instance of the wxPython GUI. Let's improve on this.

Using Python to Control Two Different GUI Frameworks

In the previous videos, we found ways to connect a wxPython GUI with a tkinter GUI, invoking one from the other and vice versa. While both GUIs were successfully running at the same time, they did not really communicate with each other. Let's see how to make them communicate with each other.

Communicating Between the Two Connected GUIs
+ Creating Amazing 3D GUIs with PyOpenGL and Pyglet
4 lectures 20:50

Use PyOpenGL to create a GUI. While OpenGL can create truly amazing images in true 3D, we'll run into some challenges along the way. Let's discuss how to work around these challenges.

Preview 06:27

The aim of this video is to use the OpenGL library and then enhancing its appearance.

Our GUI in 3D

Pyglet comes with its own event loop processing power, which enables us to avoid having to rely on yet another library to create a running Python GUI. Let's see how to use it.

Pyglet Transforms Our GUI More Easily Than PyOpenGL

The aim of this video is to create slideshows using all image types.

Creating a Slideshow Using tkinter
  • Some Python programming experience is expected but no knowledge of GUI programming is required to follow this video course.

Python is a multi-domain, interpreted programming language. It is a widely used general-purpose, high-level programming language. It is often used as a scripting language because of its forgiving syntax and compatibility with a wide variety of different eco-systems. Its flexible syntax enables developers to write short scripts while at the same time being able to use object-oriented concepts to develop very large projects.

This course follows a task-based approach to help you create beautiful and very effective GUIs with the least amount of code necessary. This course uses the simplest programming style, using the fewest lines of code to create a GUI in Python, and then advances to using object-oriented programming in later sections. If you are new to object-oriented programming (OOP), this video course will teach you how to take advantage of the OOP coding style in the context of creating GUIs written in Python.

Throughout this course, you will develop an entire GUI application, building features into it and connecting the GUI to a database. In the later sections, you will explore additional Python GUI frameworks using best practices. You will also learn how to use threading to ensure your GUI doesn't go unresponsive.

By the end of the course, you will be an expert in Python GUI programming and will be able to develop a common set of GUI applications.

About the Author

Burkhard A. Meier has more than 15 years' of professional experience working in the software industry as a software tester and developer, specializing in software test automation development, execution, and analysis. He has a very strong background in SQL relational database administration, the development of stored procedures, and debugging code. While he is experienced in Visual Studio .NET C#, Visual Test, TestComplete, and other testing languages (such as C/C++), the author's main focus over the past two years has been on developing test automation written in Python 3 to test the leading edge of FLIR ONE infrared cameras for iPhone and Android smart phones as well as handheld tablets. Being highly appreciative of art, beauty, and programming, the author developed GUIs in C# and Python to streamline everyday test automation tasks, enabling these automated tests to run unattended for weeks, collecting very useful data to be analyzed, automatically plotted into graphs, and e-mailed to upper management upon completion of nightly automated test runs. His previous jobs include working as a senior test automation engineer and designer for InfoGenesis (now Agilysys), QAD, InTouch Health, and presently, FLIR Systems.

Who this course is for:
  • This course is for existing Python developers who are interested in creating immersive user interfaces for their applications.