def initUI(self): self.sld = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.lcd = QtGui.QLCDNumber(self) self.combo = QtGui.QComboBox(self) self.combo2 = QtGui.QComboBox(self) self.combo3 = QtGui.QComboBox(self) self.lbl1 = QtGui.QLabel("Set the size of the hotspot") self.lbl3 = QtGui.QLabel() self.lbl3.setText("Set a group number of the hot spot") for i in arange(5): self.combo2.addItem(str(i + 1)) self.btn = QtGui.QPushButton("Hotspots to a line") self.btn2 = QtGui.QPushButton("Hotspots to a sine curve") self.btn3 = QtGui.QPushButton("set y") self.btn4 = QtGui.QPushButton("Clear hotspot data") vb = QtGui.QVBoxLayout() vb.addWidget(self.combo) vb.addWidget(self.lbl1) vb.addWidget(self.lcd) vb.addWidget(self.sld) vb.addWidget(self.combo3) hb1 = QtGui.QVBoxLayout() hb1.addWidget(self.lbl3, 0) hb1.addWidget(self.combo2) vb.addLayout(hb1) vb.addWidget(self.btn) vb.addWidget(self.btn2) vb.addWidget(self.btn3) vb.addWidget(self.btn4) self.setLayout(vb)
def initUI(self): self.combo = QtGui.QComboBox(self) self.method = QtGui.QComboBox(self) self.btn = QtGui.QPushButton('Click2') self.btn2 = QtGui.QPushButton("Click3") vb = QtGui.QVBoxLayout() vb.addWidget(self.combo) vb.addWidget(self.method) vb.addWidget(self.btn) vb.addWidget(self.btn2) self.setLayout(vb)
def initUI(self): self.sld = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.lcd = QtGui.QLCDNumber(self) self.combo = QtGui.QComboBox(self) self.btn = QtGui.QPushButton('Click2') self.btn.setText("Sinogram") self.btn2 = QtGui.QPushButton("shift data") self.btn3 = QtGui.QPushButton("X 10") self.btn4 = QtGui.QPushButton("/ 10") hb = QtGui.QHBoxLayout() hb.addWidget(self.btn3) hb.addWidget(self.btn4) self.btn3.setVisible(False) self.btn4.setVisible(False) self.lbl = QtGui.QLabel() self.lbl.setText("") vb = QtGui.QVBoxLayout() vb.addWidget(self.combo) vb.addWidget(self.btn) vb.addWidget(self.btn2) vb.addWidget(self.lcd) vb.addWidget(self.sld) vb.addWidget(self.lbl) vb.addLayout(hb) self.setLayout(vb)
def getparameters(self): self.parametersquit = QtGui.QVBoxLayout() #creating user input boxes self.enterobserver = QtGui.QLineEdit('JMB') self.enterobserver.setMaxLength(3) self.enterdatamode = QtGui.QComboBox() self.enterdatamode.addItems(['Error', 'Raw', 'Low Pass Filtered', 'Mixed Mode', 'SQ1 Feedback']) self.enterreadoutcard = QtGui.QComboBox() for i in range(8): if i < 4: self.enterreadoutcard.addItem('MCE 1 RC %s' % (i % 4 + 1)) else: self.enterreadoutcard.addItem('MCE 2 RC %s' % (i % 4 + 1)) self.enterreadoutcard.addItem('All') self.enterframenumber = QtGui.QLineEdit('1350000') self.enterframenumber.setMaxLength(9) self.enterdatarate = QtGui.QLineEdit('45') self.entertimeinterval = QtGui.QLineEdit('120') self.enterchanneldelete = QtGui.QComboBox() self.enterchanneldelete.addItems(['No', 'Yes']) self.submitbutton = QtGui.QPushButton('Submit') self.parameters = QtGui.QFormLayout() self.parameters.addRow('Observer', self.enterobserver) self.parameters.addRow('Datamode', self.enterdatamode) self.parameters.addRow('Readout Card', self.enterreadoutcard) self.parameters.addRow('Frame Number', self.enterframenumber) self.parameters.addRow('Data Rate', self.enterdatarate) self.parameters.addRow('Delete Old Channels', self.enterchanneldelete) self.parameters.addRow('Time Interval (s)', self.entertimeinterval) self.parameters.addRow(self.submitbutton) self.parametersquit.addLayout(self.parameters) #creating quit button self.quitbutton = QtGui.QPushButton('Quit') self.parametersquit.addWidget(self.quitbutton) self.readoutcardselect = QtGui.QComboBox() self.selectchannel = QtGui.QComboBox()
def __setupPlots(self, initialPars, **kwargs): """ This function sets up the GUI layout, adding PyQT widgets Fills the layout with objects, sets an roi to crosshair. Input: initialParameters -- Dictionary, Dictionary containing parameters of data file, needed for GUI setup. winTitle -- string, Optional Title of QWindow, default = 'Window'.None Output: None Shared Objects: imv1 -- QtGui.ImageView Item which is used to plot the map of the SHO values at a given step imv2 -- QtGui.PlotWidget Item which is used to plot the current loop selected by the CrossHairsRoi from imv1 imv3 -- QtGui.PlotWidget Item which is used to plot the DC offset or AC Amplitude vs. step number roiPt -- pg.CrossHairROI ROI object within imv1 which determines the position used to generate the loop in imv2 roi1 -- pg.ROI Standard ROI object within imv1 posLine -- pt.InfiniteLine Object in imv3 which is used to denote the current UDVS step. It's position is sinced with the frame number in imv1 cycle_list -- QtGui.ComboBox Object which allows the user to select which cycle to display plot_list -- QtGui.ComboBox Object which allows the used to select which of the SHO parameters to plot roi_list -- QtGui.ComboBox Object which allows the user to change the x-variable in imv2 from Voltage/Current to UDVS step part_list -- QtGuiComboBox Object which allows the user to select between in or out-of-field for DC and forward or reverse for AC xlabel -- Numpy Array Array holding (Name,Unit) pairs of options for the x-axis of imv2 ylabel -- Numpy Array Array holding (Name,Unit) pairs of options for the y-axis of imv2 ndims -- Int Number of spacial dimensions in data """ # Get the relevant parameters to enable plotting, labels etc. num_of_cycles = initialPars['Number of Cycles'] ylabel = initialPars['ylabel'] # This has to change! xlabel = initialPars['xlabel'] plot_elements_list = initialPars['Plot Elements'] data_part_list = initialPars['Pieces'] Ndims = initialPars['NDims'] roi_elements_list = xlabel[:, 0] ''' Setup the layout for the window ''' cw = QtGui.QWidget() # Add the plotting widget self.setCentralWidget(cw) # What does this do? l = QtGui.QGridLayout() # Use a layout cw.setLayout(l) ''' Create the Image and plot widgets ''' if Ndims == 1: imv1, imv2, imv3 = self.__setupOneD(xlabel, ylabel) else: imv1, imv2, imv3 = self.__setupTwoD(xlabel, ylabel) ''' Create combo boxes ''' cycle_list = QtGui.QComboBox( ) # Make a combo box for selecting cycle number plot_list = QtGui.QComboBox( ) # Make a combo box for selecting what variable to plot roi_list = QtGui.QComboBox( ) # Choose between plotting versus voltage or step number part_list = QtGui.QComboBox() # Choose the field or direction func_list = [] ''' Now populate them ''' for i in xrange(num_of_cycles): cycle_list.addItem("Cycle " + str(i)) for plot_element in plot_elements_list: plot_list.addItem(plot_element[0]) func_list.append(plot_element[1]) for roi_element in roi_elements_list: roi_list.addItem(roi_element) for part in data_part_list: part_list.addItem(part) glab = QtGui.QLabel('SHO Guess Parameters') g0lab = QtGui.QLabel('Amp: {}'.format('-')) g1lab = QtGui.QLabel('w0: {}'.format('-')) g2lab = QtGui.QLabel('Q: {}'.format('-')) g3lab = QtGui.QLabel('Phase: {}'.format('-')) rlab = QtGui.QLabel('SHO Result Parameters') r0lab = QtGui.QLabel('Amp: {}'.format('-')) r1lab = QtGui.QLabel('w0: {}'.format('-')) r2lab = QtGui.QLabel('Q: {}'.format('-')) r3lab = QtGui.QLabel('Phase: {}'.format('-')) ''' Add the widgets to the layout addWidget(WidgetName, Row,Col, RowSpan,ColSpan) ''' l.addWidget(imv1, 0, 0, 13, 5) # Add them at these positions l.addWidget(imv2, 0, 5, 13, 5) l.addWidget(imv3, 14, 0, 2, 10) l.addWidget(cycle_list, 0, 10) l.addWidget(plot_list, 1, 10) l.addWidget(roi_list, 2, 10) l.addWidget(part_list, 3, 10) l.addWidget(glab, 4, 10) l.addWidget(g0lab, 5, 10) l.addWidget(g1lab, 6, 10) l.addWidget(g2lab, 7, 10) l.addWidget(g3lab, 8, 10) l.addWidget(rlab, 9, 10) l.addWidget(r0lab, 10, 10) l.addWidget(r1lab, 11, 10) l.addWidget(r2lab, 12, 10) l.addWidget(r3lab, 13, 10) ''' Customize the Voltage/Current vs time plot ''' imv3.setMaximumHeight(150) # Don't want this to be too big imv3.getPlotItem().setLabel('left', text=ylabel[0, 0], units=ylabel[0, 1]) imv3.getPlotItem().setLabel('bottom', text=xlabel[1, 0], units=xlabel[1, 1]) imv3.getViewBox().setMouseEnabled(x=False, y=False) posLine = pg.InfiniteLine(angle=90, movable=True, pen='g') imv3.addItem(posLine) posLine.setValue(0) posLine.setZValue(100) ''' Share variables we'll need for later ''' self.ndims = Ndims self.imv1 = imv1 self.imv2 = imv2 self.imv3 = imv3 self.posLine = posLine self.cycle_list = cycle_list self.plot_list = plot_list self.roi_list = roi_list self.part_list = part_list self.xlabel = xlabel self.ylabel = ylabel self.func_list = func_list self.func = func_list[0] self.glabs = [g0lab, g1lab, g2lab, g3lab] self.rlabs = [r0lab, r1lab, r2lab, r3lab] return
def initUI(self): self.xSize = 20 self.ySize = 20 self.bgBtn = QtGui.QPushButton("Bg Value") self.delHotspotBtn = QtGui.QPushButton("Delete HS") self.normalizeBtn = QtGui.QPushButton("Normalize") self.cutBtn = QtGui.QPushButton("Cut") self.gaussian33Btn = QtGui.QPushButton("3*3 gauss") self.gaussian55Btn = QtGui.QPushButton("5*5 gauss") self.xUpBtn = QtGui.QPushButton("x: +") self.xUpBtn.clicked.connect(self.xUp) self.xDownBtn = QtGui.QPushButton("x: -") self.xDownBtn.clicked.connect(self.xDown) self.yUpBtn = QtGui.QPushButton("y: +") self.yUpBtn.clicked.connect(self.yUp) self.yDownBtn = QtGui.QPushButton("y: -") self.yDownBtn.clicked.connect(self.yDown) self.xSizeLbl = QtGui.QLabel("x Size") self.ySizeLbl = QtGui.QLabel("y Size") self.xSizeTxt = QtGui.QLineEdit(str(self.xSize)) self.ySizeTxt = QtGui.QLineEdit(str(self.ySize)) self.combo1 = QtGui.QComboBox() self.combo2 = QtGui.QComboBox() hb1 = QtGui.QHBoxLayout() hb1.addWidget(self.xUpBtn) hb1.addWidget(self.xDownBtn) hb2 = QtGui.QHBoxLayout() hb2.addWidget(self.xSizeLbl) hb2.addWidget(self.xSizeTxt) hb3 = QtGui.QHBoxLayout() hb3.addWidget(self.yUpBtn) hb3.addWidget(self.yDownBtn) hb4 = QtGui.QHBoxLayout() hb4.addWidget(self.ySizeLbl) hb4.addWidget(self.ySizeTxt) vb1 = QtGui.QVBoxLayout() vb1.addLayout(hb1) vb1.addLayout(hb2) vb2 = QtGui.QVBoxLayout() vb2.addLayout(hb3) vb2.addLayout(hb4) xSG = QtGui.QGroupBox("x Size") xSG.setLayout(vb1) ySG = QtGui.QGroupBox("y Size") ySG.setLayout(vb2) vb3 = QtGui.QVBoxLayout() vb3.addWidget(self.combo1) vb3.addWidget(self.combo2) vb3.addWidget(xSG) vb3.addWidget(ySG) hb6 = QtGui.QHBoxLayout() hb6.addWidget(self.bgBtn, stretch=0) hb6.addWidget(self.delHotspotBtn, stretch=0) hb7 = QtGui.QHBoxLayout() hb7.addWidget(self.normalizeBtn, stretch=0) hb7.addWidget(self.cutBtn, stretch=0) hb8 = QtGui.QHBoxLayout() hb8.addWidget(self.gaussian33Btn, stretch=0) hb8.addWidget(self.gaussian55Btn, stretch=0) vb3.addLayout(hb6) vb3.addLayout(hb7) vb3.addLayout(hb8) self.setLayout(vb3)
def initUI(self): self.combo = QtGui.QComboBox(self) self.method = QtGui.QComboBox(self) self.btn = QtGui.QPushButton('Click2') self.save = QtGui.QPushButton("Save tiff files") self.save.setHidden(True) self.btn.setText("Sinogram") self.sld = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.lcd = QtGui.QLineEdit("0") self.lbl = QtGui.QLabel() self.cbox = QtGui.QCheckBox("") self.lbl2 = QtGui.QLabel("Center") self.lbl.setText("") self.threshLbl = QtGui.QLabel("threshold") self.threshLe = QtGui.QLineEdit("") self.threshBtn = QtGui.QPushButton("Apply") centerBox = QtGui.QHBoxLayout() centerBox.addWidget(self.cbox) centerBox.addWidget(self.lbl2) centerBox.addWidget(self.lcd) self.lcd.setEnabled(False) self.methodname = ["mlem", "gridrec", "art", "pml_hybrid", "pml_quad"] self.mulBtn = QtGui.QPushButton("x 10") self.divBtn = QtGui.QPushButton("/ 10") mdBox = QtGui.QHBoxLayout() mdBox.addWidget(self.mulBtn) mdBox.addWidget(self.divBtn) self.maxLbl = QtGui.QLabel("Max") self.minLbl = QtGui.QLabel("Min") self.maxText = QtGui.QLineEdit() self.minText = QtGui.QLineEdit() maxBox = QtGui.QHBoxLayout() minBox = QtGui.QHBoxLayout() maxBox.addWidget(self.maxLbl) maxBox.addWidget(self.maxText) minBox.addWidget(self.minLbl) minBox.addWidget(self.minText) self.betaName = QtGui.QLabel("Beta") self.deltaName = QtGui.QLabel("Delta") self.itersName = QtGui.QLabel("Iteration") self.beta = QtGui.QLineEdit("1") self.delta = QtGui.QLineEdit("0.01") self.iters = QtGui.QLineEdit("10") betaBox = QtGui.QHBoxLayout() deltaBox = QtGui.QHBoxLayout() itersBox = QtGui.QHBoxLayout() threshBox = QtGui.QHBoxLayout() betaBox.addWidget(self.betaName) betaBox.addWidget(self.beta) deltaBox.addWidget(self.deltaName) deltaBox.addWidget(self.delta) itersBox.addWidget(self.itersName) itersBox.addWidget(self.iters) threshBox.addWidget(self.threshLbl) threshBox.addWidget(self.threshLe) threshBox.addWidget(self.threshBtn) for k in arange(len(self.methodname)): self.method.addItem(self.methodname[k]) vb = QtGui.QVBoxLayout() vb.addWidget(self.combo) vb.addWidget(self.method) vb.addWidget(self.btn) vb.addWidget(self.save) vb.addLayout(centerBox) vb.addLayout(threshBox) vb.addWidget(self.sld) vb.addWidget(self.lbl) vb.addLayout(mdBox) vb.addLayout(maxBox) vb.addLayout(minBox) vb.addLayout(itersBox) vb.addLayout(betaBox) vb.addLayout(deltaBox) self.setLayout(vb)
def getparameters(self): #creating user input boxes self.enterobserver = QtGui.QLineEdit('VLB') self.enterobserver.setMaxLength(3) self.enterdatamode = QtGui.QComboBox() self.enterdatamode.addItems( ['Error', 'Raw', 'Filtered SQ1 Feedback', 'Debugging', 'Mixed Mode (25:7)','Mixed Mode (22:10)','Mixed Mode (24:8)','Mixed mode (18:14)']) self.enterreadoutcard = QtGui.QComboBox() for i in range(8): if i < 4: self.enterreadoutcard.addItem('MCE 1 RC %s' % (i % 4 + 1)) else: self.enterreadoutcard.addItem('MCE 2 RC %s' % (i % 4 + 1)) self.enterreadoutcard.addItem('All') self.enterframenumber = QtGui.QLineEdit('1350000') self.enterframenumber.setMaxLength(9) self.enterdatarate = QtGui.QLineEdit('45') self.entertimeinterval = QtGui.QLineEdit('120') self.enterchanneldelete = QtGui.QComboBox() self.enterchanneldelete.addItems(['No', 'Yes']) self.entershowmcedata = QtGui.QComboBox() self.entershowmcedata.addItems(['Yes', 'No']) self.submitbutton = QtGui.QPushButton('Submit') self.mceGroupBox = QtGui.QGroupBox("MCE Parameters") self.parameters = QtGui.QFormLayout() self.mcetitle = QtGui.QLabel(self) self.mcetitle.setAlignment(QtCore.Qt.AlignCenter) self.mcetitle.setText('MCE Parameters') self.parameters.addRow(self.mcetitle) self.parameters.addRow('Observer', self.enterobserver) self.parameters.addRow('Datamode', self.enterdatamode) self.parameters.addRow('Readout Card', self.enterreadoutcard) self.parameters.addRow('Frame Number', self.enterframenumber) self.parameters.addRow('Data Rate', self.enterdatarate) self.parameters.addRow('Delete Old Columns', self.enterchanneldelete) self.parameters.addRow('Time Interval (s)', self.entertimeinterval) self.parameters.addRow('Show MCE Data', self.entershowmcedata) self.parameters.addRow(self.submitbutton) self.mceGroupBox.setLayout(self.parameters) # telescope options ================================================= self.telescan = QtGui.QComboBox() self.telescan.addItems(['1D','2D','BowTie (constant el)']) self.tel_delay = QtGui.QLineEdit('0') self.init_tel = QtGui.QComboBox() self.init_tel.addItems(['No','Yes']) self.telGroupBox = QtGui.QGroupBox("Telescope Parameters") self.telparams = QtGui.QFormLayout() self.teltitle = QtGui.QLabel(self) self.teltitle.setAlignment(QtCore.Qt.AlignCenter) self.teltitle.setText('Telescope Parameters') self.telparams.addRow(self.teltitle) self.telparams.addRow('Activate Telescope', self.init_tel) self.telparams.addRow('Scan Strategy', self.telescan) self.telparams.addRow('Delayed Start (sec)', self.tel_delay) self.starttel = QtGui.QPushButton('Initialize Telescope') self.telparams.addRow(self.starttel) self.telGroupBox.setLayout(self.telparams) # ===================================================================== self.parametersquit = QtGui.QVBoxLayout() self.parametersquit.setAlignment(QtCore.Qt.AlignCenter) self.parametersquit.addWidget(self.telGroupBox) self.parametersquit.addWidget(self.mceGroupBox) self.quitbutton = QtGui.QPushButton('Quit') self.parametersquit.addWidget(self.quitbutton) self.readoutcardselect = QtGui.QComboBox() self.selectchannel = QtGui.QComboBox() self.selectrow = QtGui.QComboBox()
def initUI(self): """Initialise the GUI.""" self.usemock = False hbmain = QtGui.QHBoxLayout() self.plt1 = pg.PlotWidget() self.plt1.setLabel('left', "y (mm)") self.plt1.setLabel('bottom', "x (mm)") self.plt1.showGrid(x=True, y=True) self.plt_headposition_x = pg.InfiniteLine(angle=90, movable=False) self.plt_headposition_y = pg.InfiniteLine(angle=0, movable=False) self.plt1.addItem(self.plt_headposition_x) self.plt1.addItem(self.plt_headposition_y) self.plt_gcode = self.plt1.plot(pen=pg.mkPen('r', width=2)) self.plt1.setAspectLocked(True,ratio=1) hbmain.addWidget(self.plt1) vbconsole = QtGui.QVBoxLayout() gb = QtGui.QGroupBox('console:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() self.gui_console_date_cb = QtGui.QCheckBox('show date', self, checkable=True, checked=False) self.gui_console_time_cb = QtGui.QCheckBox('show time', self, checkable=True, checked=False) gbvbhb.addWidget(self.gui_console_date_cb) gbvbhb.addWidget(self.gui_console_time_cb) gbvb.addLayout(gbvbhb) self.gui_consoletext = QtGui.QTextEdit() gbvb.addWidget(self.gui_consoletext) self.gui_command = QtGui.QLineEdit('', self) self.gui_command.returnPressed.connect(self.respond_gui_command) gbvb.addWidget(self.gui_command) gb.setLayout(gbvb) vbconsole.addWidget(gb) hbmain.addLayout(vbconsole) vbcontrols = QtGui.QVBoxLayout() gb = QtGui.QGroupBox('connection:') gbvb = QtGui.QVBoxLayout() hbox = QtGui.QHBoxLayout() pb = QtGui.QPushButton("Scan") pb.clicked.connect(self.scan) self.scanbtn = pb hbox.addWidget(pb) cb=QtGui.QComboBox() self.port_list=cb self.port_list.setMinimumWidth(200) hbox.addWidget(cb) cb=QtGui.QCheckBox("Open") self.opened=cb cb.stateChanged.connect(self.toggle_connection) hbox.addWidget(cb) gbvb.addLayout(hbox) gb.setLayout(gbvb) vbcontrols.addWidget(gb) # gb = QtGui.QGroupBox('controls:') # gbvb = QtGui.QVBoxLayout() # gbvbhb = QtGui.QHBoxLayout() # btn = QtGui.QPushButton('unlock') # btn.clicked.connect(self.unlock) # gbvbhb.addWidget(btn) # btn = QtGui.QPushButton('FEED HOLD') # btn.clicked.connect(self.feed_hold) # gbvbhb.addWidget(btn) # btn = QtGui.QPushButton('RESUME') # btn.clicked.connect(self.feed_resume) # gbvbhb.addWidget(btn) # gbvb.addLayout(gbvbhb) # gb.setLayout(gbvb) # vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('main:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() btn = QtGui.QPushButton('unlock') btn.clicked.connect(self.unlock) gbvbhb.addWidget(btn) self.motorlock_enable_cb = QtGui.QCheckBox('motorlock', self, checkable=True, checked=True) self.motorlock_enable_cb.clicked.connect(self.motorlock_toggle) gbvbhb.addWidget(self.motorlock_enable_cb) btn = QtGui.QPushButton('set MCS zero (home)!') btn.clicked.connect(self.gui_set_mcs_zero) gbvbhb.addWidget(btn) btn = QtGui.QPushButton('set WCS zero!') btn.clicked.connect(self.gui_set_wcs_zero) gbvbhb.addWidget(btn) gbvb.addLayout(gbvbhb) gbvbhb = QtGui.QHBoxLayout() btn = QtGui.QPushButton('G0 go to MCS origin') btn.clicked.connect(self.go_to_mcs_origin) gbvbhb.addWidget(btn) btn = QtGui.QPushButton('G0 go to WCS origin') btn.clicked.connect(self.go_to_wcs_origin) gbvbhb.addWidget(btn) gbvb.addLayout(gbvbhb) gb.setLayout(gbvb) vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('position:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() btn = QtGui.QPushButton('get state') btn.clicked.connect(self.gui_get_state) gbvbhb.addWidget(btn) self.gui_get_state_online_cb = QtGui.QCheckBox('online', self, checkable=True, checked=False) self.gui_get_state_online_cb.clicked.connect(self.gui_get_state_online_cb_clicked) gbvbhb.addWidget(self.gui_get_state_online_cb) gbvb.addLayout(gbvbhb) gbvbhb = QtGui.QHBoxLayout() self.gui_info_state1 = QtGui.QLabel('state', self) self.gui_info_state2 = QtGui.QLabel('state', self) self.gui_info_mcs_x = QtGui.QLabel('MCS x', self) self.gui_info_mcs_y = QtGui.QLabel('MCS y', self) self.gui_info_wcs_x = QtGui.QLabel('WCS x', self) self.gui_info_wcs_y = QtGui.QLabel('WCS y', self) gbvb.addWidget(self.gui_info_state1) gbvb.addWidget(self.gui_info_state2) gbvbhb = QtGui.QHBoxLayout() gbvbhb.addWidget(self.gui_info_mcs_x) gbvbhb.addWidget(self.gui_info_mcs_y) # gbvb.addLayout(gbvbhb) #gbvbhb = QtGui.QHBoxLayout() gbvbhb.addWidget(self.gui_info_wcs_x) gbvbhb.addWidget(self.gui_info_wcs_y) gbvb.addLayout(gbvbhb) gbvb.addLayout(gbvbhb) gb.setLayout(gbvb) vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('jogging controls:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() #btn = QtGui.QPushButton('1') #btn.clicked.connect(self.unlock) #gbvbhb.addWidget(btn) self.gui_jog_stepsize = Spinner('jog step size (mm):', 1, step=1, guic=gbvbhb) self.gui_jog_feedrate = Spinner('feed rate (mm/min):', 5000, step=100, guic=gbvbhb) gbvb.addLayout(gbvbhb) horizontalGroupBox = QtGui.QGroupBox("") layout = QtGui.QGridLayout() layout.setColumnStretch(0, 1) layout.setColumnStretch(1, 1) layout.setColumnStretch(2, 1) def set_jogfun(what): def fun(): self.jog(what) return fun #d = {'what': '-x +y', 'n': 0, 'm': 0} def makebutton(d): btn = QtGui.QPushButton(d['what']) btn.clicked.connect(set_jogfun(d['what'])) layout.addWidget(btn,d['n'],d['m']) makebutton({'what': '-x +y', 'n': 0, 'm': 0}) makebutton({'what': '+y', 'n': 0, 'm': 1}) makebutton({'what': '+x +y', 'n': 0, 'm': 2}) makebutton({'what': '-x', 'n': 1, 'm': 0}) # makebutton({'what': '', 'n': 1, 'm': 1}) makebutton({'what': '+x', 'n': 1, 'm': 2}) makebutton({'what': '-x -y', 'n': 2, 'm': 0}) makebutton({'what': '-y', 'n': 2, 'm': 1}) makebutton({'what': '+x -y', 'n': 2, 'm': 2}) horizontalGroupBox.setLayout(layout) gbvb.addWidget(horizontalGroupBox) gb.setLayout(gbvb) vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('absolute positioning:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() self.gui_g1_xpos_mm = Spinner('x (mm):', 0, step=1, guic=gbvbhb) self.gui_g1_ypos_mm = Spinner('y (mm):', 0, step=1, guic=gbvbhb) gbvb.addLayout(gbvbhb) self.gui_g1_feedrate = Spinner('feed rate (mm/min):', 5000, step=100, guic=gbvb) gbvbhb = QtGui.QHBoxLayout() btn = QtGui.QPushButton('G0 GO') btn.clicked.connect(self.g0_go_to_position) gbvbhb.addWidget(btn) btn = QtGui.QPushButton('G1 GO') btn.clicked.connect(self.g1_go_to_position) gbvbhb.addWidget(btn) gbvb.addLayout(gbvbhb) gb.setLayout(gbvb) vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('spindle control:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() self.gui_spindlespeed = Spinner('spindle / servo:', 600, step=50, bounds=[0, 1000], guic=gbvbhb, fun=self.set_spindle_speed) self.gui_spindle_enable_cb = QtGui.QCheckBox('Spindle', self, checkable=True, checked=False) self.gui_spindle_enable_cb.clicked.connect(self.gui_spindle_enable_cb_clicked) gbvbhb.addWidget(self.gui_spindle_enable_cb) #btn = QtGui.QPushButton('ON') #btn.clicked.connect(self.set_spindle_on) #gbvbhb.addWidget(btn) #btn = QtGui.QPushButton('OFF') #btn.clicked.connect(self.set_spindle_off) #gbvbhb.addWidget(btn) gbvb.addLayout(gbvbhb) gb.setLayout(gbvb) vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('G-code streaming:') gbvb = QtGui.QVBoxLayout() gbvbhb = QtGui.QHBoxLayout() l = QtGui.QLabel('file:') gbvbhb.addWidget(l) self.gcodefile_text = QtGui.QTextEdit(os.path.join(os.path.expanduser('~'), 'test.gcode')) self.gcodefile_text.setMinimumWidth(150) self.gcodefile_text.setMaximumHeight(30) gbvbhb.addWidget(self.gcodefile_text) btn = QtGui.QPushButton('...') btn.clicked.connect(self._browse_gcodefile) gbvbhb.addWidget(btn) btn = QtGui.QPushButton('load') btn.clicked.connect(self.gcode_load_file) gbvbhb.addWidget(btn) gbvb.addLayout(gbvbhb) gbvbhb = QtGui.QHBoxLayout() self.gcode_stream_progressbar = QtGui.QProgressBar(self) gbvbhb.addWidget(self.gcode_stream_progressbar) btn = QtGui.QPushButton('start streaming') btn.clicked.connect(self.gcode_stream_start) gbvbhb.addWidget(btn) btn = QtGui.QPushButton('stop streaming') btn.clicked.connect(self.gcode_stream_stop) gbvbhb.addWidget(btn) gbvb.addLayout(gbvbhb) self.gui_eta_info = QtGui.QLabel('--- streaming ETA info ---', self) gbvb.addWidget(self.gui_eta_info) gbvb.addLayout(gbvbhb) gb.setLayout(gbvb) vbcontrols.addWidget(gb) gb = QtGui.QGroupBox('') gbhb = QtGui.QHBoxLayout() btn = QtGui.QPushButton('FEED HOLD') btn.clicked.connect(self.feed_hold) btn.setMinimumHeight(60) gbhb.addWidget(btn) btn = QtGui.QPushButton('RESUME') btn.clicked.connect(self.feed_resume) btn.setMinimumHeight(60) gbhb.addWidget(btn) gb.setLayout(gbhb) vbcontrols.addWidget(gb) hbmain.addLayout(vbcontrols) hbmain.setStretch(0,2) hbmain.setStretch(1,1) hbmain.setStretch(2,1) self.setLayout(hbmain) self.setGeometry(20, 40, 1400, 900) self.setWindowTitle('Vplotter Controller') self.setStyleSheet("font-size: 12pt") self.show() self.scan() self.get_state_timer = QtCore.QTimer() self.get_state_timer.timeout.connect(self.gui_get_state) self.serial_active = False self.gcode_stream_running = False