From f746e769fd20a9a3e6d83a4626d14d741e8e0620 Mon Sep 17 00:00:00 2001 From: Ian Date: Mon, 25 Mar 2019 21:15:20 -0400 Subject: [PATCH] #55 modification of the entries changing some entry boxes with other input methods to limit the choices of the user --- pcbdevice/UI/UI.py | 62 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/pcbdevice/UI/UI.py b/pcbdevice/UI/UI.py index 4145978..6341226 100644 --- a/pcbdevice/UI/UI.py +++ b/pcbdevice/UI/UI.py @@ -1,4 +1,6 @@ from tkinter import * +from tkinter.filedialog import askdirectory, askopenfilename, asksaveasfilename +from tkinter.ttk import Combobox from pcbdevice.main import main @@ -18,36 +20,82 @@ class textBox: Text = Label(frame, text=parameter) Text.pack(side=LEFT) - self.Box = Entry(frame) + self.Box = Entry(frame, width = 20) self.Box.pack(side=RIGHT) +class menuBox: + def __init__(self, master, parameter, selection): + self.master = master + self.createWidget(master, parameter, selection) + + def createWidget(self, master, parameter, selection): + frame = Frame(master, width=500, height=30, ) + frame.pack(side=TOP) + frame.pack_propagate(0) + + Text = Label(frame, text=parameter) + Text.pack(side=LEFT) + self.Box = Combobox(frame, values = selection, width = 17) + self.Box.pack(side=RIGHT) + class button: def __init__(self, master): self.master = master self.createWidget(master) def execution(self): - main(PCB.Box.get(), Gcode.Box.get(), bool(ascii.Box.get()), int(Width.Box.get()), int(Height.Box.get()), + main(PCB.path, Gcode.path, bool(ascii.Box.current()), int(Width.Box.get()), int(Height.Box.get()), int(radius.Box.get()), unit.Box.get()) + def createWidget(self, master): frame = Frame(master, width=500, height=30, ) frame.pack(side=BOTTOM) frame.pack_propagate(0) - Butt = Button(frame, text = 'execute program', command = self.execution) + Butt = Button(frame, text = 'execute program', command = lambda: self.execution()) Butt.pack(side = RIGHT) +class pathFind: + + path = '' + + def __init__(self, master, parameter, openSave): + self.master = master + self.createWidget(master, parameter, openSave) + + def openDir(self): + self.path = str(askopenfilename(initialdir = "/",title = "Select file",filetypes = (("pbm files","*.pbm")))) + + def saveDir(self): + self.path = str(asksaveasfilename(initialdir = "/",title = "Select file",filetypes = (("pbm files","*.gcode")))) + + def createWidget(self, master, parameter, openSave): + frame = Frame(master, width=500, height=30, ) + frame.pack(side=TOP) + frame.pack_propagate(0) + + Text = Label(frame, text=parameter) + Text.pack(side=LEFT) + if openSave: + Butt = Button(frame, text = 'find path', command = lambda: self.openDir() ) + else: + Butt = Button(frame, text = 'find path', command = lambda: self.saveDir() ) + Butt.pack(side = RIGHT) + +def display(this): + print(this) + root.title('totally not a virus') root.geometry("550x300") #path = textBox(root, 'Program path') -PCB = textBox(root, 'PCB image path') -Gcode = textBox(root, 'Gcode output path') -ascii = textBox(root, 'If the image is in ascii(True) or binary(False)') +PCB = pathFind(root, 'PCB image path', TRUE) +Gcode = pathFind(root, 'Gcode output path', FALSE) +ascii = menuBox(root, 'If the image is in ascii or binary', ['binary','ascii']) Width = textBox(root, 'Width of the PCB') Height = textBox(root, 'Height of the PCB') radius = textBox(root, 'Tool\'s radius in mm') -unit = textBox(root, 'PCB dimension unit') +unit = menuBox(root, 'PCB dimension unit', ['mm', 'm', 'in']) button = button(root)