uccjshrimpton

Basic UI Tkinter

Jun 21st, 2016
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. #Tutorial site: http://effbot.org/tkinterbook/tkinter-index.htm
  2.  
  3. from tkinter import *
  4.  
  5. def ButtonPress():
  6.     print("Let's break it DOWN!")
  7.  
  8. mainWindow = Tk()
  9.  
  10. topFrame = Frame(mainWindow)
  11. topFrame.pack(side=TOP)
  12.  
  13. bottomFrame = Frame(mainWindow)
  14. bottomFrame.pack(side=BOTTOM)
  15.  
  16. myPhoto = PhotoImage(file="doge.gif")
  17. myPhotoLabel = Label(mainWindow, image=myPhoto)
  18. myPhotoLabel.photo = myPhoto
  19. myPhotoLabel.pack()
  20.  
  21. myLabel = Label(topFrame, text="This is a label")
  22. myLabel.pack(side=TOP)
  23.  
  24. myButton1 = Button(topFrame, text="Button 1", fg="red", command=ButtonPress)
  25. myButton2 = Button(topFrame, text="button 2", fg="blue", command=ButtonPress)
  26. myButton3 = Button(topFrame, text="Button 3", fg="green", command=ButtonPress)
  27. myButton4 = Button(bottomFrame, text="Button 4", fg="purple", command=ButtonPress)
  28.  
  29. myButton1.pack(side=LEFT)
  30. myButton2.pack(side=LEFT)
  31. myButton3.pack(side=LEFT)
  32. myButton4.pack(side=RIGHT)
  33.  
  34. mainWindow.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment