Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Choosing a Platform Introduction

Here are resources that you can use to build your projects for different platforms:

  • colorama: Cross-platform colored terminal text
  • Flask: A lightweight WSGI web application framework for Python
  • Bootstrap: Framework to design and customize responsive mobile-first sites
  • PySimpleGUI: Python GUI For Humans
  • PyQT5: Python bindings for the Qt cross platform application toolkit

00:00 Choosing a Project Platform. Command-line applications typically run in a console window. This would be the command prompt on Windows and the Terminal on Linux and Mac.

00:12 You click to use a web or GUI application, but you type in commands for command-line applications. Users of CLI applications typically have to have some technical knowledge as they’re going to need to use these commands and understand the menu structure of a program, if applicable. CLI applications may not be as beautiful or as easy to use as a web or GUI application, but that doesn’t mean that they’re less powerful.

00:35 It’s possible to improve the look of CLI applications by applying colors to the text. Let’s take a look at that in action with the colorama library.

00:44 Here’s a simple example of a menu which would appear in a typical CLI program. As you can see, it’s not particularly engaging. While all of the options are there, so we can see which keyboard shortcuts are going to work for a particular menu, it’s not particularly easy to see what’s working. However, here you can see the example has been colored using the colorama library and the keyboard shortcuts are in bright yellow, making them stand out on the screen. By applying a consistent color theme across your CLI app, you’ll be able to make the user’s life much simpler.

01:16 Let’s look at some of the pros and cons of command-line based projects. Firstly, on the pros side, command-line based projects are quick to develop. They’re the kind of things you program when you first started out programming in Python, and you don’t have to spend a lot of time dealing with user interface issues.

01:33 For this reason, they’re simple to debug. There’s not much between you and the program itself, and it’s easy to insert statements that allow you to see what’s going on within the program.

01:43 They can be great for power users as they offer a no-frills way to access the functionality of the program. Now, let’s look at some of the downsides of CLI programs. Firstly, they’re not particularly user-friendly. While you as a programmer may find them simple and easy to use, the average user will probably find them a little bit bewildering and unfriendly.

02:04 They can be difficult to distribute as they will probably rely on someone having a working Python installation of the correct version before they’ll be able to get it up and running, so it may well be limited to those power users we discussed previously.

02:17 This means they’ll be limited to technical users only, which probably limits the scope of your program’s usefulness across the entire user base. Next, web applications.

02:29 Web applications run on the web and they can be accessed on pretty much any device without being downloaded, providing there is internet access. If you want your project to be accessible to a wide range of users quickly, it needs to be a web application. A web application has a back end and a front end.

02:46 The back end is the part where the business logic is that manipulates and stores data. The front end is the interface to the user. It determines the look of the web application.

02:56 Most of your focus will be on the back end code; however, front end code is important too, as we’re going to see, so you’ll need some knowledge of HTML, CSS, and possibly JavaScript to create a simple-looking interface.

03:09 But just the basics will be enough. Fortunately, with freely available libraries such as Bootstrap, it’s possible for a Python developer to create a web application which still looks modern despite not needing a great deal of technical knowledge in terms of CSS and JavaScript. Let’s take a look at that in action.

03:29 So, here is a simple single-page Flask web app which just has some example HTML elements in it. We can see we’ve got a heading, we’ve got some radio buttons,

03:45 we’ve got a text area,

03:47 and then what would probably be a submit button.

03:52 Let’s take a look at what that looks like with no styling.

03:59 Here, we can see our unstyled Flask web app. As you can see, it doesn’t look great. It looks like something from the late 90s, and while that isn’t actually a reflection on how competent the business logic is, a lot of users would be turned off by this and think this looked like something that had just been thrown together.

04:17 Fortunately, Bootstrap means we can style these elements and make it look much more modern with very little effort. Here you can see the Bootstrap-styled version, and the additions are pretty minimal. There’s just this Bootstrap CSS link in the <head> section,

04:35 and then this JavaScript at the end of the <body>. In addition, the only change to the HTML is that the <button> has had this class added to it.

04:45 Now, let’s see what that looks like. As you can see, this looks a lot better. This is the kind of thing where a user would think, “Yeah, this looks modern,” and despite the fact that the business logic could be exactly the same as the previous one we’ve seen, we know that a lot of people do judge the book by its cover.

05:02 So just by the addition of a few lines of code, you can spruce up the way your application looks and give users a lot more confidence that you’ve programmed it well. Now, let’s take a look at some of the pros and cons of web-based projects.

05:16 Firstly, they have a good user experience. Most people are used to using web apps and don’t even think about the fact that actually, they’re interacting with a program. Secondly, they’re as near to universal as it’s possible to get. Anyone who has a computer with an internet connection will be able to access your app. Third, there’s no installation needed.

05:37 People would just be able to access your program, probably without even realizing that they are running a program. And finally, there’s only one installation for all users.

05:46 You won’t have to worry about individual machine configurations, different Python versions, and upgrading when the time comes. Now, let’s look at some of the downsides of web-based projects.

05:57 Firstly, they’re of moderate complexity—depending on the application, of course. There’s a lot more boilerplate code that needs to go into it, and you need to understand new technologies, so you won’t just be able to program this solely with Python.

06:11 You’ll need to learn at least a little HTML, possibly some CSS, and JavaScript as well to get your application to run in a smooth, modern-looking manner. Thirdly, security; you need to be aware of the implications of storing users’ data and how to store it safely and securely.

06:29 You need to keep up with any security updates which are needed in any of the frameworks you’re using and monitor your program to see if everything is working as you intended. Desktop GUI.

06:41 Every time you run a program on your computer, whether it’s Windows, Mac or Linux, desktop or laptop—it’s through an application which will use the computer’s native GUI.

06:51 No front end technology is needed to create a GUI, as you can build it all with Python. GUI frameworks are available for Python such as PySimpleGUI, which—as its name implies—is simple and user-friendly.

07:04 There’s also the much more advanced PyQt5, which is extremely powerful, but the learning curve is pretty steep. Let’s take a look at code for both those frameworks.

07:14 So, here you can see some code using PySimpleGUI for a straightforward application. All it will do is create a window onscreen, ask for some text, and then, on pressing a button, will repeat that text in a popup. So, we have the layout that’s needed with different elements, such as text, input, and our buttons.

07:35 We then create the Window, and here we have our event loop, which deals with the events in the program, including pressing the quit button, taking the value from text input, and then creating our popup.

07:49 Let’s see that code running. So, as you can see, the GUI is fairly small, so we’re going to zoom in on it so you can see it better. Here I’m going to enter some text and now I’m going to click the Submit button and you can see the popup has appeared. I can click OK to dismiss it, and then I can quit the program using the Quit button.

08:12 Here’s that same application coded using PyQt5. As you can see, there’s much more code and we’ve needed to be more explicit about nearly every element of the program. PyQt5 is much more powerful than PySimpleGUI, but with that power comes the responsibility of needing to set every element of the program’s operation and appearance. However, when we see it running…

08:37 So, once again, I’m just going to zoom in on the screen so you can see this more clearly. Type in the text,

08:44 click the Submit button—and you can see the popup appears. We can quit using the Quit button.

08:51 Now, let’s look at some of the pros and cons of desktop GUI-based projects. Firstly, on the upside, they’re great for users. Most people will have used a desktop computer before and they’ll understand all of the paradigms they need to make your program run. In addition, most frameworks will look native to the system that they’re running on, so most people won’t even be aware that they’re running a Python program.

09:13 Secondly, there are tools to allow them to be distributed and installed, so it’s possible to bundle up, effectively, a Python installation and your application and get the user to install that, so you can send them just a single file and they’ll install it in the way they would any other program. Thirdly, because of Python’s nature, they can be cross-platform, and if you use the right GUI toolkit, they will look as if they belong on the system natively.

09:38 Now, let’s look at some of the downsides of desktop GUI-based projects. Firstly, there’s typically a steep learning curve for a GUI framework. This means you’ll spend a lot of time understanding how to create windows and widgets rather than dealing with your program’s business logic. Secondly, you need one installation per user.

09:58 This is in contrast to the web, where a single installation may be able to serve many hundreds or thousands of users. This means managing things such as updates becomes much more complicated.

Become a Member to join the conversation.