Creating 10 Apps in Python [ with PySimpleGui ]
HTML-код
- Опубликовано: 21 май 2024
- In this video you will learn how to create simple python GUIs using the PySimpleGUI library. There are 10 projects in this video: A converter, a calculator, a stopwatch, a text app, the snake game, an image editor, a music player, a weather app and a opencv face detector. There is also an extra video about creating a gui in a single line of code.
By the end of the video you should be comfortable understanding PySimpleGUI and solve more or less any problem inside of it. The video will also use popular python modules like matplotlib, opencv, pytube, pillow and BeautifulSoup4.
If you want to support me: / clearcode
(You also get lots of perks)
Social stuff:
Twitter - / clear_coder
Discord - / discord
Timestamps:
0:00:00 - Intro
0:03:48 - Converter
0:37:00 - One line app
0:38:46 - Calculator
1:09:06 - Stopwatch
1:36:14 - Text editor
1:57:10 - Snake
2:29:40 - Graph app (MatPlotLib)
2:47:50 - Image editor (Pillow)
3:11:06 - Music Player
3:48:59 - Weather app (BeautifulSoup4)
4:08:14 - Face detector (OpenCV)
Github:
github.com/clear-code-project...
Pastebin:
Weather app - pastebin.com/LHPdVbgq
Stopwatch - pastebin.com/bHP6GppS
Face Detector (open cv) - pastebin.com/3BKFmubT
Snake game - pastebin.com/zRZvssxB
Text editor - pastebin.com/NWDb2Pjw
Image editor (Pillow) - pastebin.com/H3QCwQgX
Graph app (Matplotlib) - pastebin.com/dES5Qp4B
Calculator - pastebin.com/h2W5t35L
Converter - pastebin.com/aDVADH7R
One line app - pastebin.com/4rvyhcJx
music player - pastebin.com/DZfqjwMs
If you enjoy this video and want to support me you can join my Patreon or buy my Udemy course
patreon.com/clearcode
udemy.com/course/learn-python-by-making-games
I got your Udemy course on Python. I feel bad that I only paid £14 but I'm a poor person, lol, thanks for the wonderful tutorials. really very good.
i will not pay for it
@@nitinsansi8528 good
@@patel_rohan1702 someone understands me
@@nigelpallatt L bozo
Fantastic, really excellent. I haven't had so much fun with a follow-along in years! Thank you!
Its high time to revisit this amazing series in the perspective of Flet ! Thank you !
Fun tutorial!
1:08:20 To give the calculator a tiny little more functionality, under the if event == 'ENTER', you can add
current_num = [] # empties the current number list
current_num.append(str(result)) # appends the result / ans to the current num list
calculator has a lots of bug , I totally change the mechanisem ,, in your approach if someone press two operation you got problem, i design three fumction to solve all of it
def button_press(num):
global equation_text
equation_text = equation_text + str(num)
equation_label.set(equation_text) # window['-TEXT-].update(equation_text)
pass
def equals():
global equation_text
try:
ttry:
total = str(eval(equation_text))
equation_label.set(total) ## window['-TEXT-].update(equation_text)
equation_text = total
equation_text = total
except SyntaxError:
equation_label.set("Syntax Is Invalid") #window['-TEXT-].update(equation_text)
equation_text = ""
except ZeroDivisionError:
equation_label.set("Devided By Zero") #window['-TEXT-].update(equation_text)
equation_text = ""
def clear():
global equation_text
equation_label.set("")
equation_text = ""
this is great. i combine this tutorial and another python Text to speech tutorial and made a TexT reader for myself. Great Thanks
Great video, helpful very much. Keep uploading these informative videos.
This is no doubt THE BEST tutorial for beginners! From Scratch WOW
Interesting and helpful tutorial! As well as a perfect explanation! Thank you!
simple application enter your details
ruclips.net/video/DWn5-Ej8R-M/видео.html
This is amazing, I always wanted to have an option to create an option to create a Dynamic Theme changer event/button. Never found anything on the web, and it's pretty interesting and informative to see your approach!
thanks for great and clear explaination.very helpful to understand the logic using PysimpleGUI.
Please be consistent you will grow because of your content. Thanks ☺️
This is a great selection of python projects for beginners. Well done
Great explanation of this nice GUI
just thank you! .... YES, its' CLEAR CODE
Love your vids! Thank uuu
Your video is better than most others it should be on top wish RUclips search was better so that I can filter out useless channels from my search
i can already tell this will be great tutorial for my IQ. thanks!
This is amazing!
I've highly been enjoying your Udemy course lately. Been having lots of fun learning with it.
nerd
@@nitinsansi8528 😂
@@nitinsansi8528 The hell are you doing here then?
Finally it's back!
Very nice video. You could add a little more code in the stop watch since at the moment the lap function does not really create "Lap Times". It just stores the current value for the overall elapsed time. For example if the first Lap is 2 seconds long the the second one is one second long this would show: Lap 1: 2; Lap 2: 3 instead of Lap 1: 2; Lap 2: 1
Thanks a lot ,,,, Super nice and clear
I have just enrolled in your Udemy course, I truly can not understand how you can have such organisational ability in your teaching! Very impressive.
u wasted your money
@@nitinsansi8528 SHUSH BROKEY
Great Video! I think you may have forgotten about the exit option for the text editor.
Great tutorial
Best Teacher on Py... Please teach us Kivy
It is very easy way to understand. Way better than my udemy course.
for the snake part if you do not want your snake to go opposite way you can use something like this:
if event == "Left:37" and direction != DIRECTIONS["right"]:
direction = DIRECTIONS["left"]
Thank you!
Thank you for your sharing.
And could you please tell me: how to remove an element in sg.cloumn when window.read(timeout 10) is running?
Hi! I don't know if you reply or not, but i have a question. I'm developing an app that will help me calculate the dimension of components, and i noticed that if i lay it down like the first demonstration and i put in negative numerical values it recognizes them as string values, not numerical values. I managed to work around it without implementing the numerical check but i want to have a safer insertion. Is there a workaround?
In the text editor 1:48:04 u should add:
if char_count == 0: word_count = 0
so that when you have nothing in there it wount tell u that u have 1 word
holy shit..u do actually live up to ur name dont u? that's definitely CLEAR code and CLEAR explanation!! very easy to understand
Nice video but what are your sublime text packages ?
Love your voice.
If that is you right in the beginning, congrats on looking like Tom Cruise. Also, what an amazing resource. Going to tackle this after I finish your udemy course. Thank you for being my mentor!!!
GraphApp, this is not working: fig = matplotlib.figure.Figure(figsize = (5,4)). Had to use this instead (from pyplot): fig = plt.figure(figsize = (5,4)). I don't know if this is system related issue but "figure" is not an attribute of matplotlib... Just FYI :)
thanks
Thanks for help, I looked through the comments looking if anyone else hit this issue.
@@benmaks you're welcome 😀
Or you can do this import matplotlib.pyplot as plt
4:02:38 Google must have changed the layout of the weather page because all I'm getting when I print the name is 'Weather'. I downloaded your code from GitHub and it does the same thing (just displays 'Weather' where the city name should be). Any idea how to fix? I tried looking at the html for the page but it is a lot of code.
Thanks
At 33:07 I found it much easier to just use this:
if event == 'button1' and values[0] == 'km to miles':
input = int(values['input1'])
window['outputText1'].update(input / 1.609 )
and then use the asterisk operator to do the opposite
definitely make 'km to miles' a variable like KM_TO_MILES. This means you can also make it a number which is a bit easier to check
I'm just researching to decide on which python gui to put effort into to get started with. You mentioned that PySimplegui is wrapped around others such as Tkinter and qt....... would it be more beneficial to learn those first?
If you just want to make guis and don't care about looks very much just go with PySimpleGui, it is by far the easiest to learn. I will release a long series on tkinter in a few weeks, that will cover much more sophisticated stuff.
Enjoying this tutorial very much and learning a lot!
However, when programming the graph.py progam, i get this error:
AttributeError: module 'matplotlib' has no attribute 'figure'.
Any ideas on a work-around? Thanks!
import matplotlib.figure
will fix attribute error.
Just import matplotlib.pyplot as plt
Hai sir,can we change pySimpleGUI to .apk?
Thanks for this. what kind of project would you do to land a job as python dev? a project large and good enough to get noticed in CV. can you something like that. or can you suggest something.
I am trying to work on a table and backend it’s connected to the db. But after making the list empty, the table click event is always true and it’s throwing error, array out of index.
1:52:58 you could just use:
file = open(file_path,'r+')
wn['-TEXTBOX-'].update(file.read())
no need to import anything, is this not a good way to do it?
ah what a nice tutorial!
wait what its 4 hours
Great video.
At 33:59
After the window['-OUTPUT-'].update(output_string)
I got an error saying
output_string is not defined.
I get the same error for some reason, did you manage to get it fixed?
@@officialfarhad7033 hey, i make all code in visual studio 2022 and it doesn't show any errors, but when i start my thing a got stupid error - No module named 'PySimpleGUI', it doesn't work when i make new environment for using python 3.11 because without it i can't use match...
Do you know how to solve it? Because i've already updated and downloaded PySImpleGUI at all, and just get it
Oh..
Wow...
✅✅✅✅✅✅✅✅
I must be wrong but just yesterday I was searching for this video and didn't find it. Might I ask why did you reupload this?
made a community post about it!
How can I add a clickable hyperlink (url) or a button to my PySimpleGUI code
at 2:40:00 with the graph app, I get an error "AttributeError: module 'matplotlib' has no attribute 'figure'," my include is imported but all of the library has no such thing as figure, what do?
Same issue, been googling but getting nothing
Ok I just figured it out. I added 'import matplotlib.pyplot as plt at the top. But I was still apple to use fig = matplotlib.figure.Figure(fig size = (5,4)). I even commented out the import of pyplot and it stopped working but by just having that import line of code at the top helped...weird but it worked!
for the converter example, while running the code
"match values['-UNITS-']:"
it is throwing me an error, stating invalid syntax.
match only works with python 3.10 or greater. You probably have an older version.
you can use an if elif else statement in place of the match to make it work,
setting units = values['-UNITS-'] makes the if statement read like:
if units == 'km to mile': ... elif units=='kg to pound': etc.
1:47:00 In the Text Editor the word count is wrong when there are chain of white spaces or new rows. Use split() without arguments to fix it. Cheers!:
clean_text = full_text.replace('
', ' ').split()
if full_text == '':
word_count=0
else:
word_count = len(clean_text)
hey, can we share the app with someone without displaying the code to them?
Sorry for my question, I am a very beginner, and I am not sure where I should start, is it a terminal window ? or a python window? or what ? I am looking forward to start it as soon as I now where I should start typing the code.
Right, first I recommend learning a bit of python first from some online videos. Apps are not for a person who has no experience with a language.
I'm having problems with installing tkinter. I type in the cmd 'pip install PySimpleGUI' as instructed and when I try to import it, I get an error saying tkinter is not installed. I try pip installing tkinter and all I get is an error message. Any idea whats wrong?
tkinter is usually installed when you install Python, not via pip. The easiest fix is probably to reinstall python and make sure you tick the box to install tkinter. Look for a checkbox that inlcudes tcl/tk
@@ClearCode Okay. I'll try that. Thanks.
Stop-watch part, time module is not working on my pycharm, with PySimpleGUI, what to do?
HELP! I got error here (32:30) when i wrote "match" because i had python 9, but i need python 10 and more, i dowloaded new python and chose new interpreter in Visual Studio, but now i have error - No module named 'PySimpleGUI', i downloaded it and trying to update but i already did everything it, who knows what's the problem can be?
I wish you can make a Chess game tutorial made in Python.
1 more vote for chess game
@@hillarymapondera4122
Indeed. ✅
Did the videos get deleted, it says it was uploaded 11 hrs ago, but I remember this being uploaded a while ago.
yeah you're right, just check his community post :D
for stopwatch part if you dont want to close and make new window you can try this:
if event == 'Start':
if active:
# from active to stop
active = False
window['Start'].update('Reset')
window['Lap'].update(visible = False)
else:
# from stop to reset
if start_time > 0:
window['TEXT'].update('Time')
window['Start'].update('Reset')
window['Start'].update('Start')
start_time = 0
# from start to active
else:
start_time = time()
active = True
window['Start'].update('Stop')
window['Lap'].update(visible = True)
if active:
elapsed_time = round(time() - start_time,1)
window['TEXT'].update(elapsed_time)
the calculator has lots of bug i solve some of them but still i need to prevent two operation ( pop one item if full_operation[-2] in operations ) that needs to be done but the enter got to change to
if event == 'Enter':
full_operation.append(''.join(current_num))
result = eval(' '.join(full_operation))
window['-TEXT-'].update(result)
current_num=[]
current_num.append(str(result))
print(full_operation)
print(current_num)
full_operation = []
My Visual Studio code won't open the program window why is that??? Can someone help me please!?
"import PySimpleGUI as sg":
my vscode defaulted py as the shortcut for PySimpleGUI
I can start the GUI no problem but the theme_menu won't work for me. Can anyone help me? I use a MacBook Air M1
Hello, about 14:46, when I try to add
while True:
event, values = window.read()
if event == sg.WIN_CLOSED:
break
window.close()
Python doesn't seem to understand window.read() and window.close()
(I'm running on VSCode , Python 3.7 32bit windows 7. I'm broke here and I can't buy new Windows PC, even just celeron based. My country's food inflation is skyrocketing and I have to stick to this old laptop for longer)
cap sensitive ?
Can you update the pastebin?
2:02:10
Snake game
Does anyone know key codes for Mac OS? The codes in this video don't work to me.
Finally I got it!
You can check the key codes by putting `print(ord(event[0]))` in `while True`.
The output for Left Arrow is 76 which is an integer.
`if ord(event[0]) == 76: print('left')` works perfectly!
I don't know why `if event == 'Left:76': print('left')` doesn't work though ;(
@@MMMMMM-fn6cf Thanks bro, saved me a lot of time, couldn't find anything online
Hi, can you teach pyqt5?
What are you finding difficult? Qt designer is just drag and drop :) I have many projects using it :)
1:37:36
This looks familiar... 🧐
wdym?
1:23:10 Time out
It will be nice if not a huge size of output exe file
Please make open cv tutoriol
Add a line to the else: of converter to clear the -INPUT-
window['-INPUT-'].update(' ')
my contribution to the 1st app
spyder doesn`t like syntax "match values['-UNITS-']:" . Anyone having the same problem?
Stopwatch don’t work after pressing the reset button😢
why does my "match" statement doesn't work?
because your python version is too old. Uninstall and reinstall python with the latest one and you should be good.
@@ClearCode Hi, i downloaded python 3.11 and make for it environment in Visual Studio 2022, but i still get error - No module named 'PySimpleGUI', that's very strange because Visual Studio shows me that the project doesn't have any issues...
for calculator I find lots of bugs i made three main function that UI can call them this approach I have not had a bug
def button_press(num):
global equation_text
equation_text = equation_text + str(num)
equation_label.set(equation_text)
pass
def equals():
global equation_text
try:
total = str(eval(equation_text))
equation_label.set(total)
equation_text = total
except SyntaxError:
equation_label.set("Syntax Is Invalid")
equation_text = ""
except ZeroDivisionError:
equation_label.set("Devided By Zero")
equation_text = ""
def clear():
global equation_text
equation_label.set("")
equation_text = ""
How to export a game to exe
Can't we make all of these with tkinter?
you can, pysimplegui is actually just a wrapper for tkinter
Why did you reupload?
made a community post about it!
The other video had a downloader app made with PyTube. So, someone flagged the video and it was taken down. Now, the Ytube downloader app was replaced with a music player. I think that's what happened.
Work all day and then i wake up work all day and then i wake up code all day😂
54:20
How to convert pygame code into apk
I think this video was restricted by youtube for the project - youtube video downloader.
man can you teach us kivy
Is that a reupload?
made a community post about it!
I see what they were going for with pysimplegui but I think tkinter is simpler actually ... Am the only one that thinks so ?
Output string is not defined is ruining my life. Who else is having this recurring problem. It’s infuriating. I’m using PyCharm and I think the way the modules are employed is different from Sublime. Tips
I KEEP GETTING SO MUSCH FREAKING ADSS😡😡😡😡😡🤬🤬🤬🤬🤬😠😠😠😠😠😡
Esperamos un tutor con Qt que es mas avanzado
Great tutorial