Advertisement
gregwa

Beginning Python #25 Examples 1,2 and 3

Jul 7th, 2011
647
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Example 1
  2. from Tkinter import *
  3.  
  4. root = Tk()
  5. button = Button(root, text = "Hello FullCircle").grid()
  6. root.mainloop()
  7.  
  8. #Example 2
  9.  
  10. from Tkinter import *
  11.  
  12. class App:
  13.  
  14.     def __init__(self, master):
  15.  
  16.         frame = Frame(master)
  17.        
  18.         self.lblText = Label(frame, text = "This is a label widget")
  19.         self.btnQuit = Button(frame, text="Quit", fg="red", command=frame.quit)
  20.         self.btnHello = Button(frame, text="Hello", command=self.SaySomething)
  21.         frame.grid(column = 0, row = 0)
  22.         self.lblText.grid(column = 0, row = 0, columnspan = 2)
  23.         self.btnHello.grid(column = 0, row = 1)
  24.         self.btnQuit.grid(column = 1, row = 1)
  25.  
  26.  
  27.     def SaySomething(self):
  28.         print "Hello to FullCircle Magazine Readers!!!!!!!!!!"
  29.  
  30. root = Tk()
  31.  
  32. app = App(root)
  33.  
  34. root.mainloop()
  35.  
  36. # Example 3
  37.  
  38. from Tkinter import *
  39.  
  40. class App:
  41.  
  42.     def __init__(self, master):
  43.  
  44.         frame = Frame(master)
  45.        
  46.         self.lblText = Label(frame, text = "This is a label widget")
  47.         self.btnQuit = Button(frame, text="Quit", fg="red", command=frame.quit)
  48.         self.btnHello = Button(frame, text="Hello", command=self.SaySomething)
  49.         frame.grid(column = 0, row = 0)
  50.         self.lblText.grid(column = 0, row = 0, columnspan = 2)
  51.         self.btnHello.grid(column = 0, row = 1)
  52.         self.btnQuit.grid(column = 1, row = 1)
  53.  
  54.  
  55.     def SaySomething(self):
  56.         print "Hello to FullCircle Magazine Readers!!!!!!!!!!"
  57.  
  58. root = Tk()
  59. root.geometry('150x75+550+150')
  60. app = App(root)
  61.  
  62. root.mainloop()
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement