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
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 = ""
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!
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"]
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
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.
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
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 :)
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!
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?
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!
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 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.
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)
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)
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.
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?
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
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.
@@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
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?
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.
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 = []
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.
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)
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 = ""
It was, but it seems they have changed the license not so long ago. I wonder if it's worth just jumping straight into tkinter, there is even bigger tkinter tutorial on his channel
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 ;(
@@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...
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.
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
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
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 = ""
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
Its high time to revisit this amazing series in the perspective of Flet ! Thank you !
Fantastic, really excellent. I haven't had so much fun with a follow-along in years! Thank you!
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?
this is great. i combine this tutorial and another python Text to speech tutorial and made a TexT reader for myself. Great Thanks
Your video is better than most others it should be on top wish UA-cam search was better so that I can filter out useless channels from my search
Please be consistent you will grow because of your content. Thanks ☺️
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!
just thank you! .... YES, its' CLEAR CODE
It is very easy way to understand. Way better than my udemy course.
This is no doubt THE BEST tutorial for beginners! From Scratch WOW
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"]
i can already tell this will be great tutorial for my IQ. thanks!
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
Best Teacher on Py... Please teach us Kivy
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
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.
Finally it's back!
Great video, helpful very much. Keep uploading these informative videos.
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
Great explanation of this nice GUI
Interesting and helpful tutorial! As well as a perfect explanation! Thank you!
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!!!
thanks for great and clear explaination.very helpful to understand the logic using PysimpleGUI.
holy shit..u do actually live up to ur name dont u? that's definitely CLEAR code and CLEAR explanation!! very easy to understand
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
This is a great selection of python projects for beginners. Well done
This is amazing!
Great Video! I think you may have forgotten about the exit option for the text editor.
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
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!
Thank you
Love your vids! Thank uuu
Great tutorial
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 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.
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)
Nice video but what are your sublime text packages ?
Love your voice.
Thanks a lot ,,,, Super nice and clear
Fantastic!
ohh thank you so much for making the module! :)
@@ClearCode ❤
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)
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!
Thank you!
ah what a nice tutorial!
wait what its 4 hours
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.
Stop-watch part, time module is not working on my pycharm, with PySimpleGUI, what to do?
Hai sir,can we change pySimpleGUI to .apk?
"import PySimpleGUI as sg":
my vscode defaulted py as the shortcut for PySimpleGUI
Hey why is the app pop up not coming up for me when i launch my code?
How can I add a clickable hyperlink (url) or a button to my PySimpleGUI code
1:23:10 Time out
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?
Thanks
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?
I wish you can make a Chess game tutorial made in Python.
1 more vote for chess game
@@hillarymapondera4122
Indeed. ✅
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.
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.
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
Add a line to the else: of converter to clear the -INPUT-
window['-INPUT-'].update(' ')
my contribution to the 1st app
hey, can we share the app with someone without displaying the code to them?
Can't we make all of these with tkinter?
you can, pysimplegui is actually just a wrapper for tkinter
My Visual Studio code won't open the program window why is that??? Can someone help me please!?
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?
1:37:36
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
Oh..
Wow...
✅✅✅✅✅✅✅✅
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.
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 = []
This looks familiar... 🧐
wdym?
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.
Can you update the pastebin?
Hi, can you teach pyqt5?
What are you finding difficult? Qt designer is just drag and drop :) I have many projects using it :)
spyder doesn`t like syntax "match values['-UNITS-']:" . Anyone having the same problem?
Stopwatch don’t work after pressing the reset button😢
It will be nice if not a huge size of output exe file
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 ?
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 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 convert pygame code into apk
they reallly made pysimplegui register to use wasnt it open source?
It was, but it seems they have changed the license not so long ago. I wonder if it's worth just jumping straight into tkinter, there is even bigger tkinter tutorial on his channel
Please make open cv tutoriol
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
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...
I think this video was restricted by youtube for the project - youtube video downloader.
How to export a game to exe
54:20
I see what they were going for with pysimplegui but I think tkinter is simpler actually ... Am the only one that thinks so ?
Work all day and then i wake up work all day and then i wake up code all day😂
man can you teach us kivy
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.
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😡😡😡😡😡🤬🤬🤬🤬🤬😠😠😠😠😠😡
Is that a reupload?
made a community post about it!
Esperamos un tutor con Qt que es mas avanzado
Great tutorial