def __init__(self, master, controller, img): """ Sets up the validation contours view screen Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(ValidationContoursController object): The controller which will be in charge of the view img(Image): The resulting image from the contours model processing """ BaseView.__init__(self, master) self.addTitle("Does this look okay?") def configImgPanel(img, imgPanel): resizdeImg = AppUtils.converImgToTkinterImg(img, master.winfo_width() - 50, master.winfo_height() - 150) imgPanel.configure( width=master.winfo_width() - 50, height=master.winfo_height() - 150, relief=RIDGE, borderwidth=2, image=resizdeImg, ) imgPanel.image = resizdeImg self.imgPanel = Label(self) configImgPanel(img, self.imgPanel) self.imgPanel.bind("<Configure>", lambda e: configImgPanel(img, self.imgPanel)) self.imgPanel.pack(side=TOP) self.noButton = Button(self, text="No", command=controller.noClicked) self.noButton.pack(side=BOTTOM) self.yesButton = Button(self, text="Yes", command=controller.yesClicked) self.yesButton.pack(side=BOTTOM)
def __init__(self, master, controller): ''' Sets up the skew view Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(SkewController object): The controller which will be in charge of the view ''' BaseView.__init__(self, master) self.addTitle("Skew Calibration") def resizeVideoCapturePanel(videoCapturePanel, controller): controller.updatePanel() videoCapturePanel.configure(width=master.winfo_width()-50, height=master.winfo_height()-195) controller.updatePanel() self.videoCapturePanel = Label( self, width=master.winfo_width()-50, height=master.winfo_height()-195 , relief=RIDGE, borderwidth=2) self.videoCapturePanel.bind("<Configure>", lambda e: resizeVideoCapturePanel(self.videoCapturePanel, controller) ) self.videoCapturePanel.pack(side=TOP) self.undoButton = Button(self, text="Undo last photo", state=DISABLED, command=controller.undoClicked) self.undoButton.pack(side=BOTTOM) self.photoButton = Button(self, text="Take photo", command=controller.takePhotoClicked) self.photoButton.pack(side=BOTTOM) self.calibrateButton = Button(self, text="Start Skew Calibration", command=controller.startSkewCalibration) self.calibrateButton.pack(side=BOTTOM)
def __init__(self, master, controller): ''' Sets up the contours view Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(ContoursController object): The controller which will be in charge of the view ''' BaseView.__init__(self, master) self.addTitle("Scan Board") #Video Capture frame for both cameras self.videoPanel = Label(self ) self.videoPanel.pack(side=TOP) def resizeVideoCapturePanels(videoPanel,controller): controller.updatePanel() panelWidth = (master.winfo_width()-10) panelHeight = (master.winfo_height() -140) videoPanel.configure(width=panelWidth, height=panelHeight) controller.updatePanel() self.videoPanel.bind("<Configure>", lambda e: resizeVideoCapturePanels(self.videoPanel, controller) ) self.photosButton = Button(self, text="Take photo", command=controller.takePhotosClicked) self.photosButton.pack(side=BOTTOM)
def __init__(self, master, controller, img): ''' Sets up the validation scale view screen Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(ValidationScaleController object): The controller which will be in charge of the view img(Image): Confirm taken image from camera ''' BaseView.__init__(self, master) self.addTitle("Does this look okay?") self.imgPanel = Label(self ) self.imgPanel.pack(side=TOP) def resizeImgPanel(imgPanel,img): panelWidth = (master.winfo_width()-10) panelHeight = (master.winfo_height() -165) resizdeImg = AppUtils.converImgToTkinterImg(img, panelWidth, panelHeight) imgPanel.configure(width=panelWidth, height=panelHeight, image = resizdeImg) imgPanel.image = resizdeImg self.imgPanel.bind("<Configure>", lambda e: resizeImgPanel(self.imgPanel, img) ) self.noButton = Button(self, text="No, return to scale calibration screen", command=controller.noClicked) self.noButton.pack(side=BOTTOM) self.yesButton = Button(self, text="Yes, start calibrating scale", command=controller.yesClicked) self.yesButton.pack(side=BOTTOM)
def __init__(self, master, controller, img): ''' Sets up the skew validation contours view screen Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(ValidationSkewController object): The controller which will be in charge of the view img(Image): The resulting image from the skew model processing ''' BaseView.__init__(self, master) self.addTitle("Does this look okay?") def configImgPanel(img, imgPanel): cv2.imwrite('IMPORTANTTEST.jpg', img) resizedImg = AppUtils.converImgToTkinterImg(img, master.winfo_width()-50, master.winfo_height()-165) imgPanel.configure(width=master.winfo_width()-50, height=master.winfo_height()-165, relief=RIDGE, borderwidth=2, image = resizedImg) imgPanel.image = resizedImg self.imgPanel = Label(self) configImgPanel(img, self.imgPanel) self.imgPanel.bind("<Configure>", lambda e: configImgPanel(img, self.imgPanel) ) self.imgPanel.pack(side=TOP) self.redoButton = Button(self, text="No, return to calibrating skew", command=controller.redoClicked) self.redoButton.pack(side=BOTTOM) continueText = "Yes, continue to scale calibration" self.continuteButton = Button(self, text=continueText, command=controller.continueClicked) self.continuteButton.pack(side=BOTTOM)
def __init__(self, master, controller): ''' Sets up The PromptSkewView Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(PromptSkewController object): The controller which will be in charge of the view ''' BaseView.__init__(self, master) self.addTitle("Skew Calibration") self.panel = Frame(self,relief=RIDGE, borderwidth=2) self.panel.pack_propagate(0) self.panel.pack(side=TOP) scrollbar = Scrollbar(self.panel) scrollbar.pack(side=RIGHT, fill=Y) instructions = Text(self.panel, wrap=WORD, yscrollcommand=scrollbar.set, state=NORMAL) instructions.delete(1.0, END) instructions.insert(END, "Skew Calibration Instructions: \nSkew calibration is not necessary to proceed. If you skip Skew Calibration, however, your results will be less accurate. \nStep 0: Press Calibrate button \nStep 1: Print out <location of circlegrid pattern> \nStep 2: Place printout on machine bed, with entire pattern in view of camera. \nStep 3: Take two(2) photos. \nStep 4: Rotate image in bed by ~ 15-20 degrees. \nStep 5: Take photo. \nStep 6: Repeat steps 4 and 5 until you have taken at least 15 photos. \nStep 7: Press Start") instructions.config(state=DISABLED) instructions.pack(side=TOP, fill=BOTH, expand=True) def resizePanel(panel): panelWidth = (master.winfo_width()-10) panelHeight = (master.winfo_height() -195) panel.configure(width=panelWidth, height=panelHeight) self.panel.bind("<Configure>", lambda e: resizePanel(self.panel) ) scrollbar.config(command=instructions.yview) self.skipButton = Button(self, text="Skip skew", command=controller.skipClicked) self.skipButton.pack(side=BOTTOM) self.calibrateButton = Button(self, text="Calibrate skew", command=controller.calibrateClicked) self.calibrateButton.pack(side=BOTTOM) self.deleteButton = Button(self, text="Delete skew", command=controller.deleteClicked) self.deleteButton.pack(side=BOTTOM)
def __init__(self, master, controller, json): ''' Sets up the export view Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(ExportController object): The controller which will be in charge of the view jsonText(String): The json text which is displayed to the user after export ''' BaseView.__init__(self, master) self.addTitle("JSON Exported") self.panel = Frame(self,relief=RIDGE, borderwidth=2) self.panel.pack_propagate(0) self.panel.pack(side=TOP) scrollbar = Scrollbar(self.panel) scrollbar.pack(side=RIGHT, fill=Y) jsonText = Text(self.panel, wrap=WORD, yscrollcommand=scrollbar.set, state=NORMAL) jsonText.delete(1.0, END) jsonText.insert(END, json) jsonText.config(state=DISABLED) jsonText.pack(side=TOP, fill=BOTH, expand=True) def resizePanel(panel): panelWidth = (master.winfo_width()-10) panelHeight = (master.winfo_height() -110) panel.configure(width=panelWidth, height=panelHeight) self.panel.bind("<Configure>", lambda e: resizePanel(self.panel) ) scrollbar.config(command=jsonText.yview) self.skipButton = Button(self, text="Exit", command=master.destroy) self.skipButton.pack(side=BOTTOM)
def __init__(self, master, controller,formParams): ''' Sets up the ScaleView Args: master(Tk object): The toplevel widget of Tk which is the main window of an application controller(ScaleController object): The controller which will be in charge of the view formParams(Dictionary): The current form params ''' BaseView.__init__(self, master) self.addTitle("Scale Calibration") #Video Capture frame for both cameras self.videoPanel = Label(self ) self.videoPanel.pack(side=TOP) panelWidth = (master.winfo_width()-10) panelHeight = (master.winfo_height() -230) def resizeVideoCapturePanel(videoPanel, controller): controller.updatePanel() panelWidth = (master.winfo_width()-10) panelHeight = (master.winfo_height() -230) videoPanel.configure(width=panelWidth, height=panelHeight) controller.updatePanel() self.videoPanel.bind("<Configure>", lambda e: resizeVideoCapturePanel(self.videoPanel, controller) ) defaultFont = tkFont.nametofont("TkDefaultFont") #Width onEditVar= StringVar() onEditVar.set(str(formParams['width'])) onEditVar.trace("w", lambda name, index, mode, onEditVar=onEditVar: self.updateExportButton()) vcmd = (master.register(self.validate),'%P', '%S') widthPanel = Label(self) widthLabel = Label(widthPanel, text="Width:") widthLabel.pack(side=LEFT) self.widthInput = Entry(widthPanel, width=11, validate = 'key', validatecommand = vcmd, textvariable=onEditVar, font=defaultFont) self.widthInput.pack(side=RIGHT) widthPanel.pack(side=TOP) #Height onEditVar= StringVar() onEditVar.set(str(formParams['height'])) onEditVar.trace("w", lambda name, index, mode, onEditVar=onEditVar: self.updateExportButton()) heightPanel = Label(self) heightLabel = Label(heightPanel, text="Height:") heightLabel.pack(side=LEFT) self.heightInput = Entry(heightPanel, width=11, validate = 'key', validatecommand = vcmd, textvariable=onEditVar, font=defaultFont) self.heightInput.pack(side=RIGHT) heightPanel.pack(side=TOP) #Units unitsPanel = Label( self) calibrationLabel = Label(unitsPanel, text="Units:") calibrationLabel.pack(side=LEFT) self.unitsBox = ttk.Combobox(unitsPanel, width=10, state="readonly", font=defaultFont) self.unitsBox['values'] = ('cm', 'in', 'mm') self.unitsBox['state'] = 'readonly' self.unitsBox.set(formParams['units']) self.unitsBox.pack(side=RIGHT) unitsPanel.pack(side=TOP) #Export button self.photosButton = Button(self, text="Take photo", command=controller.photosClicked) self.photosButton.pack(side=TOP)