def __init__(self, data_file, parent=None): super(HDF5Browser, self).__init__(parent) self.data_file = data_file self.treeWidget = HDF5TreeWidget( data_file, parent=self, ) self.treeWidget.selectionModel().selectionChanged.connect( self.selection_changed) self.viewer = HDF5ItemViewer( parent=self, show_controls=True, ) self.refresh_tree_button = QtWidgets.QPushButton( ) #Create a refresh button self.refresh_tree_button.setText("Refresh Tree") #adding the refresh button self.treelayoutwidget = QtWidgets.QWidget( ) #construct a widget which can then contain the refresh button and the tree self.treelayoutwidget.setLayout(QtWidgets.QVBoxLayout()) self.treelayoutwidget.layout().addWidget(self.treeWidget) self.treelayoutwidget.layout().addWidget(self.refresh_tree_button) self.refresh_tree_button.clicked.connect( self.treeWidget.model.refresh_tree) splitter = QtWidgets.QSplitter() splitter.addWidget( self.treelayoutwidget ) #Add newly constructed widget (treeview and button) to the splitter splitter.addWidget(self.viewer) self.setLayout(QtWidgets.QHBoxLayout()) self.layout().addWidget(splitter)
def renderer_selected(self, index): """Change the figure widget to use the selected renderer.""" # The class of the renderer is stored as the combobox data RendererClass = self.renderer_combobox.itemData(index) try: self.renderer = RendererClass(self.data, self) except TypeError: # If the box is empty (e.g. it's just been cleared) use a blank widget self.renderer = QtWidgets.QWidget()
def __init__(self, instrument_dict, parent=None, dock_settings_path=None, scripts_path=None, working_directory=None): # """Args: instrument_dict(dict) : This is a dictionary containg the instruments objects where the key is the objects new name in the generated new Ipython console dock_settings_path(str): A path for loading a previous dock widget configuration script_path(str): The path of any scripts the user may want to run using the drop down menu at the top of the gui working_directory(str): A path to the requested working directory - handy if you always wish to save data to the same directorys """ super(GuiGenerator, self).__init__(parent) self._logger = LOGGER self.instr_dict = instrument_dict if working_directory == None: self.working_directory = os.path.join(os.getcwd()) else: self.working_directory = working_directory self.data_file = df.current(working_directory=working_directory) self.instr_dict['HDF5'] = self.data_file self.setDockNestingEnabled(1) uic.loadUi(os.path.join(os.path.dirname(__file__), 'guigenerator.ui'), self) self.allDocks = {} self.allWidgets = {} self.actions = dict(Views={}, Instruments={}) self.dockwidgetArea = pyqtgraph.dockarea.DockArea() self.dockWidgetArea = self.replace_widget(self.verticalLayout, self.centralWidget(), self.dockwidgetArea) self.dockWidgetAllInstruments.setWidget(self.dockwidgetArea) self.dockWidgetAllInstruments.setTitleBarWidget( QtWidgets.QWidget()) # This trick makes the title bar disappear # Iterate over all the opened instruments. If the instrument has a GUI (i.e. if they have the get_qt_ui function # defined inside them), then create a pyqtgraph.Dock for it and add its widget to the Dock. Also prints out any # instruments that do not have GUIs self._logger.info('Opening all GUIs') for instr in self.instr_dict: self._open_one_gui(instr) self.terminalWindow = None self.menuTerminal() self._addActionViewMenu('Terminal') self.script_menu = None if scripts_path is not None: self.scripts_path = scripts_path else: self.scripts_path = 'scripts' self.makeScriptMenu() self.NightMode = 1 # address of h5 file self.filename = df.current().filename # self._tabifyAll() self._setupSignals() if dock_settings_path is not None: self.dock_settings_path = dock_settings_path self.menuLoadSettings() else: self.dock_settings_path = None self.showMaximized()
def __init__( self, item=None, parent=None, figure_widget=None, show_controls=True, show_refresh=True, show_default_button=True, show_copy=True, renderer_combobox=None, refresh_button=None, copy_button=None, default_button=None, ): """Create a viewer widget for any dataset or datagroup object Arguments: item : HDF5 group or dataset (optional) The dataset (or group) to display parent : QWidget (optional) The Qt parent of the widget. show_controls : bool (optional) If True (default), show the refresh button and combobox. If False, just show the renderer. show_refresh : bool (optional) If show_controls is True, this sets whether the refresh button is visible. renderer_combobox : QComboBox (optional) If this is specified, use the supplied combobox instead of creating a new one. You probably want to specify show_controls=False. refresh_button : QPushButton (optional) If specified, use the supplied button instead of creating one. copy_button : QPushButton (optional) If specified, use the supplied button instead of creating one. default_button : QPushButton (optional) If specified, use the supplied button to select the default rendererinstead of creating one. """ super(HDF5ItemViewer, self).__init__(parent) if figure_widget is None: self.figure_widget = QtWidgets.QWidget() else: self.figure_widget = figure_widget if renderer_combobox is None: self.renderer_combobox = QtWidgets.QComboBox() else: self.renderer_combobox = renderer_combobox self.renderer_combobox.activated[int].connect(self.renderer_selected) if refresh_button is None: self.refresh_button = QtWidgets.QPushButton() self.refresh_button.setText("Refresh Figure") else: self.refresh_button = refresh_button self.refresh_button.clicked.connect(self.refresh) if default_button is None: self.default_button = QtWidgets.QPushButton() self.default_button.setText("Default Renderer") else: self.default_button = default_button self.default_button.clicked.connect(self.default_renderer) if copy_button is None: self.copy_button = QtWidgets.QPushButton() self.copy_button.setText("Copy Figure") else: self.copy_button = copy_button self.copy_button.clicked.connect(self.CopyActivated) self.clipboard = QtWidgets.QApplication.clipboard() self.setLayout(QtWidgets.QVBoxLayout()) self.layout().addWidget(self.figure_widget, stretch=1) self.layout().setContentsMargins(0, 0, 0, 0) self.renderers = list() if show_controls: # this part may be broken hb = QtWidgets.QHBoxLayout() hb.addWidget(self.renderer_combobox, stretch=1) if show_refresh: hb.addWidget(self.refresh_button, stretch=0) if show_copy: hb.addWidget(self.copy_button, stretch=0) if show_default_button: hb.addWidget(self.default_button, stretch=0) self.layout().addLayout(hb, stretch=0)
def __init__(self, instrument_dict, parent=None, dock_settings_path=None, scripts_path=None, working_directory=None): super(GuiGenerator, self).__init__(parent) self._logger = LOGGER self.instr_dict = instrument_dict if working_directory == None: self.working_directory = os.path.join(os.getcwd()) else: self.working_directory = working_directory self.data_file = df.current(working_directory=working_directory) self.instr_dict['HDF5'] = self.data_file self.setDockNestingEnabled(1) uic.loadUi(os.path.join(os.path.dirname(__file__), 'guigenerator.ui'), self) self.allDocks = {} self.allWidgets = {} self.actions = dict(Views={}, Instruments={}) self.dockwidgetArea = pyqtgraph.dockarea.DockArea() self.dockWidgetArea = self.replace_widget(self.verticalLayout, self.centralWidget(), self.dockwidgetArea) self.dockWidgetAllInstruments.setWidget(self.dockwidgetArea) self.dockWidgetAllInstruments.setTitleBarWidget( QtWidgets.QWidget()) # This trick makes the title bar disappear # Iterate over all the opened instruments. If the instrument has a GUI (i.e. if they have the get_qt_ui function # defined inside them), then create a pyqtgraph.Dock for it and add its widget to the Dock. Also prints out any # instruments that do not have GUIs self._logger.info('Opening all GUIs') for instr in self.instr_dict: self._open_one_gui(instr) self.terminalWindow = None self.menuTerminal() self._addActionViewMenu('Terminal') self.script_menu = None if scripts_path is not None: self.scripts_path = scripts_path else: self.scripts_path = 'scripts' self.makeScriptMenu() self.NightMode = 1 # address of h5 file self.filename = df.current().filename # self._tabifyAll() self._setupSignals() if dock_settings_path is not None: self.dock_settings_path = dock_settings_path self.menuLoadSettings() else: self.dock_settings_path = None self.showMaximized()