Skip to content

Commit

Permalink
Changed error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
spavlick committed Nov 22, 2014
1 parent 2463df3 commit 27214da
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 42 deletions.
15 changes: 15 additions & 0 deletions buttontester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from Tkinter import *
from ttk import *
import tkMessageBox

def func1():
tkMessageBox.showmessage('message 1')
def func2():
tkMessageBox.showmessage('message 2')

root=Tk()
frame=Frame(root)
button=Button(frame,command=func1)
button.configure(command=func2)
frame.pack()
root.mainloop()
14 changes: 14 additions & 0 deletions buttontester.py~
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from Tkinter import *
from ttk import *
import tkMessageBox

def func1():
tkMessageBox.showmessage('message 1')
def func2():
tkMessageBox.showmessage('message 2')

root=Tk()
frame=Frame(root)
button=Button(frame,command=func1)
button.configure(command=func2)
frame.loop()
38 changes: 18 additions & 20 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,67 +158,67 @@ def checkgeom(self):
def syntaxCheck(self):
try:
literal_eval(self.h.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for h')
try:
literal_eval(self.w.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for w')
try:
literal_eval(self.s.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for s')
try:
literal_eval(self.m.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for m')
try:
literal_eval(self.wstyle.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for wstyle')
try:
literal_eval(self.lindex.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for lindex')
try:
float(self.sigma.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for sigma. Please enter float value')
try:
float(self.mur.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for mur. Please enter float value')
try:
int(self.nlayer.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for nlayer. Please enter integer value')
try:
int(self.nwinding.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for nwinding. Please enter integer value')
try:
float(self.gt.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for gt. Please enter float value')
try:
float(self.gb.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for gb. Please enter float value')
try:
float(self.Ae.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for Ae. Please enter float value')
try:
float(self.le.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for le. Please enter float value')
try:
float(self.nc.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for nc. Please enter float value')
try:
float(self.c.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for c. Please enter float value')

def valueCheck(self):
Expand Down Expand Up @@ -554,7 +554,7 @@ def generate_netlist_errors(self):
class ScrollbarFrame(Frame):
def __init__(self, root):

Frame.__init__(self, root)
Frame.__init__(self, root,height=200,width=600)
self.canvas = Canvas(root, borderwidth=0)
self.frame = GUI(root)
self.hsb = Scrollbar(root, orient="horizontal", command=self.canvas.xview)
Expand All @@ -564,7 +564,7 @@ def __init__(self, root):
self.vsb.pack(side="right", fill="y")
self.hsb.pack(side="bottom",fill="x")
self.canvas.pack(side="top", fill="both", expand=True)
self.canvas.create_window((6,6), window=self.frame, anchor="nw",
self.canvas.create_window((4,4),window=self.frame, anchor="nw",
tags="self.frame")

self.frame.bind("<Configure>", self.OnFrameConfigure)
Expand All @@ -579,5 +579,3 @@ def OnFrameConfigure(self, event):
mainframe.pack(side="top", fill="both", expand=True)
#for child in mainframe.winfo_children(): child.grid_configure(padx=3, pady=3)
root.mainloop()

#add check for format of each entry
46 changes: 24 additions & 22 deletions gui.py~
Original file line number Diff line number Diff line change
Expand Up @@ -152,74 +152,78 @@ class GUI(Frame):
self.entries[key].delete(0,END)

def checkgeom(self):
nwinding=int(self.nwinding.get())
nlayer=int(self.nlayer.get())
self.syntaxCheck()
self.valueCheck()

def syntaxCheck(self):
try:
literal_eval(self.h.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for h')
try:
literal_eval(self.w.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for w')
try:
literal_eval(self.s.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for s')
try:
literal_eval(self.m.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for m')
try:
literal_eval(self.wstyle.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for wstyle')
try:
literal_eval(self.lindex.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for lindex')
try:
float(self.sigma.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for sigma. Please enter float value')
try:
float(self.mur.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for mur. Please enter float value')
try:
int(self.nlayer.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for nlayer. Please enter integer value')
try:
int(self.nwinding.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for nwinding. Please enter integer value')
try:
float(self.gt.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for gt. Please enter float value')
try:
float(self.gb.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for gb. Please enter float value')
try:
float(self.Ae.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for Ae. Please enter float value')
try:
float(self.le.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for le. Please enter float value')
try:
float(self.nc.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for nc. Please enter float value')
try:
float(self.c.get())
except SyntaxError:
except Exception:
tkMessageBox.showerror(message='incorrect entry format for c. Please enter float value')

def valueCheck(self):
nwinding=int(self.nwinding.get())
nlayer=int(self.nlayer.get())
if nwinding!= max(literal_eval(self.lindex.get())):
tkMessageBox.showerror(message='nwinding mismatch with lindex, please retry')
elif nwinding!= len(literal_eval(self.wstyle.get())):
Expand Down Expand Up @@ -550,7 +554,7 @@ class GUI(Frame):
class ScrollbarFrame(Frame):
def __init__(self, root):

Frame.__init__(self, root)
Frame.__init__(self, root,height=200,width=700)
self.canvas = Canvas(root, borderwidth=0)
self.frame = GUI(root)
self.hsb = Scrollbar(root, orient="horizontal", command=self.canvas.xview)
Expand All @@ -560,7 +564,7 @@ class ScrollbarFrame(Frame):
self.vsb.pack(side="right", fill="y")
self.hsb.pack(side="bottom",fill="x")
self.canvas.pack(side="top", fill="both", expand=True)
self.canvas.create_window((6,6), window=self.frame, anchor="nw",
self.canvas.create_window((4,4),window=self.frame, anchor="nw",
tags="self.frame")

self.frame.bind("<Configure>", self.OnFrameConfigure)
Expand All @@ -575,5 +579,3 @@ if __name__=='__main__':
mainframe.pack(side="top", fill="both", expand=True)
#for child in mainframe.winfo_children(): child.grid_configure(padx=3, pady=3)
root.mainloop()

#add check for format of each entry

0 comments on commit 27214da

Please sign in to comment.