Here are resources that you can use to build your projects for different platforms:
Choosing a Platform Introduction
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.
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: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: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.
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.
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
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: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.
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.
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.
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
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.
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: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.
Become a Member to join the conversation.