Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. import tkinter as Tkinter
  2. import sys
  3.  
  4. root = Tkinter.Tk()
  5. root.title("Munchkin")
  6.  
  7. def buttonTest():
  8. print("Starting game...")
  9.  
  10. showHand = Tkinter.Button(text="Show hand", fg="green", pady=2, bd=3)
  11. showLocalTable = Tkinter.Button(text="Show your table", fg="green", pady=2, bd=3)
  12. countHand = Tkinter.Button(text="Count hand", fg="blue",pady=2, bd=3)
  13. quitGame = Tkinter.Button(text="Quit", bg="red")
  14. startGame = Tkinter.Button(text="Start Game", bg="green", padx=10, pady=5, bd=3, command=buttonTest)
  15.  
  16. showHand.grid(row=2, column =0)
  17. showLocalTable.grid(row=3, column =0)
  18. countHand.grid(row=4, column =0)
  19. quitGame.grid(row=6, column =0)
  20. startGame.grid(row=5, column =0)
  21.  
  22. label1 = Tkinter.Label(root, text="Command box")
  23. entry1 = Tkinter.Entry(root, width=100) #possibly move these into the gui section for the term
  24.  
  25. label1.grid(row=7)
  26. entry1.grid(row=8) #possibly move these into the gui section for the term
  27.  
  28. Tkinter.messagebox.showinfo("Munchkin", "Welcome to Munchkin!\n\nGo down into the dungeon, kill everything you meet.\nYou can backstab your friends, or help them. Or both!\nWhoever scrambles to level 10 first gets the treasure.\n\nFull rules at en.wikipedia.org/wiki/Munchkin_(card_game) ")
  29.  
  30. #shellAdder(root)
  31.  
  32. class shellOutputRedirect():
  33. def __init__(self, text_widget):
  34. self.text_space = text_widget
  35.  
  36. def write(self, string):
  37. self.text_space.config(state=Tkinter.NORMAL)
  38. self.text_space.insert("end", string)
  39. self.text_space.see("end")
  40. self.text_space.config(state=Tkinter.DISABLED)
  41.  
  42. class shellAdder():
  43. def __init__(self, parent):
  44. text_box = Tkinter.Text(parent, state=Tkinter.DISABLED)
  45. text_box.grid(row=0)
  46.  
  47. sys.stdout = shellOutputRedirect(text_box)
  48. sys.stderr = shellOutputRedirect(text_box)
  49.  
  50. output_button = Tkinter.Button(parent, text="Send command", command=self.getEntry, pady=5, padx=5)
  51. output_button.grid(row=15, column=0)
  52.  
  53. def getEntry(self):
  54. self.text_space.insert("end", string)
  55. #print ("Std Output")
  56. #input()
  57. #raise ValueError("Std Error")
  58.  
  59. shellAdder(root)
  60. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement