def initUI(self): self.main = QtWidgets.QWidget() self._tabs = QtWidgets.QTabWidget() self._main = QtWidgets.QWidget() self._manu = QtWidgets.QWidget() self.setCentralWidget(self.main) self.gridlayout = QtWidgets.QGridLayout() self._tabs.addTab(self._main, "Main") self._tabs.addTab(self._manu, "Manual") self.initMaintab() self.initManualtab() self.gridlayout.addWidget(self._tabs, 0, 0, 10, 1) self.main.setLayout(self.gridlayout) self._tabs.gridlayout = QtWidgets.QGridLayout() self._tabs.setLayout(self._tabs.gridlayout) self.gridlayout.setSpacing(10) self.setWindowTitle(self.title) left = 100 top = 100 width = 1000 height = 800 self.setGeometry(left, top, width, height) self.statusBar().showMessage('Loading') # mainMenu = self.menuBar() fileMenu = mainMenu.addMenu('File') # openButton = QtWidgets.QAction(QIcon('open24.png'), 'Open', self) openButton.setShortcut('Ctrl+O') openButton.setStatusTip('Open directory') openButton.triggered.connect(self.getfolder) fileMenu.addAction(openButton) # exitButton = QtWidgets.QAction(QIcon('exit24.png'), 'Exit', self) exitButton.setShortcut('Ctrl+Q') exitButton.setStatusTip('Exit application') exitButton.triggered.connect(self.close) fileMenu.addAction(exitButton) # self.show()
def initializeGUI(self): #Tooltips QtWidgets.QToolTip.setFont(QtGui.QFont('SansSerif', 14)) self.setToolTip('IOC Measurement') #Toolbar self.addToolBar(NavigationToolbar(self.PyTrace_widget.PSensorPlot,self)) #Menu mnuExit=QtWidgets.QAction('&End Program',self) mnuExit.setStatusTip('Exit PyTrace') mnuExit.triggered.connect(self.close) menu=self.menuBar() mnufile=menu.addMenu('P&yTrace') mnufile.addAction(mnuExit) # Resize main window self.resize(1100,1000) # 1000, 850 #self.center() self.setWindowTitle('PyTrace@ESS') self.show()
def __init__(self): topologies = [TopologyPreprocLauncher, TopologyPIVLauncher] self.topologies = {cls.__name__: cls for cls in topologies} QtWidgets.QMainWindow.__init__(self) self.setupUi(self) topo_names = ["TopologyPreprocLauncher", "TopologyPIVLauncher"] self.actions = {} for topo_name in topo_names: action = self.actions[topo_name] = QtWidgets.QAction(self) self.menuTopologies.addAction(action) action.setText(topo_name) def func(_, topo_name=topo_name): self.init_topo(topo_name) action.triggered.connect(func) self.actionOpen.triggered.connect(self.open_file)
def create_action(self, text, slot=None, shortcut=None, icon=None, tip=None, checkable=False, signal="triggered()"): action = QtWidgets.QAction(text, self) if icon is not None: action.setIcon(QIcon(":/%s.png" % icon)) if shortcut is not None: action.setShortcut(shortcut) if tip is not None: action.setToolTip(tip) action.setStatusTip(tip) if slot is not None: action.triggered.connect(slot) if checkable: action.setCheckable(True) return action
def __init__(self): super(ApplicationWindow, self).__init__() # self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self._main = QtWidgets.QStackedWidget() self.file_name = "NO NAME" # self._main = QtWidgets.QWidget() self.setCentralWidget(self._main) # self.setWindowTitle("UHSLC QC Software") self.setWindowIcon(QtGui.QIcon('uhslclogotext72_pfL_icon.ico')) self.resize(1837, 1200) # Create Screen objects self.start_screen = Start(self) self.second_screen = HelpScreen(self) self._main.addWidget(self.start_screen) self._main.addWidget(self.second_screen) self._main.setCurrentWidget(self.start_screen) self.start_screen.clicked.connect( lambda: self._main.setCurrentWidget(self.second_screen)) self.second_screen.clicked.connect( lambda: self._main.setCurrentWidget(self.start_screen)) self.setStatusTip("Permanent status bar") # Create an action in the menu bar that is later on assigned to one of # the options (e.g. File, Edit, View etc) in the menu bar close_app = QtWidgets.QAction("&Exit", self) close_app.setShortcut("Ctrl+Q") # Show the tip in the status bar on hover close_app.setStatusTip('Leave the app') close_app.triggered.connect(self.close_application) open_help_menu = QtWidgets.QAction("&Instructions", self) open_help_menu.setShortcut("F1") open_help_menu.triggered.connect(self.start_screen.clicked.emit) # open_help_menu.triggered.connect(self.open_help_menu) open_file = QtWidgets.QAction("&Open monp", self) open_file.setShortcut("Ctrl+O") open_file.setStatusTip('Load a File') open_file.triggered.connect(self.file_open) reload_file = QtWidgets.QAction("&Reload", self) reload_file.setShortcut("Ctrl+R") reload_file.setStatusTip('Reload all file(s) that were loaded') reload_file.triggered.connect(self.get_loaded_files) opents_file = QtWidgets.QAction("&Open ts", self) opents_file.setShortcut("Ctrl+T") opents_file.setStatusTip('Opens ts folder') opents_file.triggered.connect(self.open_ts) self.statusBar() # Create dropwon menu main_menu = self.menuBar() # Add options to the menuBar file_menu = main_menu.addMenu('&File') help_menu = main_menu.addMenu('&Help') # Connect action with the option file_menu.addAction(open_file) file_menu.addAction(reload_file) file_menu.addAction(opents_file) file_menu.addAction(close_app) help_menu.addAction(open_help_menu)
def __init__(self): """Initialise the application - includes loading settings from disc, initialising a lakeator, and setting up the GUI.""" super().__init__() self._load_settings() self._main = QtWidgets.QWidget() self.setCentralWidget(self._main) layout = QtWidgets.QHBoxLayout(self._main) self.setWindowTitle('Locator') self.setWindowIcon(QtGui.QIcon("./kiwi.png")) self.loadAction = QtWidgets.QAction("&Load File", self) self.loadAction.setShortcut("Ctrl+L") self.loadAction.setStatusTip("Load a multichannel .wav file.") self.loadAction.triggered.connect(self.file_open) self.saveAction = QtWidgets.QAction("&Save Image", self) self.saveAction.setShortcut("Ctrl+S") self.saveAction.setStatusTip("Save the current display to a PNG file.") self.saveAction.triggered.connect(self.save_display) self.saveAction.setDisabled(True) self.saveGisAction = QtWidgets.QAction("&Save to GIS", self) self.saveGisAction.setShortcut("Ctrl+G") self.saveGisAction.setStatusTip( "Save the heatmap as a QGIS-readable georeferenced TIFF file.") self.saveGisAction.triggered.connect(self.exportGIS) self.saveGisAction.setDisabled(True) self.statusBar() mainMenu = self.menuBar() fileMenu = mainMenu.addMenu("&File") fileMenu.addAction(self.loadAction) fileMenu.addAction(self.saveAction) fileMenu.addAction(self.saveGisAction) setArrayDesign = QtWidgets.QAction("&Configure Array Design", self) setArrayDesign.setShortcut("Ctrl+A") setArrayDesign.setStatusTip( "Input relative microphone positions and array bearing.") setArrayDesign.triggered.connect(self.get_array_info) setGPSCoords = QtWidgets.QAction("&Set GPS Coordinates", self) setGPSCoords.setShortcut("Ctrl+C") setGPSCoords.setStatusTip( "Set the GPS coordinates for the array, and ESPG code for the CRS." ) setGPSCoords.triggered.connect(self.get_GPS_info) arrayMenu = mainMenu.addMenu("&Array") arrayMenu.addAction(setArrayDesign) arrayMenu.addAction(setGPSCoords) setDomain = QtWidgets.QAction("&Set Heatmap Domain", self) setDomain.setShortcut("Ctrl+D") setDomain.setStatusTip( "Configure distances left/right up/down at which to generate the heatmap." ) setDomain.triggered.connect(self.getBoundsInfo) self.refreshHeatmap = QtWidgets.QAction("&Calculate", self) self.refreshHeatmap.setShortcut("Ctrl+H") self.refreshHeatmap.setStatusTip("(Re)calculate heatmap.") self.refreshHeatmap.triggered.connect(self.generate_heatmap) self.refreshHeatmap.setDisabled(True) self.refreshView = QtWidgets.QAction("&Recalculate on View", self) self.refreshView.setShortcut("Ctrl+R") self.refreshView.setStatusTip( "Recalculate heatmap at current zoom level.") self.refreshView.triggered.connect(self.recalculateOnView) self.refreshView.setDisabled(True) heatmapMenu = mainMenu.addMenu("&Heatmap") heatmapMenu.addAction(setDomain) # Initialise canvas self.static_canvas = FigureCanvas(Figure(figsize=(5, 3))) layout.addWidget(self.static_canvas) # Add a navbar navbar = NavigationToolbar(self.static_canvas, self) self.addToolBar(QtCore.Qt.BottomToolBarArea, navbar) # Override the default mpl save functionality to change default filename navbar._actions['save_figure'].disconnect() navbar._actions['save_figure'].triggered.connect(self.save_display) navbar._actions['home'].triggered.connect(lambda: print("testing")) self.img = None # Dynamically generate menu full of all available colourmaps. Do not add the inverted ones. self.colMenu = heatmapMenu.addMenu("&Choose Colour Map") self.colMenu.setDisabled(True) colGroup = QtWidgets.QActionGroup(self) for colour in sorted(colormaps(), key=str.casefold): if colour[-2:] != "_r": cm = self.colMenu.addAction(colour) cm.setCheckable(True) if colour == self.settings["heatmap"]["cmap"][:-2]: cm.setChecked(True) receiver = lambda checked, cmap=colour: self.img.set_cmap(cmap) cm.triggered.connect(receiver) cm.triggered.connect(self._setcol) cm.triggered.connect(self.static_canvas.draw) colGroup.addAction(cm) self.invert = QtWidgets.QAction("&Invert Colour Map", self) self.invert.setShortcut("Ctrl+I") self.invert.setStatusTip("Invert the current colourmap.") self.invert.triggered.connect(self.invert_heatmap) self.invert.setCheckable(True) self.invert.setDisabled(True) heatmapMenu.addAction(self.invert) heatmapMenu.addSeparator() heatmapMenu.addAction(self.refreshHeatmap) heatmapMenu.addAction(self.refreshView) algoMenu = mainMenu.addMenu("Algorithm") self.algChoice = algoMenu.addMenu("&Change Algorithm") algGroup = QtWidgets.QActionGroup(self) for alg in sorted(["GCC", "MUSIC", "AF-MUSIC"], key=str.casefold): cm = self.algChoice.addAction(alg) cm.setCheckable(True) if alg == self.settings["algorithm"]["current"]: cm.setChecked(True) receiver = lambda checked, al=alg: self.setAlg(al) cm.triggered.connect(receiver) colGroup.addAction(cm) self.params = QtWidgets.QAction("&Algorithm Settings", self) self.params.setStatusTip("Alter algorithm-specific settings.") self.params.triggered.connect(self.getAlgoInfo) algoMenu.addAction(self.params) # Display a "ready" message self.statusBar().showMessage('Ready') # Boolean to keep track of whether we have GPS information for the array, and an image self._has_GPS = False self._has_heatmap = False # Keep track of the currently opened file self.open_filename = "" self.loc = lakeator.Lakeator(self.settings["array"]["mic_locations"])
def _init_toolbar(self): self.basedir = str(cbook._get_data_path('images')) background_color = self.palette().color(self.backgroundRole()) foreground_color = self.palette().color(self.foregroundRole()) icon_color = (foreground_color if background_color.value() < 128 else None) for text, tooltip_text, image_file, callback in self.toolitems: if callback not in [ 'zoom', 'pan', 'back', 'forward', 'home', 'configure_subplots' ]: if text is None: #self.addSeparator() pass else: a = self.addAction(QIcon('res\\save_icon.ico'), text, getattr(self, callback)) self._actions[callback] = a if tooltip_text is not None: a.setToolTip(tooltip_text) if text == 'Subplots': a = self.addAction( self._icon("qt4_editor_options.png", icon_color), 'Customize', self.edit_parameters) a.setToolTip('Edit axis, curve and image parameters') # Add the (x, y) location widget at the right side of the toolbar # The stretch factor is 1 which means any resizing of the toolbar # will resize this label instead of the buttons. self.measure_win_A = QtWidgets.QAction(QIcon("res\\m_icon.ico"), "Open Measurement Window", self) self.measure_win_A.triggered.connect(self.parent.Open_measure_window) self.addAction(self.measure_win_A) self.statusLabel = QtWidgets.QLabel("", self) self.statusLabel.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.statusLabel.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Ignored)) self.statusLabel.setStyleSheet("QLabel { color : red; }") self.statusLabelAction = self.addWidget(self.statusLabel) font1 = QtGui.QFont("Times", 12) self.statusLabelAction.setVisible(False) self.statusLabel.setFont(font1) if self.coordinates: self.locLabel = QtWidgets.QLabel("", self) self.locLabel.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.locLabel.setSizePolicy( QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Ignored)) self.coordinateLabel = self.addWidget(self.locLabel) newfont = QtGui.QFont("Times", 12) self.coordinateLabel.setVisible(True) self.locLabel.setFont(newfont)
def __init__(self): super().__init__() self.T = 60 self.invertible_model = InvertibleModel(self.T) self._main = QtWidgets.QFrame(self) self.vertical_layout = QtWidgets.QVBoxLayout(self._main) self._main.setLayout(self.vertical_layout) self.setCentralWidget(self._main) self.toolbar = self.addToolBar('Toolbar') combo = QtWidgets.QComboBox(self) combo.addItem('Simple Example') combo.addItem('Complex Example 1') combo.addItem('Complex Example 2') combo.setCurrentIndex(0) combo.activated.connect(self.combo_activated) self.toolbar.addWidget(combo) compute_encode_action = QtWidgets.QAction('encode f(x) -> y,z', self) compute_encode_action.triggered.connect(self.compute_encode) self.toolbar.addAction(compute_encode_action) compute_decode_action = QtWidgets.QAction('decode f_inv(y,z) -> x', self) compute_decode_action.triggered.connect(self.compute_decode) self.toolbar.addAction(compute_decode_action) denoise_action = QtWidgets.QAction('denoise [y, yz_pad, z]', self) denoise_action.triggered.connect(self.denoise) self.toolbar.addAction(denoise_action) # zero_yz_pad_action = QtWidgets.QAction('yz padding -> 0', self) # zero_yz_pad_action.triggered.connect(self.zero_yz_pad) # self.toolbar.addAction(zero_yz_pad_action) # confusing, leave out # label = 'yz padding -> N(0, {:>4.2g})'.format(self.invertible_model.model.zeros_noise_scale) # noise_yz_pad_action = QtWidgets.QAction(label, self) # noise_yz_pad_action.triggered.connect(self.noise_yz_pad) # self.toolbar.addAction(noise_yz_pad_action) gauss_z_action = QtWidgets.QAction('z -> N(0, 1)', self) gauss_z_action.triggered.connect(self.gauss_z) self.toolbar.addAction(gauss_z_action) self.ssim_label = QtWidgets.QLabel( 'structural similarity(x, x_hat) = {:4.2g}'.format(0.9999), self) spacer = QtWidgets.QWidget() spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.toolbar.addWidget(spacer) self.toolbar.addWidget(self.ssim_label) # self.threshold_slider = QtWidgets.QSlider(Qt.Horizontal, self) # self.threshold_slider.setMinimum(0) # self.threshold_slider.setMaximum(500) # self.threshold_slider.setValue(50) # self.threshold_slider.valueChanged.connect(self.changeThreshold) # self.toolbar.addWidget(self.threshold_slider) # threshold_label = 'set all values < {:4.2g} to 0'.format( # self.threshold_slider.value() / 100. # ) # self.threshold_action = QtWidgets.QAction(threshold_label, self) # self.threshold_action.triggered.connect(self.threshold) # self.toolbar.addAction(self.threshold_action) # hide_editors_action = QtWidgets.QAction('Hide Editors', self) # hide_editors_action.triggered.connect(self.hide_editors) # self.toolbar.addAction(hide_editors_action) self.upper = QtWidgets.QFrame(self._main) self.lower_single = SingleEditorWidget(self._main) self.lower_single.setFixedHeight(170) self.lower_double = DoubleEditorWidget(self._main) self.lower_double.setFixedHeight(210) self.vertical_layout.addWidget(self.upper) self.vertical_layout.addWidget(self.lower_single) self.vertical_layout.addWidget(self.lower_double) upper_layout = QtWidgets.QHBoxLayout(self.upper) ##################################################### # these calls need to stay in this order! otherwise # the event handlers registered in the figure # will be overwritten! # create a mpl figure self.figure = create_figure() # create the figurecanvas object self.canvas = FigureCanvas(self.figure) # plot into the figure # self.combo_activated(combo.currentIndex()) filename, start = filenames_and_starts[combo.currentIndex()] x, x_frames, x_velocity = get_xy_from_file( filename + '.flac', filename + '.mid', self.invertible_model.audio_options) print('x.shape', x.shape) print('x_frames.shape', x_frames.shape) print('x_velocity.shape', x_velocity.shape) self.x_true = np.array(x[start:start + self.T]) self.z_pred, self.yz_pad_pred, self.y_pred = self.invertible_model.encode( self.x_true) self.x_inv, self.x_inv_padding = self.invertible_model.decode( self.z_pred, self.yz_pad_pred, self.y_pred) ################################################################# # test only # self.x_true = np.random.uniform(0, 1, (self.T, 256)) # self.y_pred = np.random.uniform(0, 1, (self.T, 185)) # self.z_pred = np.random.uniform(0, 1, (self.T, 9)) # self.yz_pad_pred = np.random.uniform(0, 1, (self.T, 62)) # self.x_inv = np.random.uniform(0, 1, (self.T, 256)) ################################################################# print('self.x_true.shape', self.x_true.shape) print('self.y_pred.shape', self.y_pred.shape) print('self.yz_pad_pred.shape', self.yz_pad_pred.shape) print('self.z_pred.shape', self.z_pred.shape) print('self.x_inv.shape', self.x_inv.shape) print('self.x_inv_padding.shape', self.x_inv_padding.shape) self.all_plots = AllPlots(fig=self.figure, x_true=self.x_true.view(), y_pred=self.y_pred.view(), z_pred=self.z_pred.view(), yz_pad_pred=self.yz_pad_pred.view(), x_inv=self.x_inv.view()) upper_layout.addWidget(self.canvas) # connect the signals to slots self.all_plots.ipo_y_instrument.do_select.connect(self.select) self.all_plots.ipo_y_phase.do_select.connect(self.select_pv) self.all_plots.ipo_y_velocity.do_select.connect(self.select_pv) self.all_plots.ipo_z.do_select.connect(self.select) self.all_plots.ipo_yz_pad_pred.do_select.connect(self.select) ###################################################### self.selected_y = 8 self.selected_ipo = self.all_plots.ipo_y_instrument self.select(self.selected_ipo, self.selected_y) self.lower_single.show() self.lower_double.hide() self.upper.setFocus()