Advertisement
Guest User

Example GUI

a guest
Mar 12th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.messagebox
  3.  
  4. def fx():
  5.     global Input
  6.     result = ""
  7.     n = int(Value.get())
  8.     try:
  9.         for i in range(1,11): # Changed Xrange to range
  10.             result += "{} x {} = {}\n".format(i,n,i*n)
  11.     except NameError:
  12.         tkinter.messagebox.showerror("What Happened?", "Something went wrong!")
  13.     return print(result), tkinter.messagebox.showinfo("Result", result)
  14.  
  15.  
  16.  
  17. App = Tk()
  18. App.title("Your Program!")
  19. App.geometry("400x100+200+200")
  20. App.config(bg="#404040")
  21.  
  22. Instruction = Label(App, text = "Enter an Integer: ", bg="#404040", fg="white")
  23. Instruction.pack(side=TOP)
  24.  
  25. Input = IntVar(None)
  26. Value = Entry(App, textvariable = Input, fg="white",bg="#202020")
  27. Value.pack()
  28.  
  29. Run = Button(App, bg="#202020",width = 20, text = " Do work",fg="white",command = fx)
  30. Run.pack(side=BOTTOM)
  31.  
  32. App.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement