Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. from tkinter import *
  2. myWindow=Tk()
  3. myTitle='ICCESS Sphincter Actuator V1.0'
  4. myWindow.title(myTitle)
  5.  
  6. v = StringVar(myWindow, "1")
  7. retVal = v.get()
  8.  
  9. def onRbClick():
  10. retVal=v.get()
  11. myTitle='RB: '+retVal
  12. myWindow.title(myTitle)
  13.  
  14. rb1 = Radiobutton(myWindow, text = 'Cable-driven', variable = v, value = '1', command=onRbClick)
  15. rb1.grid(row=0, column=0, padx=10, pady=10, sticky='NW')
  16. rb2 = Radiobutton(myWindow, text = 'Pneumatic-bellows', variable = v, value = '2', command=onRbClick)
  17. rb2.grid(row=0, column=1, padx=10, pady=10, sticky='NW')
  18.  
  19. def connect():
  20. xx=ev.get()
  21. myWindow.title(xx)
  22.  
  23. frm1 = Frame(myWindow)
  24. frm1.grid(row=0, column=2)
  25. ev = StringVar(myWindow, 'COM1')
  26. ent1 = Entry(frm1, width='10', textvariable = ev)
  27. ent1.pack(side=LEFT, padx=5)
  28. btn_connect = Button(frm1, text='Connect', command=connect)
  29. btn_connect.pack(side=LEFT, padx=5)
  30.  
  31. btn_close = Button(myWindow, text='Close', command=exit)
  32. #btn_close.pack(padx=100, pady=50)
  33. btn_close.grid(row=0, column=3, padx=10, pady=10)
  34.  
  35.  
  36. def onBtClick(event):
  37. theW = event.widget
  38. print(theW.cget('text'))
  39. if myWindow.cget('bg')=='green':
  40. myWindow.configure(bg='gray')
  41. else:
  42. myWindow.configure(bg='green')
  43.  
  44. hsimg = PhotoImage(file = r"hs.png")
  45. # hsimg = hsimg0.subsample(3,3)
  46. dsimg = PhotoImage(file = r"ds.png")
  47. crimg = PhotoImage(file = r"cr.png")
  48. wsimg = PhotoImage(file = r"ws.png")
  49.  
  50. #btn_hs=Button(myWindow, text='Healthy Squeeze', image=hsimg, compound=TOP, command=onBtClick)
  51. btn_hs=Button(myWindow, text='Healthy Squeeze', image=hsimg, compound=TOP)
  52. btn_hs.bind("<Button-1>", onBtClick)
  53. btn_ds=Button(myWindow, text='Decay Squeeze', image=dsimg, compound=TOP)
  54. btn_ds.bind("<Button-1>", onBtClick)
  55. btn_cr=Button(myWindow, text='Cough Reflex', image=crimg, compound=TOP)
  56. btn_cr.bind("<Button-1>", onBtClick)
  57. btn_ws=Button(myWindow, text='Week Squeeze', image=wsimg, compound=TOP)
  58. btn_ws.bind("<Button-1>", onBtClick)
  59.  
  60. btn_hs.grid(row=2, column=0, ipadx=10, pady=10)
  61. btn_ds.grid(row=2, column=1, ipadx=10, pady=10)
  62. btn_cr.grid(row=2, column=2, ipadx=10, pady=10)
  63. btn_ws.grid(row=2, column=3, ipadx=10, pady=10)
  64.  
  65.  
  66. myWindow.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement