Python Forum
How old am I? (first gui script)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How old am I? (first gui script)
#1
Original script:
Apart from the fact being that this is is my first fully-made gui script ever, this script is also coming from a newbie! So I might not understand all terms.. Angel

I spent a lot of time making sure everything was correct. But please suggest me better alternatives or warn me of bad practices I might have used. Big Grin

The script is pretty simple it gives you three input fields, makes sure you type in correct values (example cannot type 3 as first digit in year's field) with the help of textvariable, and pops up how old you are in minutes when you click on "That's me!".

Also, when you run the tkinter messagebox version (below over here), you will notice that the button gets stuck every time the message pops up? I changed the module because of that reason do you guys know why that is happening?

If you want to run the script here are instructions:


Use this version of the code instead (uses tkinter messagebox instead) if you do not have pymsgbox:

-> Known issue: Button gets stuck when message pops up. Don't know why that happens.



Oh and here are the pictures I used just by the way:
(I'll upload them later Razz )

Thanks for reading!
Reply
#2
for start:
Read PEP8 for Style Guides, e.g. naming conventions
Read about String formatting, e.g. instead of defining function to add commas
Use IntVar, instead of StringVar
Use datetime module to construct date from user input and it will be way easier to check the input - e.g. is it valid date, is it before today, etc.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
Thanks I appreciate it. Do you face what I did when running tkinter's messagebox? Every time the messagebox pops up the button that spawns the messagebox gets stuck.. I was wondering if it's just me.
Reply
#4
I didn't run it
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Normally you would display the result in a widget, e.g. label, not messagebox.
Also, get rid of using global variables
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(Jun-27-2018, 03:46 PM)buran Wrote: Normally you would display the result in a widget, e.g. label, not messagebox. Also, get rid of using global variables

I want a secondary window to display errors (the result is just temporarily using the msgbox in the future it will pop a window with a picture in it), so messagebox from tkinter seemed very convenient. But this malfunction seems to occur to me with both my GUI scripts so I have to use another function instead of messagebox.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020