#55 float can be entered for dimensions

changed verifications so dimensions entry can be floats
This commit is contained in:
Ian
2019-04-06 14:04:10 -04:00
parent 22b632da9b
commit 89e751350c

View File

@@ -56,14 +56,14 @@ class button:
print('FAIL') print('FAIL')
def verifyEntry(self): def verifyEntry(self):
if not Width.Box.get().isdigit(): if not Width.Box.get().replace('.','',1).isdigit():
self.State.config(text = 'ERROR: Width needs to be a positive integer', fg = 'red', font = 'Helvetica 10 bold') self.State.config(text = 'ERROR: Width needs to be a positive number', fg = 'red', font = 'Helvetica 10 bold')
return 0 return 0
if not Height.Box.get().isdigit(): if not Height.Box.get().replace('.','',1).isdigit():
self.State.config(text = 'ERROR: Height needs to be a positive integer', fg = 'red', font = 'Helvetica 10 bold') self.State.config(text = 'ERROR: Height needs to be a positive number', fg = 'red', font = 'Helvetica 10 bold')
return 0 return 0
if not radius.Box.get().isdigit(): if not radius.Box.get().replace('.','',1).isdigit():
self.State.config(text = 'ERROR: Tool radius needs to be a positive integer', fg = 'red', font = 'Helvetica 10 bold') self.State.config(text = 'ERROR: Tool radius needs to be a positive number', fg = 'red', font = 'Helvetica 10 bold')
return 0 return 0
if not (radius.Box.get() < Width.Box.get() or radius.Box.get() < Height.Box.get()): if not (radius.Box.get() < Width.Box.get() or radius.Box.get() < Height.Box.get()):
self.State.config(text = 'ERROR: Tool radius needs to be smaller than Width and Height', fg = 'red', font = 'Helvetica 10 bold') self.State.config(text = 'ERROR: Tool radius needs to be smaller than Width and Height', fg = 'red', font = 'Helvetica 10 bold')
@@ -74,6 +74,13 @@ class button:
if not Gcode.path.endswith('.gcode'): if not Gcode.path.endswith('.gcode'):
self.State.config(text = 'ERROR: File type is not .gcode', fg = 'red', font = 'Helvetica 10 bold') self.State.config(text = 'ERROR: File type is not .gcode', fg = 'red', font = 'Helvetica 10 bold')
return 0 return 0
try:
main(PCB.path, Gcode.path, bool(ascii.Box.current()), int(Width.Box.get()), int(Height.Box.get()),
int(radius.Box.get()), unit.Box.get())
except:
self.State.config(text='ERROR: unexpected error', fg='red', font='Helvetica 10 bold')
#raise
return 0
self.State.config(text='SUCCESS: (ง ͠° ͟ل͜ ͡°)ง', fg='green', font='Helvetica 10 bold') self.State.config(text='SUCCESS: (ง ͠° ͟ل͜ ͡°)ง', fg='green', font='Helvetica 10 bold')
return 1 return 1
@@ -98,11 +105,15 @@ class pathFind:
def openDir(self): def openDir(self):
self.path = str(askopenfilename(initialdir = "/",title = "Select file",filetypes = (("pbm files","*.pbm"),("all files","*.*")))) self.path = str(askopenfilename(initialdir = "/",title = "Select file",filetypes = (("pbm files","*.pbm"),("all files","*.*"))))
self.Box.configure(state='normal')
self.Box.insert(END, self.path) self.Box.insert(END, self.path)
self.Box.configure(state='readonly')
def saveDir(self): def saveDir(self):
self.path = str(asksaveasfilename(initialdir = "/",title = "Select file",filetypes = (("pbm files","*.gcode"),("all files","*.*")))) self.path = str(asksaveasfilename(initialdir = "/",title = "Select file",filetypes = (("pbm files","*.gcode"),("all files","*.*"))))
self.Box.configure(state='normal')
self.Box.insert(END, self.path) self.Box.insert(END, self.path)
self.Box.configure(state='readonly')
def createWidget(self, master, parameter, openSave): def createWidget(self, master, parameter, openSave):
frame = Frame(master, width=500, height=30, ) frame = Frame(master, width=500, height=30, )
@@ -116,11 +127,9 @@ class pathFind:
else: else:
Butt = Button(frame, text = 'search', command = lambda: self.saveDir()) Butt = Button(frame, text = 'search', command = lambda: self.saveDir())
Butt.pack(side = RIGHT) Butt.pack(side = RIGHT)
self.Box = Entry(frame, width=45) self.Box = Entry(frame, width=45, state = 'readonly')
self.Box.pack(side=RIGHT, padx = 3) self.Box.pack(side=RIGHT, padx = 3)
def display(this):
print(this)
root.title('totally not a virus') root.title('totally not a virus')
root.geometry("550x300") root.geometry("550x300")