Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- from tkinter import ttk
- class GUI:
- def __init__(self):
- self.root = Tk()
- self.root.geometry("600x400")
- self.root.title("Coord Convert 1.0")
- self.root.configure(bg="#9999CC")
- def convert(self, event, inN, inE, dt, z, ns, rN, rE):
- ##inN: INPUT N
- ##inE: INPUT E
- ##dt: DATUM
- ##z: ZONE
- ##ns: radial Button N
- ##ns: radial Button S
- ##rN: RESULT N
- ##rE: RESULT E
- print("INPUT N")
- print(inN.get("1.0", END))
- print("INPUT E")
- print(inE.get("1.0", END))
- print("DATUM")
- print(dt.get())
- print("ZONE")
- print(z.get())
- print("IntVar")
- if ns.get() == 1:
- print("N")
- elif ns.get() == 2:
- print("S")
- print("RESULT N")
- print(rN.get("1.0", END))
- print("RESULT E")
- print(rE.get("1.0", END))
- def run(self):
- window= Frame(self.root, bg="#9999CC") ##a frame to hold everything
- window.pack(fill=BOTH, expand=1)
- ##create the 5 frames left to right
- INN = Frame(window, bg="#9999CC") ##INPUT N frame
- INN.pack(fill=BOTH , expand=1, side=LEFT)
- 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
- INPUTN=Text(INN, height=17, width=11, bg="#ffff66")
- INPUTN.pack(fill=X)
- INE = Frame(window, bg="#9999CC") ##INPUT E frame
- INE.pack(fill=BOTH , expand=1, side=LEFT)
- 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
- INPUTE=Text(INE, height= 17, width=11, bg="#ffff66")
- INPUTE.pack()
- CEN = Frame(window, bg="#9999CC") ## frame for the center of the window
- CEN.pack(fill=BOTH , expand=1, side=LEFT)
- Frame(CEN, bg="#9999CC").pack(fill=BOTH, expand=1) ##spacer
- Label(CEN, text= "DATUM:",font=("calibra", 9), width=10, height= 0, bg= "#9999CC").pack(side=TOP)
- DATUM= ttk.Combobox(CEN, values=["wgs","minna nigeria"])
- DATUM.pack()
- Frame(CEN, bg="#9999CC").pack(fill=BOTH, expand=1) ##spacer
- Label(CEN, text= "ZONE:",font=("calibra", 9), width=10, height= 0, bg= "#9999CC").pack(side=TOP)
- zone_raidal = Frame(CEN, bg="#9999CC") # a frame to hold the zone entry and radial buttons
- zone_raidal.pack(side=TOP)
- ZONE= Entry(zone_raidal, width=11,bg= "#FFFFFf",bd=0)
- ZONE.pack(side=LEFT)
- radial = Frame(zone_raidal, bg="#9999CC") #frame just to hold the radial buttons
- radial.pack(side=LEFT)
- MODES = [("N", "1"),("S", "2")]
- v = IntVar()
- v.set(1)
- buttonN= Radiobutton(radial, width=4, height= 1, text= "N", padx=8,bg= "#9999CC",fg="black",bd=0,font=("rockwell", 9),variable=v, value=1)
- buttonN.pack(side=TOP)
- buttonS= Radiobutton(radial, width=4, height=1,text= "S", padx=8,bg= "#9999CC",fg="black",bd=0,font=("rockwell", 9),variable=v, value=2)
- buttonS.pack(side=TOP)
- Frame(CEN, bg="#9999CC").pack(fill=BOTH, expand=1) ##spacer
- RN = Frame(window, bg="#9999CC")##RESULT N frame
- RN.pack(fill=BOTH , expand=1, side=LEFT)
- 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
- RESULTN=Text(RN, height= 17, width=11, bg="#ffff66", state="disabled")
- RESULTN.pack()
- RE = Frame(window, bg="#9999CC") ##RESULT E frame
- RE.pack(fill=BOTH , expand=1, side=LEFT)
- 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
- RESULTE=Text(RE, height= 17, width=11, bg="#ffff66", state="disabled")
- RESULTE.pack()
- 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))
- button.pack()
- self.root.mainloop()
- if __name__ == "__main__":
- try:
- app=GUI()
- app.run()
- except Exception as err:
- print("There was an Error")
- print(err)
- except KeyboardInterrupt:
- print("Quitting")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement