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.
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.
The aim of this video is to add a label widget to our GUI.
Let's add more features to our GUI, namely buttons and text boxes.
While our GUI is nicely improving, it would be more convenient to add a little functionality to our widgets.
The aim of this video is to add more functionality to our GUI.
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.
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.
The aim of this video is to improve the visual aspects of our GUI.
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.
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.
The aim of this video is to explore all there is to know about menu bars.
In order to organize our expanding GUI, we need to create tabs. Let's see how.
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.
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.
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.
This video takes us through customizing our GUI.
The aim of this video is to create Spinbox widgets and to control the appearance of our Spinbox widgets.
This video will take us through adding more useful functionality to our GUI.
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.
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.
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.
The aim of this video is to create reusable components so that we don't have to copy-paste the code right from scratch.
The Matplotlib Python Module enables us to create visual charts using Python 3.
The aim of this video is to download Python modules that we need for creating Matplotlib charts.
We can create charts from only a few lines of Python code. Let's find out how.
So far, we have used the default Matplotlib GUI. Now let's find out how to create some tkinter GUIs using Matplotlib.
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.
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.
The aim of this video is to use core Python to control scaling of charts dynamically.
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.
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.
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.
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.
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.
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.
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.
This video shows how we can easily read entire web pages by using Python's built-in modules.
In this video, we will see how to connect to a MySQL database server using Python connector driver.
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.
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.
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.
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.
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.
The aim of this video is to internationalize our GUI by changing the window's title from English to another language.
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.
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.
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.
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.
We need to test our code both in the design and implementation stages. Here's how to do it.
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.
While Python ships with a Logging module, it is very easy to create our own, which gives us absolute control over our logging format.
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.
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.
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.
The wxPython library does not ship with Python, so in order to use it, we first have to install it.
Running a demo script will give us a basic GUI. We'll need to customize it in order to create our own 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.
Both the wxPython and the tkinter libraries have their own advantages. We'll see what they are by embedding the 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.
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.
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.
The aim of this video is to use the OpenGL library and then enhancing its appearance.
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.
The aim of this video is to create slideshows using all image types.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.