Set a integer limit in a entry widget in tkinter (python)
Question: How do I make it so that if person enters a number higher than 3000, it prints
out a custom message instead of calculating the factorial of that certain
number?

I've tried 'if number > 3000, print "blah blah blah"', but it doesn't work.
Think it has something to do with tkinter.

    
    
    from Tkinter import *
    import tkMessageBox, os
    
    #calculates factorial of inputNumber
    def calculate():
        number = inputNumber.get()
        inputNumber.delete(0, END)
        product = 1
        for i in range(int(number)):
            product = product * (i+1)
        facAnswer.delete(1.0, END)
        facAnswer.insert(END, product)
    
    cal = Tk()
    cal.title("Factorial Calculator")
    cal.geometry('450x300+200+200')
    
    #Enter the number you want the factorial of 
    factorialNumber = IntVar()
    inputNumber = Entry(cal, textvariable=factorialNumber)
    inputNumber.pack()
    
    #executes calculate function by pressing button
    enterButton= Button(cal, text="CALCULATE!", width=20,command=calculate)
    enterButton.pack(side='bottom',padx=15,pady=15)
    
    #Where the answer appears:
    facAnswer = Text(cal)
    facAnswer.insert(END, "Answer:")
    facAnswer.pack()
    
    cal.mainloop()
    


Answer: It seemed to work for me. You could put everything in a class,  
and try using `get()` on `factorialNumber`, to see if it makes a difference.

    
    
    import Tkinter as tk
    
    class GUI(tk.Tk):
        def __init__(self):
            tk.Tk.__init__(self)
    
            self.title("Factorial Calculator")
            self.geometry('450x300+200+200')
    
        # Enter the number you want the factorial of
            self.factorialNumber = tk.IntVar()
            self.inputNumber = tk.Entry(self, textvariable=
                                        self.factorialNumber)
            self.inputNumber.pack()
    
        # executes calculate function by pressing button
            enterButton= tk.Button(self, text="CALCULATE!",
                                    width=20,command=self.calculate)
            enterButton.pack(side='bottom',padx=15,pady=15)
    
        # Where the answer appears
            self.facAnswer = tk.Text(self)
            self.facAnswer.insert('end', "Answer:")
            self.facAnswer.pack()
    
    
        def calculate(self):
            number = self.factorialNumber.get()
            if number > 3000:
                print('The number is out of range.')
            else:
                self.inputNumber.delete(0, 'end')
                product = 1
                for i in range(int(number)):
                    product = product * (i+1)
                self.facAnswer.delete(1.0, 'end')
                self.facAnswer.insert('end', product)
    
    
    gui = GUI()
    gui.mainloop()
    

