Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. from tkinter import *
  2.  
  3.  
  4. # Call Tkinter by variable Window
  5. window = Tk()
  6.  
  7.  
  8. #Functions
  9. def end():
  10.     exit()
  11.  
  12. def click():
  13.     entered_text=textbx.get()
  14.     output.delete(0.0, END)
  15.     try:
  16.         definition = dicton[entered_text]
  17.     except:
  18.         definition = "Sorry this isn't in diction"
  19.     output.insert(END, definition)
  20.  
  21. #Window code
  22. window.title = "GUI"
  23. window.geometry("700x600")
  24. window.configure(background="black")
  25.  
  26. #Basic Labels
  27. Label (window, bg="black", fg="white" , text="Enter text here:", font="none 10 bold") .grid(row=0, column=0,)
  28. Label (window, text="\nOutput:", bg="black", fg="white") .grid(row=2 , column=1)
  29.  
  30.  
  31. #Placement Items
  32. textbx = Entry(window, width="20", bg="white")
  33. textbx.grid(row=0, column=1, sticky=E)
  34. Button(window, width=6, text="Go!", command=click) .grid(row=1, column=1)
  35. output = Text(window, width=75, height=6, wrap=WORD, background="white" )
  36. output.grid(row=5, column=0, columnspan=10, sticky=W)
  37.  
  38.  
  39.  
  40. #Dictionary for testing
  41. dicton = {
  42.     'bug': 'this is an error in code', 'software': 'This is something that isnt physical in IT'
  43. }
  44.  
  45. Button(window, width=20, command=end,text="EXIT", bg="white" ) .grid(row=10, column=2)
  46.  
  47. window.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement