def set_up_tabs(self): """Initiate two tabs for UI""" _2D_maps_tab = QtGui.QWidget() _3D_maps_tab = QtGui.QWidget() self._2D_maps_tab_placement = QtGui.QGridLayout(_2D_maps_tab) self._3D_maps_tab_placement = QtGui.QGridLayout(_3D_maps_tab) self.tab_widget.addTab(_2D_maps_tab, "2D Maps") self.tab_widget.addTab(_3D_maps_tab, "3D Maps")
def initheatmap(self,z1): #casts z as array for creating heatmap # z1 = np.asarray(z1) #z2 = np.asarray(self.z2) #recasting data in z as integers # z1.astype(int) #z2.astype(int) self.heatmapplot = pg.PlotItem() self.heatmapplot.setLabel('bottom', 'Row') self.heatmapplot.setLabel('left', 'Channel') self.heatmapplot.setTitle('MCE RMS Channel Noise') self.heatmap = pg.ImageView(view= self.heatmapplot) self.heatmap.setPredefinedGradient('thermal') self.heatmap.autoLevels() self.heatmap.setImage(z1) #changes levels for heatmap to create gradient at depending on the data rate self.avggrad = int(np.average(z1)) self.stddevgrad = int(np.std(z1)) # self.heatmap.setLevels(self.avggrad - (3 * self.stddevgrad), self.avggrad + (3 * self.stddevgrad)) # self.grid.addWidget(self.heatmap, 3, 2, 2, 3) # create new window for hk and fft data self.heatmapwindow = QtGui.QWidget() self.heatmapwindow.setWindowTitle('MCE RMS Noise Map') self.heatgrid = QtGui.QGridLayout() self.heatgrid.addWidget(self.heatmap, 3, 2, 2, 3) self.heatmapwindow.setGeometry(10, 10, 1920, 1080) self.heatmapwindow.setLayout(self.heatgrid) self.heatmapwindow.show()
def initUI(self): self.grid = QtGui.QGridLayout() self.setLayout(self.grid) self.lbl1 = QtGui.QLabel("Select beamline") self.lbl2 = QtGui.QLabel( "Enter theta position pv if other than default") self.lbl3 = QtGui.QLabel("Warning Message") self.lbl4 = QtGui.QLabel( "NOTE: PV for 2-IDE data processed before Feb 2018 is 657") self.btn = QtGui.QPushButton("Okay") self.txtfield = QtGui.QLineEdit("8") self.txtfield2 = QtGui.QLineEdit("663") self.button = QtGui.QCheckBox("Bionanoprobe") self.button2 = QtGui.QCheckBox("2-IDE") self.setWindowTitle('Configuration') self.btn.setAutoRepeat(True) vb = QtGui.QVBoxLayout() vb.addWidget(self.lbl1, 1) vb.addWidget(self.button, 2) vb.addWidget(self.button2, 3) vb2 = QtGui.QVBoxLayout() vb2.addWidget(self.lbl2, 1) vb2.addWidget(self.txtfield, 2) vb2.addWidget(self.txtfield2, 3) vb3 = QtGui.QVBoxLayout() vb3.addWidget(self.lbl3) vb3.addWidget(self.lbl4) vb4 = QtGui.QVBoxLayout() vb4.addWidget(self.btn) self.grid.addLayout(vb, 0, 0, 2, 1) self.grid.addLayout(vb2, 0, 1, 2, 2) self.grid.addLayout(vb3, 4, 0, 2, 3) self.grid.addLayout(vb4, 6, 1, 1, 1)
def createGridLayout(self): """ Create a grid layout to manage the widgets size and position """ self.layout = QtGui.QGridLayout() self.setLayout(self.layout)
def __init__(self, plot_item, plot_item_parent): QtGui.QWidget.__init__(self) self.layout = QtGui.QGridLayout() self.plot_item = plot_item self.plot_item_parent = plot_item_parent self.rows = {} vb = self.plot_item.getViewBox() # graph size name = 'graph width' _, spinbox, check = self.add_row(name, "all") spinbox.setKeyboardTracking(False) spinbox.setValue(self.plot_item.width()) spinbox.valueChanged.connect(functools.partial(self.set_graph_width, spinbox, check)) vb.sigResized.connect(functools.partial(self.get_graph_width, spinbox)) name = 'graph height' _, spinbox, check = self.add_row(name, "all") spinbox.setKeyboardTracking(False) spinbox.setValue(self.plot_item.height()) spinbox.valueChanged.connect(functools.partial(self.set_graph_height, spinbox, check)) vb.sigResized.connect(functools.partial(self.get_graph_height, spinbox)) name = 'window width' _, spinbox = self.add_row(name) spinbox.setKeyboardTracking(False) spinbox.setValue(self.plot_item_parent.width()) spinbox.valueChanged.connect(functools.partial(self.set_layout_width, spinbox)) name = 'window height' _, spinbox = self.add_row(name) spinbox.setKeyboardTracking(False) spinbox.setValue(self.plot_item_parent.height()) spinbox.valueChanged.connect(functools.partial(self.set_layout_height, spinbox)) self.setLayout(self.layout) for plot_item in plot_item_parent.ci.items.keys(): self.sig_graph_height.connect(plot_item.setFixedHeight) self.sig_graph_width.connect(plot_item.setFixedWidth)
def __init__(self, num_processes, ip=None, port=None, ifc=None): super().__init__() self.central = QtGui.QWidget() # This will be our central widget self.grid_layout = QtGui.QGridLayout() self.setWindowTitle("CUWB Monitor - MAIN") self.sub_windows = dict() self.plot_windows = dict() self.network_discovery_window = NetworkDiscoveryWindow(num_processes, ip, port, ifc) self.aggregate_plot_window = AggregatePlotWindow() self.type_filter_window = TypeFilterWindow() self.network_discovery_window.show() self.type_filter_button = QtGui.QPushButton('Filter Data Types') self.type_filter_button.clicked.connect(self.open_type_filter_window) self.grid_layout.addWidget(self.type_filter_button, 2, 1) self.aggregate_plot_button = QtGui.QPushButton('Aggregate Plots') self.aggregate_plot_button.clicked.connect(self.open_aggregate_plots_window) self.grid_layout.addWidget(self.aggregate_plot_button, 1, 1) self.network_discovery_btn = QtGui.QPushButton('Network Discovery') self.network_discovery_btn.clicked.connect(self.open_discovery_window) self.grid_layout.addWidget(self.network_discovery_btn, 1, 0) self.reset_btn = QtGui.QPushButton('Reset All Windows') self.reset_btn.clicked.connect(self.reset_all_windows) self.grid_layout.addWidget(self.reset_btn, 2, 0) self.toggle_pause_play_btn = QtGui.QPushButton('Pause') self.toggle_pause_play_btn.clicked.connect(self.toggle_pause_play) self.grid_layout.addWidget(self.toggle_pause_play_btn, 3, 0, 1, 2) self.paused = False self.serial_title = QtGui.QLabel('SERIAL NUM') self.serial_title.setStyleSheet('color: black') self.serial_title.setAlignment(QtCore.Qt.AlignCenter) self.serial_title.setMargin(5) self.total_count_title = QtGui.QLabel('CDP CNT') self.total_count_title.setStyleSheet('color: black') self.total_count_title.setAlignment(QtCore.Qt.AlignCenter) self.serial_title.setMargin(5) self.grid_layout.addWidget(self.serial_title, 4, 0) self.grid_layout.addWidget(self.total_count_title, 4, 1) self.serial_labels = dict() self.total_count_labels = dict() self.count = 0 self.central.setLayout(self.grid_layout) self.setCentralWidget(self.central) self.resize(300, 100) self.startTimer(250) self.currently_filtering = False self.previous_nodes = set(UwbNetwork.nodes.keys())
def init_ui(self): self.setWindowTitle('MCE TIME Data') self.getparameters() self.grid = QtGui.QGridLayout() self.grid.addLayout(self.parametersquit, 1, 1, 1, 1) self.setLayout(self.grid) self.setGeometry(10, 10, 1920, 1080) self.show()
def init_ui(self): self.setWindowTitle('TIME Live Data Visualization Suite') self.getparameters() self.grid = QtGui.QGridLayout() self.grid.addLayout(self.parametersquit, 1, 1, 1, 1) self.setLayout(self.grid) self.setGeometry(10, 10, 1920, 1080) self.show()
def _construct_tabs(self): """ Constructs Qt.Gui.QWidgets (tabs) places widgets in corresponding tabs :return: """ modelTab = QtGui.QWidget() self.modelTabLayout = QtGui.QGridLayout(modelTab) self.tabsWidget.addTab(modelTab, "Model")
def initUI(self): names = list() for i in arange(self.numlabels): names.append("") self.grid = QtGui.QGridLayout() self.lbl = QtGui.QLabel() self.lbl2 = QtGui.QLabel() self.lbl.setText( "closing this window won't affect your selection of the files") self.lbl2.setText( "You should convert the files in order to generate sinogram or reconstructed data" ) self.btn = QtGui.QPushButton('Save Data in Memory', self) self.btn2 = QtGui.QPushButton("set Image Tag", self) self.btn3 = QtGui.QPushButton("set Element", self) self.btn4 = QtGui.QPushButton("Sort data by angle") columns = np.ceil(np.sqrt(self.numlabels)) rows = 10 j = 0 pos = list() for y in arange(columns): for x in arange(rows): pos.append((x, y)) self.button = list() for i in names: self.button.append(QtGui.QCheckBox(i)) self.grid.addWidget(self.button[j], pos[j][0], pos[j][1]) j = j + 1 self.setLayout(self.grid) self.vb = QtGui.QVBoxLayout() self.vb2 = QtGui.QVBoxLayout() self.vb.addWidget(self.lbl, 12) self.vb.addWidget(self.lbl2, 13) hb = QtGui.QHBoxLayout() hb.addWidget(self.btn2) hb.addWidget(self.btn3) hb.addWidget(self.btn4) self.vb2.addLayout(hb) self.vb2.addWidget(self.btn) self.grid.addLayout(self.vb, 11, 0, 1, 7) self.grid.addLayout(self.vb2, 13, 1, 1, 3) self.move(100, 100) self.setWindowTitle('Calculator') self.show()
def _construct_tabs(self): """ constructs Qt.Gui.QWidgets (tabs) places widgets in corresponding tabs :return: """ # digitizerTab: will contain all DockWidgets related to digitizer digitizerTab = QtGui.QWidget() modelTab = QtGui.QWidget() self.digitizerTabLayout = QtGui.QGridLayout(digitizerTab) self.tabsWidget.addTab(digitizerTab, "Digitizer") self.tabsWidget.addTab(modelTab, "Model")
def __init__(self): super().__init__() self.setWindowTitle('CUWB Monitor - CDP Data Type Filtering') self.num_columns = 10 self.central = QtGui.QWidget() self.grid_layout = QtGui.QGridLayout() self.central.setLayout(self.grid_layout) self.setCentralWidget(self.central) self.resize(1000, 400) self.current_types = set() self.filtering = False self.filter_toggle_button = QtGui.QPushButton('Start Filter') self.filter_toggle_button.clicked.connect(self.toggle_filter) self.grid_layout.addWidget(self.filter_toggle_button, 0, 0, 1, self.num_columns) self.type_count = 0 self.type_checkboxes = dict() self.type_labels = dict() self.types = dict() for cdp_type in cdp.CDP.data_item_classes.keys(): self.types[cdp_type] = cdp.CDP.data_item_classes[cdp_type].__name__ self.type_checkboxes[cdp_type] = QtGui.QCheckBox() self.type_labels[cdp_type] = QtGui.QLabel() self.type_count += 1 self.types[UNKNOWN_FILTER_TYPE] = 'Unknown Types' self.type_checkboxes[UNKNOWN_FILTER_TYPE] = QtGui.QCheckBox() self.type_labels[UNKNOWN_FILTER_TYPE] = QtGui.QLabel() type_per_col = (int(self.type_count / (self.num_columns / 2)) + 1) row = 1 col = 0 for cdp_type in sorted(self.types.keys()): self.grid_layout.addWidget(self.type_checkboxes[cdp_type], row, col) self.grid_layout.addWidget(self.type_labels[cdp_type], row, col + 1) self.type_labels[cdp_type].setText(self.types[cdp_type]) self.type_labels[cdp_type].setAlignment(QtCore.Qt.AlignLeft) row += 1 if row > type_per_col: col += 2 row = 1 self.timer = self.startTimer(QPLOT_FREQUENCY)
def widget(self): return self._widget w = QtGui.QGroupBox() w.setTitle(self.name) l = QtGui.QGridLayout() l.addWidget(self.bar, 0, 0) l.addWidget(self.slider, 0, 1) l.addWidget(self.button, 1, 0, 1, 2) w.setLayout(l) w.block = self return w
def __init__(self): """ model gui Contains the graphical aspects of user interface. Handles construction of: MainWindow tabWidgets DockArea DockWidgets GridLayouts """ super(ModelGUI, self).__init__() pg.setConfigOption('background', '#f8f8ff') pg.setConfigOption('foreground', 'k') # creating instance of ModelLogic self.MLogic = ModelLogic() # set minimum window size self.setMinimumSize(1000, 500) self.setStyleSheet('QMainWindow{background-color: lightsteelblue}') # dock area to contain all dock widgets self.model_ui = DockArea() self.gridLayout = QtGui.QGridLayout() # setting up gridLayout self.tabsWidget = QtGui.QTabWidget() # tab widget self.tabsWidget.setLayout(self.gridLayout) # setting layout for tabs self.setCentralWidget(self.tabsWidget) # setting tabs_widget to center # calling method to construct tabs self.modelTabLayout = None self._construct_tabs() # calling method to construct dock widgets self._model_docks() self._add_menu_buttons() # calling method to add objects to docks self._add_objects_to_docks() # adding model_ui to modelTabLayout and centering/showing window self.modelTabLayout.addWidget(self.model_ui) self.center() self.show()
def inittelescope(self): # start the telescope QThread self.tel_updater = Tel_Thread() self.tel_updater.new_tel_data.connect(self.updatetelescopedata) self.tel_updater.start() # initialize printouts of current tele values not plotted self.patext = QtGui.QLabel('PA: %s' %('-')) self.slewtext = QtGui.QLabel('Slew Flag: %s' %('-')) self.timetext = QtGui.QLabel('UTC Time: %s' %('-')) # create space for tele printout values self.telescopedata = QtGui.QVBoxLayout() self.telescopedata.addWidget(self.patext) self.telescopedata.addWidget(self.slewtext) self.telescopedata.addWidget(self.timetext) # create plot object for alt-az graph self.altazgraph = pg.PlotWidget() self.altazgraphdata = pg.ScatterPlotItem() self.altazgraph.addItem(self.altazgraphdata) self.altazgraph.showGrid(x=True, y=True) self.altazgraph.setTitle('Alt-Az Graph') self.altazgraph.setLabel('left', 'alt') self.altazgraph.setLabel('bottom', 'az') # create plot object for ra-dec graph self.radecgraph = pg.PlotWidget() self.radecgraphdata = pg.ScatterPlotItem() self.radecgraph.addItem(self.radecgraphdata) self.radecgraph.showGrid(x=True, y=True) self.radecgraph.setTitle('Ra-Dec Graph') self.radecgraph.setLabel('left', 'DEC (deg)') self.radecgraph.setLabel('bottom', 'RA (deg)') # create new window for telescope graphs self.telescopewindow = QtGui.QWidget() self.telescopewindow.setWindowTitle('Telescope Data') self.telegrid = QtGui.QGridLayout() self.telegrid.addLayout(self.telescopedata, 1, 1, 1, 1) self.telegrid.addWidget(self.altazgraph, 1, 2, 2, 2) self.telegrid.addWidget(self.radecgraph, 1, 4, 2, 2) self.telescopewindow.setGeometry(10, 10, 1920, 1080) self.telescopewindow.setLayout(self.telegrid) self.telescopewindow.show() self.repeat = False
def __init__(self): super(UI, self).__init__() """ Setting up UI: Widgets, background color, tabs, and windows size """ """ EMC contains all objects (maps, views, plots). Objects are first imported to EarthMod_controller thenEarthMod_controler is imported here. """ # instance of eEarthMod_controller self.EMC = Logic() self._2D_maps_ui = DockArea() self._3D_maps_ui = DockArea() self._2D_maps_tab_placement = None self._3D_maps_tab_placement = None # Dock area widgets that will contain our objects self.menu_dock = None self.data_df_dock = None self.contour_dock = None self.heat_dock = None self.variogram_dock = None self._3D_settings_dock = None self.map_img_dock = None self._3D_surface_dock = None # setting up layout self.vbox = QtGui.QGridLayout() self.tab_widget = QtGui.QTabWidget() self.tab_widget.setLayout(self.vbox) self.setCentralWidget(self.tab_widget) # calling methods self.set_up_tabs() self.build_2D_maps_docks() self.build_3D_map_docks() self.add_buttons_to_menu() self.add_objects_to_docks() self.setStyleSheet('QMainWindow{background-color: lightsteelblue}') self.setMinimumSize(1000, 700) self.center() self.show()
def __init__(self): """ digitizer gui: Contains the graphical aspects of the user interface. Handles construction of: MainWindow tabWidgets DockArea DockWidgets GridLayouts Does not construct QPushButtons. QPushButtons and their respective logic are imported from a separate python file/class. """ super(DigitizerGUI, self).__init__() # creating instance of DigitizerLogic self.DLogic = DigitizerLogic() # set minimum window size self.setMinimumSize(1000, 500) # dock areas to contain all dock widgets self.digitizer_ui = DockArea() self.gridLayout = QtGui.QGridLayout() # setting up gridLayout self.tabsWidget = QtGui.QTabWidget() # tab widget self.tabsWidget.setLayout(self.gridLayout) # setting layout for tabs self.setCentralWidget(self.tabsWidget) # setting tabs_widget to center # calling method to construct tabs self.digitizerTabLayout = None # Qt.Gui.GridLayout for digitizer_tab self._construct_tabs() # calling method to construct tabs_widgets # calling method to construct dock widgets self._digitizer_docks() self._add_menu_buttons() # calling method to add objects to docks self._add_objects_to_docks() self.digitizerTabLayout.addWidget(self.digitizer_ui) self.setStyleSheet('QMainWindow{background-color: lightsteelblue}') self.center() self.show()
def __init__(self, serial): QtGui.QMainWindow.__init__(self) self.central = QtGui.QWidget() #This will be our central widget self.serial = serial self.setWindowTitle( 'CUWB Monitor - Image Discovery ID: 0x{:08X}'.format(serial)) self.grid_layout = QtGui.QGridLayout() self.manufacturer_label = QtGui.QLabel("Manufacturer:N/A") self.product_label = QtGui.QLabel("Product:N/A") self.running_label = QtGui.QLabel("Running:N/A") self.grid_layout.addWidget(self.manufacturer_label, 0, 0) self.grid_layout.addWidget(self.product_label, 0, 1) self.grid_layout.addWidget(self.running_label, 0, 2) self.type_label_list = list() self.version_label_list = list() self.sha1_label_list = list() # Create 3 of each type, version, and sha info labels for idx in range(3): self.type_label_list.append(QtGui.QLabel("Image:N/A")) self.grid_layout.addWidget(self.type_label_list[idx], idx + 1, 0) self.grid_layout.itemAtPosition(idx + 1, 0).widget().hide() self.sha1_label_list.append(QtGui.QLabel("SHA:N/A")) self.grid_layout.addWidget(self.sha1_label_list[idx], idx + 1, 1) self.grid_layout.itemAtPosition(idx + 1, 1).widget().hide() self.version_label_list.append(QtGui.QLabel("Version:N/A")) self.grid_layout.addWidget(self.version_label_list[idx], idx + 1, 2) self.grid_layout.itemAtPosition(idx + 1, 2).widget().hide() self.central.setLayout(self.grid_layout) self.setCentralWidget(self.central) self.resize(825, 50) self.running = True self.show() self.timer = self.startTimer(QPLOT_FREQUENCY)
def inittelescope(self): tempfilename = 'tempfiles/quittele.txt' tempfile = open(tempfilename, 'w') tempfile.write('Open') tempfile.close() self.telescopewindow = QtGui.QWidget() self.telescopewindow.setWindowTitle('Telescope Data') self.inittelescopedata() self.telegrid = QtGui.QGridLayout() self.telegrid.addLayout(self.telescopedata, 1, 1, 1, 1) self.telegrid.addWidget(self.altazgraph, 1, 2, 2, 2) self.telegrid.addWidget(self.radecgraph, 1, 4, 2, 2) self.telescopewindow.setGeometry(50, 50, 100, 100) self.telescopewindow.setLayout(self.telegrid) self.telescopewindow.show() self.teletimer = pg.QtCore.QTimer() self.teletimer.timeout.connect(self.updatetelescopedata) self.teletimer.start(1000)
def create_ctrl_panel(win): panel = QWidget(win) panel.move(100, 0) win.scene().addWidget(panel) layout = QtGui.QGridLayout(panel) panel.symbol = QComboBox(panel) [ panel.symbol.addItem(i + 'USDT') for i in 'BTC ETH XRP DOGE BNB SOL ADA LTC LINK DOT TRX BCH'.split() ] panel.symbol.setCurrentIndex(1) layout.addWidget(panel.symbol, 0, 0) panel.symbol.currentTextChanged.connect(change_asset) layout.setColumnMinimumWidth(1, 30) panel.interval = QComboBox(panel) [panel.interval.addItem(i) for i in '1d 4h 1h 30m 15m 5m 1m'.split()] panel.interval.setCurrentIndex(6) layout.addWidget(panel.interval, 0, 2) panel.interval.currentTextChanged.connect(change_asset) layout.setColumnMinimumWidth(3, 30) panel.indicators = QComboBox(panel) [ panel.indicators.addItem(i) for i in 'Clean:Few indicators:Moar indicators'.split(':') ] panel.indicators.setCurrentIndex(1) layout.addWidget(panel.indicators, 0, 4) panel.indicators.currentTextChanged.connect(change_asset) layout.setColumnMinimumWidth(5, 30) panel.darkmode = QCheckBox(panel) panel.darkmode.setText('Haxxor mode') panel.darkmode.setCheckState(2) panel.darkmode.toggled.connect(dark_mode_toggle) layout.addWidget(panel.darkmode, 0, 6) return panel
def __init__(self): super().__init__() self.setWindowTitle("CUWB Monitor - Aggregate Plots") self.central = QtGui.QWidget() self.grid_layout = QtGui.QGridLayout() self.plot_windows = dict() self.plot_labels = dict() self.aggregate_plot_cnt = 0 for plot_type in sorted(list(map_type_to_aggregate_plot.keys())): self.plot_labels.update([(plot_type, QtGui.QLabel(plot_type))]) self.plot_labels[plot_type].setStyleSheet('color: blue') self.plot_labels[plot_type].mouseReleaseEvent = partial( self.plotClickEvent, plot_type) self.aggregate_plot_cnt += 1 self.grid_layout.addWidget(self.plot_labels[plot_type], self.aggregate_plot_cnt, 0) self.central.setLayout(self.grid_layout) self.setCentralWidget(self.central) self.resize(375, 20 + self.aggregate_plot_cnt * 20)
def testDatasetPlot(fd): widget = QtGui.QWidget() widget.setLayout(QtGui.QGridLayout()) oneDimPlot = DatasetPlot() plot, params = oneDimPlot.plotLine( fd['/data/event/balls/hit/ball_0_9ba91cb6163611e5899524fd526610e7']) widget.layout().addWidget(params, 0, 0) widget.layout().addWidget(oneDimPlot, 1, 0) compoundPlot = DatasetPlot() plot, params = compoundPlot.plotLine(fd['/data/static/tables/dimensions']) widget.layout().addWidget(params, 0, 1) widget.layout().addWidget(compoundPlot, 1, 1) twoDimPlot = DatasetPlot() plot, params = twoDimPlot.plotLine(fd['/data/uniform/balls/x']) widget.layout().addWidget(params, 0, 2) widget.layout().addWidget(twoDimPlot, 1, 2) nDimPlot = DatasetPlot() plot, params = nDimPlot.plotLine(fd['/data/uniform/ndim/data3d']) widget.layout().addWidget(params, 0, 3) widget.layout().addWidget(nDimPlot, 1, 3) widget.show() return widget
def init_gui(self): self.layout = QtGui.QGridLayout() self.setLayout(self.layout) self.title = QtGui.QLabel('<b>ANALISE DE CURVAS DE LUZ</b>', alignment=0x0004) self.bt_n = QtGui.QPushButton('usar um novo arquivo') self.kic = QtGui.QPushButton('buscar online') self.txt1 = QtGui.QLineEdit() self.txt2 = QtGui.QLineEdit() self.sub = QtGui.QPushButton('submit') self.layout.addWidget(self.title, 0, 0, 1, 2) self.layout.addWidget(self.bt_n, 1, 0) self.layout.addWidget(self.kic, 1, 1) self.layout.addWidget(self.txt1, 2, 0) self.layout.addWidget(self.txt2, 2, 1) self.layout.addWidget(self.sub, 2, 2) self.setGeometry(10, 10, 1000, 600) self.txt1.hide() self.txt2.hide() self.sub.hide() self.show()
def __init__(self, marketPairList=[]): super(ChartWindow, self).__init__() self.setWindowTitle('qmarket') cw = QtGui.QWidget() self.setCentralWidget(cw) self.layout = QtGui.QGridLayout() zeroLayoutMargins(self.layout) cw.setLayout(self.layout) self.restoreGeometry(gSettings.value('geometry').toByteArray()) QtGui.QShortcut(QtGui.QKeySequence('Q'), self, app.closeAllWindows) QtGui.QShortcut(QtGui.QKeySequence('W'), self, self.close) QtGui.QShortcut(QtGui.QKeySequence('N'), self, lambda: ChartWindow().show()) QtGui.QShortcut( QtGui.QKeySequence('Space'), self, lambda: self.mouseOverChartGroup .mainPlot().vb.menu.popup(QtGui.QCursor.pos())) # Set background palette to black pal = self.palette() pal.setColor(QtGui.QPalette.Window, Qt.black) self.setPalette(pal) self.closeEvent = self.closeEvent self.mouseOverChartGroup = None self.charts = MultiKeyDict() allWindows.append(self) coord = [0, 0] if marketPairList: if type(marketPairList) is tuple: marketPairList = [marketPairList] for marketPair in marketPairList: self.setChartAt(marketPair, coord) coord[ROW] += 1 else: self.setChartAt(None, coord)
def display_cuwb_networks_widget(self): self.cuwb_nets = QtGui.QWidget() self.cuwb_nets.setSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Maximum) nets_layout = QtGui.QVBoxLayout() self.cuwb_nets.setLayout(nets_layout) self.scroll_area.setWidget(self.cuwb_nets) if len(self.network_discovery.available_networks) == 0: label = QtGui.QLabel("No CUWB networks are available") label.setStyleSheet('color: red') nets_layout.addWidget(label, QtCore.Qt.AlignCenter) else: # Restart CDP streams indexes and empty all containers to avoid duplication self.stream_idx = 0 self.cdp_streams = dict() self.stream_checkboxes = dict() # All available addresses indexed by ListeningAddrInfo objects. # The values are sets of stream_idx. This information is used to # auto check/uncheck checkboxes equivalent addresses. # It does not include the indexes of streams with interface '0.0.0.0' self.available_addresses = dict() # It includes the indexes of streams with interface '0.0.0.0' self.any_interface_streams = dict() for serial, net_info in sorted( self.network_discovery.available_networks.items(), key=lambda item: (item[1].instance_name, item[1].hostname, item[1].source_ip)): cuwb_net = QtGui.QFrame() cuwb_net.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Raised) cuwb_net.setLineWidth(1) net_layout = QtGui.QGridLayout() net_layout.setMargin(0) cuwb_net.setLayout(net_layout) header = QtGui.QWidget() header_layout = QtGui.QGridLayout() header.setLayout(header_layout) label = QtGui.QLabel('Network: <b>{} ({})</b>'.format( net_info.instance_name, serial)) header_layout.addWidget(label, 0, 0) label = QtGui.QLabel('Host: <b>{}</b>'.format( net_info.hostname)) header_layout.addWidget(label, 0, 1) label = QtGui.QLabel('{}'.format(net_info.source_ip)) header_layout.addWidget(label, 0, 2, QtCore.Qt.AlignRight) net_layout.addWidget(header, 0, 0) streams = QtGui.QWidget() streams_layout = QtGui.QGridLayout() streams.setLayout(streams_layout) idx = 0 stream_order = ['external', 'internal', 'config', 'debug'] for stream_name in stream_order: # Check if we received information about the CDP stream # before trying to display it if stream_name not in net_info.cdp_streams: continue stream = net_info.cdp_streams[stream_name] label = QtGui.QLabel('{}'.format( stream.alias.capitalize())) streams_layout.addWidget(label, idx, 0) label = QtGui.QLabel('{}/{}'.format( stream.interface, stream.netmask)) streams_layout.addWidget(label, idx, 1) label = QtGui.QLabel('->') streams_layout.addWidget(label, idx, 2, QtCore.Qt.AlignCenter) label = QtGui.QLabel('{}:{}'.format( stream.ip, stream.port)) streams_layout.addWidget(label, idx, 3) # Add CDP stream checkbox and connect Qt signal to callback function to handle state changes self.stream_checkboxes[self.stream_idx] = QtGui.QCheckBox() self.stream_checkboxes[ self.stream_idx].stateChanged.connect( partial(self.stream_click_event, self.stream_idx)) streams_layout.addWidget( self.stream_checkboxes[self.stream_idx], idx, 4, QtCore.Qt.AlignRight) if not self.network_discovery.is_interface_available( stream): # Disable checkbox if interface is not on the same subnet self.stream_checkboxes[self.stream_idx].setEnabled( False) else: # Dynamically add attribute to store the equivalent address(es) # using the local interface(s) stream.equivalent_addresses = self.get_equivalent_addresses( stream) if stream.interface != StreamInformation.any_interface: for listen_addr in stream.equivalent_addresses: # Check if there is another CDP stream with the same IP, port and # equivalent local interface and keep track of the indexes of these streams if listen_addr not in self.available_addresses: self.available_addresses[ listen_addr] = set() self.available_addresses[listen_addr].add( self.stream_idx) # Check if we are already listening on this address and autocheck the checkbox if listen_addr in self.active_addresses: self.stream_checkboxes[ self.stream_idx].setChecked(True) else: # Check if there is another CDP stream with the same IP, port and # interface set to '0.0.0.0' and keep track of the indexes of these streams if stream not in self.any_interface_streams: self.any_interface_streams[stream] = set() self.any_interface_streams[stream].add( self.stream_idx) # Check if we are already listening on this address and autocheck the checkbox if stream in self.active_any_interface_streams: self.stream_checkboxes[ self.stream_idx].setChecked(True) # Keep track of all the displayed CDP streams and their indexes self.cdp_streams[self.stream_idx] = stream self.stream_idx += 1 idx += 1 net_layout.addWidget(streams, 1, 0) nets_layout.addWidget(cuwb_net)
pg.setConfigOption('foreground', 'k') plot2 = pg.PlotWidget(parent=None) #Modify widgets #Procurar funcao de set between lines cdp_window = cdp_gui.cdp_gui() cdp_index_text = cdp_window.spin_label cdp_index_spin = cdp_window.spin #Trace window cdp_window.plot_cdp() #Semblance window cdp_window.plot_semb() ## Create a grid layout to manage the widgets size and position layout = QtGui.QGridLayout() w.setLayout(layout) ## Add widgets to the layout in their proper positions layout.addWidget(cdp_index_text, 0, 0, 1, 1) layout.addWidget(cdp_index_spin, 1, 0, 2, 2) layout.addWidget(cdp_window.plot_traces, 2, 2, 20, 20) layout.addWidget(cdp_window.plot_semblance, 2, 22, 20, 20) ## Display the widget as a new window w.show() ## Start the Qt event loop app.exec_()
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 __init__(self, *args, **kwargs): super(ReconstructionParametersWidget, self).__init__(*args, **kwargs) self.prop_dist_start_widget = QtGui.QDoubleSpinBox(parent=self) self.prop_dist_start_widget.setValue(DEFAULT_PROPAGATION_DISTANCE) self.prop_dist_stop_widget = QtGui.QDoubleSpinBox(parent=self) self.prop_dist_step_widget = QtGui.QDoubleSpinBox(parent=self) self.prop_dist_start_label = QtGui.QLabel('Start') self.prop_dist_start_label.setAlignment(QtCore.Qt.AlignCenter) self.prop_dist_stop_label = QtGui.QLabel('Stop') self.prop_dist_stop_label.setAlignment(QtCore.Qt.AlignCenter) self.prop_dist_step_label = QtGui.QLabel('Step') self.prop_dist_step_label.setAlignment(QtCore.Qt.AlignCenter) for widget in (self.prop_dist_start_widget, self.prop_dist_stop_widget, self.prop_dist_step_widget): widget.setSuffix(' m') widget.setRange(0.0, 1.0) widget.setSingleStep(10 ^ -(widget.decimals())) widget.setDecimals(5) widget.editingFinished.connect(self.update_propagation_distance) self.set_multi_dist_mode( mode=0) # Initialize to single-propagation distance # Button group for single or multiple propagation distances single_prop_dist_btn = QtGui.QPushButton('Single propagation distance', parent=self) single_prop_dist_btn.setCheckable(True) single_prop_dist_btn.setChecked(True) multi_prop_dist_btn = QtGui.QPushButton( 'Multiple propagation distances', parent=self) multi_prop_dist_btn.setCheckable(True) multi_prop_dist_btn.setChecked(False) propagation_distance_mode = QtGui.QButtonGroup(parent=self) propagation_distance_mode.addButton(single_prop_dist_btn, 0) propagation_distance_mode.addButton(multi_prop_dist_btn, 1) propagation_distance_mode.setExclusive(True) propagation_distance_mode.buttonClicked[int].connect( self.set_multi_dist_mode) prop_dist_layout = QtGui.QGridLayout() prop_dist_layout.addWidget(self.prop_dist_start_label, 0, 0) prop_dist_layout.addWidget(self.prop_dist_step_label, 0, 1) prop_dist_layout.addWidget(self.prop_dist_stop_label, 0, 2) prop_dist_layout.addWidget(self.prop_dist_start_widget, 1, 0) prop_dist_layout.addWidget(self.prop_dist_step_widget, 1, 1) prop_dist_layout.addWidget(self.prop_dist_stop_widget, 1, 2) mode_btns = QtGui.QHBoxLayout() mode_btns.addWidget(single_prop_dist_btn) mode_btns.addWidget(multi_prop_dist_btn) propagation_distances_label = QtGui.QLabel( '<h3>Numerical Propagation Distance(s)</h3>') propagation_distances_label.setAlignment(QtCore.Qt.AlignCenter) self.load_fourier_mask_btn = QtGui.QPushButton('Load Fourier mask', self) self.load_fourier_mask_btn.clicked.connect(self.load_fourier_mask) self.clear_fourier_mask_btn = QtGui.QPushButton( 'Clear Fourier mask', self) self.clear_fourier_mask_btn.clicked.connect(self.clear_fourier_mask) self.fourier_mask_path_label = QtGui.QLabel( 'Current Fourier mask: None', self) self.fourier_mask_path_label.setAlignment(QtCore.Qt.AlignCenter) self._fourier_mask_path_signal.connect( self.fourier_mask_path_label.setText) fourier_mask_btns = QtGui.QHBoxLayout() fourier_mask_btns.addWidget(self.load_fourier_mask_btn) fourier_mask_btns.addWidget(self.clear_fourier_mask_btn) fourier_mask_label = QtGui.QLabel('<h3>Fourier Mask Controls</h3>') fourier_mask_label.setAlignment(QtCore.Qt.AlignCenter) layout = QtGui.QVBoxLayout() layout.addWidget(propagation_distances_label) layout.addLayout(prop_dist_layout) layout.addLayout(mode_btns) layout.addWidget(fourier_mask_label) layout.addWidget(self.fourier_mask_path_label) layout.addLayout(fourier_mask_btns) self.setLayout(layout)
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
def __init__(self, serial, main_window=None): super().__init__() # Reference to the main window when device_id is provided as a command argument. # This reference is used to close the main window, which is hidden in this mode. self.main_window = main_window self.resize_flag = True self.central = QtGui.QWidget() # This will be our central widget self.grid_layout = QtGui.QGridLayout() self.plot_windows = dict() self.display_windows = dict() self.serial = serial self.setWindowTitle('CUWB Monitor - ID: 0x{:08X}'.format(self.serial)) self.type_title = QtGui.QLabel('Type') self.type_title.setStyleSheet('color: black') self.type_title.setAlignment(QtCore.Qt.AlignRight) self.type_title.setMargin(5) self.count_title = QtGui.QLabel('Count') self.count_title.setStyleSheet('color: black') self.count_title.setAlignment(QtCore.Qt.AlignCenter) self.count_title.setMargin(5) self.freq_title = QtGui.QLabel('Frequency') self.freq_title.setStyleSheet('color: black') self.freq_title.setAlignment(QtCore.Qt.AlignCenter) self.freq_title.setMargin(5) self.print_title = QtGui.QLabel('Print') self.print_title.setStyleSheet('color: black') self.print_title.setAlignment(QtCore.Qt.AlignLeft) self.print_title.setMargin(5) self.grid_layout.addWidget(self.type_title, 0, 0) self.grid_layout.addWidget(self.count_title, 0, 1) self.grid_layout.addWidget(self.freq_title, 0, 2) self.grid_layout.addWidget(self.print_title, 0, 3) self.type_count = 0 self.type_labels = dict() self.count_labels = dict() self.disp_checks = dict() self.disp_freqs = dict() if self.serial in UwbNetwork.nodes.keys(): _cdp_types = np.sort(list(UwbNetwork.nodes[self.serial].cdp_pkts.keys())) for _type in _cdp_types: self.type_labels.update([(self.type_count, QtGui.QLabel(UwbNetwork.nodes[self.serial].cdp_pkts_name[_type]))]) self.count_labels.update([(self.type_count, QtGui.QLabel('{:5d}'.format(UwbNetwork.nodes[self.serial].cdp_pkts_count[_type])))]) self.disp_freqs.update([(self.type_count, QtGui.QLabel('{:0.3f} Hz'.format(UwbNetwork.nodes[self.serial].cdp_pkts_freq [_type])))]) self.disp_checks.update([(self.type_count, QtGui.QCheckBox())]) self.type_labels[self.type_count].setAlignment(QtCore.Qt.AlignRight) self.count_labels[self.type_count].setAlignment(QtCore.Qt.AlignCenter) self.disp_freqs[self.type_count].setAlignment(QtCore.Qt.AlignCenter) self.grid_layout.addWidget(self.type_labels[self.type_count], self.type_count+1, 0) self.grid_layout.addWidget(self.count_labels[self.type_count], self.type_count+1, 1) self.grid_layout.addWidget(self.disp_freqs[self.type_count], self.type_count+1, 2) self.grid_layout.addWidget(self.disp_checks[self.type_count], self.type_count+1, 3) if _type in map_type_to_plot.keys() or _type == AppSettingsChunk.type: self.type_labels[self.type_count].setStyleSheet('color: blue') self.type_labels[self.type_count].mouseReleaseEvent = partial(self.labelClickEvent, _type) if _type in map_type_to_display_window.keys(): self.type_labels[self.type_count].setStyleSheet('color: blue') self.type_labels[self.type_count].mouseReleaseEvent = partial(self.labelClickEvent, _type) self.count_labels[self.type_count].mouseReleaseEvent = partial(self.countClickEvent, self.type_count) self.count_labels[self.type_count].setStyleSheet('color: blue') self.type_count += 1 self.central.setLayout(self.grid_layout) self.setCentralWidget(self.central) self.timer = self.startTimer(QPLOT_FREQUENCY)