Advertisement
AceScottie

tktest.py

Sep 7th, 2019
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.14 KB | None | 0 0
  1. from tkinter import *
  2. from  tkinter import ttk
  3.  
  4. class GUI:
  5.     def __init__(self):
  6.         self.root = Tk()
  7.         self.root.geometry("600x400")
  8.         self.root.title("Coord Convert 1.0")
  9.         self.root.configure(bg="#9999CC")
  10.        
  11.     def convert(self, event, inN, inE, dt, z, ns, rN, rE):
  12.         ##inN: INPUT N
  13.         ##inE: INPUT E
  14.         ##dt: DATUM
  15.         ##z: ZONE
  16.         ##ns: radial Button N
  17.         ##ns: radial Button S
  18.         ##rN: RESULT N
  19.         ##rE: RESULT E
  20.         print("INPUT N")
  21.         print(inN.get("1.0", END))
  22.         print("INPUT E")
  23.         print(inE.get("1.0", END))
  24.         print("DATUM")
  25.         print(dt.get())
  26.         print("ZONE")
  27.         print(z.get())
  28.         print("IntVar")
  29.         if ns.get() == 1:
  30.             print("N")
  31.         elif ns.get() == 2:
  32.             print("S")
  33.         print("RESULT N")
  34.         print(rN.get("1.0", END))
  35.         print("RESULT E")
  36.         print(rE.get("1.0", END))
  37.        
  38.  
  39.     def run(self):
  40.         window= Frame(self.root, bg="#9999CC") ##a frame to hold everything
  41.         window.pack(fill=BOTH, expand=1)
  42.         ##create the 5 frames left to right
  43.        
  44.         INN = Frame(window, bg="#9999CC") ##INPUT N frame
  45.         INN.pack(fill=BOTH , expand=1, side=LEFT)
  46.         Label(INN, text= "INPUT N",font=("calibra", 9), width=10, height= 2, bg= "#669966").pack(side=TOP) ##lables dont need to be bound to a variable if they do not need to be changed
  47.         INPUTN=Text(INN, height=17, width=11, bg="#ffff66")
  48.         INPUTN.pack(fill=X)
  49.        
  50.        
  51.         INE = Frame(window, bg="#9999CC") ##INPUT E frame
  52.         INE.pack(fill=BOTH , expand=1, side=LEFT)
  53.         Label(INE, text= "INPUT E",font=("calibra", 9), width=10, height= 2, bg= "#669966").pack(side=TOP) ##lables dont need to be bound to a variable if they do not need to be changed
  54.         INPUTE=Text(INE, height= 17, width=11, bg="#ffff66")
  55.         INPUTE.pack()
  56.        
  57.         CEN = Frame(window, bg="#9999CC") ## frame for the center of the window
  58.         CEN.pack(fill=BOTH , expand=1, side=LEFT)
  59.         Frame(CEN, bg="#9999CC").pack(fill=BOTH, expand=1) ##spacer
  60.         Label(CEN, text= "DATUM:",font=("calibra", 9), width=10, height= 0, bg= "#9999CC").pack(side=TOP)
  61.         DATUM= ttk.Combobox(CEN, values=["wgs","minna nigeria"])
  62.         DATUM.pack()
  63.         Frame(CEN, bg="#9999CC").pack(fill=BOTH, expand=1) ##spacer
  64.        
  65.         Label(CEN, text= "ZONE:",font=("calibra", 9), width=10, height= 0, bg= "#9999CC").pack(side=TOP)
  66.         zone_raidal = Frame(CEN, bg="#9999CC") # a frame to hold the zone entry and radial buttons
  67.         zone_raidal.pack(side=TOP)
  68.         ZONE= Entry(zone_raidal, width=11,bg= "#FFFFFf",bd=0)
  69.         ZONE.pack(side=LEFT)
  70.         radial = Frame(zone_raidal, bg="#9999CC") #frame just to hold the radial buttons
  71.         radial.pack(side=LEFT)
  72.        
  73.         MODES = [("N", "1"),("S", "2")]
  74.  
  75.         v = IntVar()
  76.         v.set(1)
  77.         buttonN= Radiobutton(radial, width=4, height= 1, text= "N", padx=8,bg= "#9999CC",fg="black",bd=0,font=("rockwell", 9),variable=v, value=1)
  78.         buttonN.pack(side=TOP)
  79.         buttonS= Radiobutton(radial, width=4, height=1,text= "S", padx=8,bg= "#9999CC",fg="black",bd=0,font=("rockwell", 9),variable=v, value=2)
  80.         buttonS.pack(side=TOP)
  81.        
  82.         Frame(CEN, bg="#9999CC").pack(fill=BOTH, expand=1) ##spacer
  83.        
  84.        
  85.        
  86.        
  87.         RN = Frame(window, bg="#9999CC")##RESULT N frame
  88.         RN.pack(fill=BOTH , expand=1, side=LEFT)
  89.         Label(RN, text= "RESULT E",font=("calibra", 9), width=10, height= 2, bg= "#669966").pack(side=TOP) ##lables dont need to be bound to a variable if they do not need to be changed
  90.         RESULTN=Text(RN, height= 17, width=11, bg="#ffff66", state="disabled")
  91.         RESULTN.pack()
  92.        
  93.         RE = Frame(window, bg="#9999CC") ##RESULT E frame
  94.         RE.pack(fill=BOTH , expand=1, side=LEFT)
  95.         Label(RE, text= "RESULT E",font=("calibra", 9), width=10, height= 2, bg= "#669966").pack(side=TOP) ##lables dont need to be bound to a variable if they do not need to be changed
  96.         RESULTE=Text(RE, height= 17, width=11, bg="#ffff66", state="disabled")
  97.         RESULTE.pack()
  98.  
  99.        
  100.         button= Button(CEN, width=10, height=2, text="CONVERT", bg="#666699", fg="blue", bd=0,font=("rockwell", 9), command=lambda e=Event(), inN=INPUTN, inE=INPUTE, dt=DATUM, z=ZONE, ns=v, rN=RESULTN, rE=RESULTE :self.convert(e, inN, inE, dt, z, ns, rN, rE))
  101.         button.pack()
  102.  
  103.         self.root.mainloop()
  104.        
  105. if __name__ == "__main__":
  106.     try:
  107.         app=GUI()
  108.         app.run()
  109.     except Exception as err:
  110.         print("There was an Error")
  111.         print(err)
  112.     except KeyboardInterrupt:
  113.         print("Quitting")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement