Re: [Tutor] tkinter and messagebox

2013-03-29 Thread eryksun
On Fri, Mar 29, 2013 at 8:00 PM, Clyde Wilson wrote: > > from tkinter import * > root=Tk() > main=Frame(root) > main.grid() > def doit(): > messagebox.showinfo("Hello") You have to import the module first: from tkinter import messagebox http://hg.python.org/cpython/file/bd8afb90ebf2/Lib

[Tutor] tkinter and messagebox

2013-03-29 Thread Clyde Wilson
The following code works fine under IDLE but errors when run as a standalone:   from tkinter import * root=Tk() main=Frame(root) main.grid() def doit():     messagebox.showinfo("Hello") btn1=Button(main,width=10,text="In") btn1.grid() lbl1=Label(main) lbl1.grid() btn2=Button(main,width=10,text="Out

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Alan Gauld
On 29/03/13 12:34, Alan Gauld wrote: A slight tweak to the solution; you probably need: So in pseudo code you should have while True: read input if exit condition break try: convert to int break except ValueError: continue process the value HTH -- Alan G

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Mitya Sirenef
On 03/29/2013 07:33 AM, Ghadir Ghasemi wrote: Hi guys I am trying to create part of a vending machine. The section below is if the user wants to insert 50p coins. It works but when I entered a non integer like 'dfsdf', the program just broke. Is there a way that the program can check if the in

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Mark Lawrence
On 29/03/2013 11:33, Ghadir Ghasemi wrote: Hi guys I am trying to create part of a vending machine. The section below is if the user wants to insert 50p coins. It works but when I entered a non integer like 'dfsdf', the program just broke. Is there a way that the program can check if the input

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Mark Lawrence
On 29/03/2013 12:21, Shall, Sydney wrote: or; where x is the input == fiftypencecoins; return isinstance(x, int) will return True or False Then you can proceed as you wish. If you enter invalid input you'll never get x to be an int so how can you test it with isinstance? -- If you're usin

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Shall, Sydney
On 29/03/2013 11:39, Amit Saha wrote: On Fri, Mar 29, 2013 at 9:35 PM, Amit Saha wrote: On Fri, Mar 29, 2013 at 9:33 PM, Ghadir Ghasemi wrote: Hi guys I am trying to create part of a vending machine. The section below is if the user wants to insert 50p coins. It works but when I entered a no

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Alan Gauld
On 29/03/13 11:33, Ghadir Ghasemi wrote: Hi guys I am trying to create part of a vending machine. when I entered a non integer like 'dfsdf', the program just broke. > Is there a way that the program can check if the input is an integer, Yes you can use try/except to catch the failure. if i

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Amit Saha
On Fri, Mar 29, 2013 at 9:35 PM, Amit Saha wrote: > On Fri, Mar 29, 2013 at 9:33 PM, Ghadir Ghasemi > wrote: >> Hi guys I am trying to create part of a vending machine. The section below >> is if the user wants to insert 50p coins. It works but when I entered a non >> integer like 'dfsdf', the

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Amit Saha
On Fri, Mar 29, 2013 at 9:39 PM, Amit Saha wrote: > On Fri, Mar 29, 2013 at 9:35 PM, Amit Saha wrote: >> On Fri, Mar 29, 2013 at 9:33 PM, Ghadir Ghasemi >> wrote: >>> Hi guys I am trying to create part of a vending machine. The section below >>> is if the user wants to insert 50p coins. It work

Re: [Tutor] How to check if user input is an integer

2013-03-29 Thread Amit Saha
On Fri, Mar 29, 2013 at 9:33 PM, Ghadir Ghasemi wrote: > Hi guys I am trying to create part of a vending machine. The section below is > if the user wants to insert 50p coins. It works but when I entered a non > integer like 'dfsdf', the program just broke. Is there a way that the program > can

[Tutor] How to check if user input is an integer

2013-03-29 Thread Ghadir Ghasemi
Hi guys I am trying to create part of a vending machine. The section below is if the user wants to insert 50p coins. It works but when I entered a non integer like 'dfsdf', the program just broke. Is there a way that the program can check if the input is an integer, and if it is, then the progra