def __init__(self, session, parent=None): super(GlueController, self).__init__(parent=parent) self.layer_widget = LayerTreeWidget() self.layer_widget.set_checkable(False) self.layer_widget.setup(session.data_collection) self.setCentralWidget(self.layer_widget) self.tbar = EditSubsetModeToolBar() self.addToolBar(self.tbar) self.layer_widget.bind_selection_to_edit_subset()
def _setup_ui(self): self._ui = load_ui('application.ui', None, directory=os.path.dirname(__file__)) self.setCentralWidget(self._ui) self._ui.tabWidget.setTabBar(GlueTabBar()) lw = LayerTreeWidget(session=self._session) lw.set_checkable(False) self._vb = QtWidgets.QVBoxLayout() self._vb.setContentsMargins(0, 0, 0, 0) self._vb.addWidget(lw) self._ui.data_layers.setLayout(self._vb) self._layer_widget = lw # Data toolbar self._data_toolbar = QtWidgets.QToolBar("Session and Data toolbar") self._data_toolbar.setIconSize(QtCore.QSize(16, 16)) self._button_open_session = QtWidgets.QToolButton() self._button_open_session.setText("Open Session") self._button_open_session.setIcon(get_icon('glue_open')) self._button_open_session.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self._button_open_session.clicked.connect(self._restore_session) self._data_toolbar.addWidget(self._button_open_session) self._button_save_session = QtWidgets.QToolButton() self._button_save_session.setText("Export Session") self._button_save_session.setIcon(get_icon('glue_filesave')) self._button_save_session.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self._button_save_session.clicked.connect(self._choose_save_session) self._data_toolbar.addWidget(self._button_save_session) self._button_open_data = QtWidgets.QToolButton() self._button_open_data.setText("Import Data") self._button_open_data.setIcon(get_icon('glue_open')) self._button_open_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_open_data.clicked.connect( self._import_helper._choose_load_data_wizard) self._data_toolbar.addWidget(self._button_open_data) self._button_save_data = QtWidgets.QToolButton() self._button_save_data.setText("Export Data/Subsets") self._button_save_data.setIcon(get_icon('glue_filesave')) self._button_save_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_save_data.clicked.connect(self._choose_save_data) self._data_toolbar.addWidget(self._button_save_data) self._button_link_data = QtWidgets.QToolButton() self._button_link_data.setText("Link Data") self._button_link_data.setIcon(get_icon('glue_link')) self._button_link_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_link_data.clicked.connect(self._set_up_links) self._data_toolbar.addWidget(self._button_link_data) self._button_edit_components = QtWidgets.QToolButton() self._button_edit_components.setText("Arithmetic attributes") self._button_edit_components.setIcon(get_icon('arithmetic')) self._button_edit_components.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self._button_edit_components.clicked.connect(self._artihmetic_dialog) self._data_toolbar.addWidget(self._button_edit_components) self.addToolBar(self._data_toolbar) self._on_data_collection_change() # Selection mode toolbar tbar = EditSubsetModeToolBar(parent=self) self._mode_toolbar = tbar self.addToolBar(self._mode_toolbar) # Error console toolbar self._console_toolbar = QtWidgets.QToolBar('Advanced toolbar') self._console_toolbar.setIconSize(QtCore.QSize(14, 14)) spacer = QtWidgets.QWidget() spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self._console_toolbar.addWidget(spacer) self._button_ipython = QtWidgets.QToolButton() self._button_ipython.setCheckable(True) self._button_ipython.setText("Terminal") self._button_ipython.setIcon(get_icon('IPythonConsole')) self._button_ipython.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_ipython.clicked.connect(self._toggle_terminal) self._console_toolbar.addWidget(self._button_ipython) self._button_preferences = QtWidgets.QToolButton() self._button_preferences.setText("Preferences") self._button_preferences.setIcon(get_icon('glue_settings')) self._button_preferences.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self._button_preferences.clicked.connect(self._edit_settings) self._console_toolbar.addWidget(self._button_preferences) self._button_console = QtWidgets.QToolButton() self._button_console.setText("Error Console") self._button_console.setToolButtonStyle(Qt.ToolButtonTextOnly) self._console_toolbar.addWidget(self._button_console) self.addToolBar(self._console_toolbar) self._log = GlueLogger(button_console=self._button_console) self._log.window().setWindowTitle("Console Log") self._log.resize(550, 550) self._log.hide() self._hub.subscribe(self, DataCollectionMessage, handler=self._on_data_collection_change) self._hub.subscribe(self, SettingsChangeMessage, handler=self._on_ui_settings_change)
def _create_menu(self): mbar = self.menuBar() menu = QtWidgets.QMenu(mbar) menu.setTitle("&File") menu.addAction(self._actions['data_new']) if 'data_importers' in self._actions: submenu = menu.addMenu("I&mport data") for a in self._actions['data_importers']: submenu.addAction(a) # menu.addAction(self._actions['data_save']) # XXX add this menu.addAction(self._actions['session_reset']) menu.addAction(self._actions['session_restore']) menu.addAction(self._actions['session_save']) if 'session_export' in self._actions: submenu = menu.addMenu("E&xport") for a in self._actions['session_export']: submenu.addAction(a) menu.addSeparator() menu.addAction("Edit &Preferences", self._edit_settings) menu.addAction("&Quit", self.app.quit) mbar.addMenu(menu) menu = QtWidgets.QMenu(mbar) menu.setTitle("&Edit ") menu.addAction(self._actions['undo']) menu.addAction(self._actions['redo']) mbar.addMenu(menu) menu = QtWidgets.QMenu(mbar) menu.setTitle("&View ") a = QtWidgets.QAction("&Console Log", menu) a.triggered.connect(self._log._show) menu.addAction(a) mbar.addMenu(menu) menu = QtWidgets.QMenu(mbar) menu.setTitle("&Canvas") menu.addAction(self._actions['tab_new']) menu.addAction(self._actions['viewer_new']) menu.addSeparator() menu.addAction(self._actions['gather']) menu.addAction(self._actions['tab_rename']) mbar.addMenu(menu) menu = QtWidgets.QMenu(mbar) menu.setTitle("Data &Manager") menu.addActions(self._layer_widget.actions()) mbar.addMenu(menu) menu = QtWidgets.QMenu(mbar) menu.setTitle("&Toolbars") tbar = EditSubsetModeToolBar() self._mode_toolbar = tbar self.addToolBar(tbar) tbar.hide() a = QtWidgets.QAction("Selection Mode &Toolbar", menu) a.setCheckable(True) a.toggled.connect(tbar.setVisible) try: tbar.visibilityChanged.connect(a.setChecked) except AttributeError: # Qt < 4.7. QtCore.Signal not supported pass menu.addAction(a) menu.addActions(tbar.actions()) mbar.addMenu(menu) menu = QtWidgets.QMenu(mbar) menu.setTitle("&Plugins") menu.addAction(self._actions['plugin_manager']) menu.addSeparator() if 'plugins' in self._actions: for plugin in self._actions['plugins']: menu.addAction(plugin) mbar.addMenu(menu) # trigger inclusion of Mac Native "Help" tool menu = mbar.addMenu("&Help") a = QtWidgets.QAction("&Online Documentation", menu) a.triggered.connect(nonpartial(webbrowser.open, DOCS_URL)) menu.addAction(a) a = QtWidgets.QAction("Send &Feedback", menu) a.triggered.connect(nonpartial(submit_feedback)) menu.addAction(a) menu.addSeparator() menu.addAction("Version information", show_glue_info)
def _create_menu(self): mbar = self.menuBar() menu = QtGui.QMenu(mbar) menu.setTitle("&File") menu.addAction(self._actions['data_new']) if 'data_importers' in self._actions: submenu = menu.addMenu("I&mport data") for a in self._actions['data_importers']: submenu.addAction(a) # menu.addAction(self._actions['data_save']) # XXX add this menu.addAction(self._actions['session_reset']) menu.addAction(self._actions['session_restore']) menu.addAction(self._actions['session_save']) if 'session_export' in self._actions: submenu = menu.addMenu("E&xport") for a in self._actions['session_export']: submenu.addAction(a) menu.addSeparator() menu.addAction("Edit &Settings", self._edit_settings) menu.addAction("&Quit", QtGui.qApp.quit) mbar.addMenu(menu) menu = QtGui.QMenu(mbar) menu.setTitle("&Edit ") menu.addAction(self._actions['undo']) menu.addAction(self._actions['redo']) mbar.addMenu(menu) menu = QtGui.QMenu(mbar) menu.setTitle("&View ") a = QtGui.QAction("&Console Log", menu) a.triggered.connect(self._log._show) menu.addAction(a) mbar.addMenu(menu) menu = QtGui.QMenu(mbar) menu.setTitle("&Canvas") menu.addAction(self._actions['tab_new']) menu.addAction(self._actions['viewer_new']) menu.addSeparator() menu.addAction(self._actions['gather']) menu.addAction(self._actions['tab_rename']) mbar.addMenu(menu) menu = QtGui.QMenu(mbar) menu.setTitle("Data &Manager") menu.addActions(self._layer_widget.actions()) mbar.addMenu(menu) menu = QtGui.QMenu(mbar) menu.setTitle("&Toolbars") tbar = EditSubsetModeToolBar() self._mode_toolbar = tbar self.addToolBar(tbar) tbar.hide() a = QtGui.QAction("Selection Mode &Toolbar", menu) a.setCheckable(True) a.toggled.connect(tbar.setVisible) try: tbar.visibilityChanged.connect(a.setChecked) except AttributeError: # Qt < 4.7. QtCore.Signal not supported pass menu.addAction(a) menu.addActions(tbar.actions()) mbar.addMenu(menu) menu = QtGui.QMenu(mbar) menu.setTitle("&Plugins") menu.addAction(self._actions['plugin_manager']) menu.addSeparator() if 'plugins' in self._actions: for plugin in self._actions['plugins']: menu.addAction(plugin) mbar.addMenu(menu) # trigger inclusion of Mac Native "Help" tool menu = mbar.addMenu("&Help") a = QtGui.QAction("&Online Documentation", menu) a.triggered.connect(nonpartial(webbrowser.open, DOCS_URL)) menu.addAction(a) a = QtGui.QAction("Send &Feedback", menu) a.triggered.connect(nonpartial(submit_feedback)) menu.addAction(a) menu.addSeparator() menu.addAction("Version information", show_glue_info)
def _setup_ui(self): self._ui = load_ui('application.ui', None, directory=os.path.dirname(__file__)) self.setCentralWidget(self._ui) self._ui.tabWidget.setTabBar(GlueTabBar()) lw = LayerTreeWidget() lw.set_checkable(False) self._vb = QtWidgets.QVBoxLayout() self._vb.setContentsMargins(0, 0, 0, 0) self._vb.addWidget(lw) self._ui.data_layers.setLayout(self._vb) self._layer_widget = lw # Data toolbar self._data_toolbar = QtWidgets.QToolBar() self._data_toolbar.setIconSize(QtCore.QSize(16, 16)) self._button_open_data = QtWidgets.QToolButton() self._button_open_data.setText("Open Data") self._button_open_data.setIcon(get_icon('glue_open')) self._button_open_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_open_data.clicked.connect( nonpartial(self._choose_load_data)) self._data_toolbar.addWidget(self._button_open_data) self._button_link_data = QtWidgets.QToolButton() self._button_link_data.setText("Link Data") self._button_link_data.setIcon(get_icon('glue_link')) self._button_link_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_link_data.clicked.connect(self._set_up_links) self._data_toolbar.addWidget(self._button_link_data) self._button_ipython = QtWidgets.QToolButton() self._button_ipython.setCheckable(True) self._button_ipython.setText("IPython Terminal") self._button_ipython.setIcon(get_icon('IPythonConsole')) self._button_ipython.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_ipython.clicked.connect(self._toggle_terminal) self._data_toolbar.addWidget(self._button_ipython) self._button_open_data = QtWidgets.QToolButton() self._button_open_data.setText("Open Session") self._button_open_data.setIcon(get_icon('glue_open')) self._button_open_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_open_data.clicked.connect( nonpartial(self._restore_session)) self._data_toolbar.addWidget(self._button_open_data) self._button_open_data = QtWidgets.QToolButton() self._button_open_data.setText("Save Session") self._button_open_data.setIcon(get_icon('glue_filesave')) self._button_open_data.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self._button_open_data.clicked.connect( nonpartial(self._choose_save_session)) self._data_toolbar.addWidget(self._button_open_data) spacer = QtWidgets.QWidget() spacer.setMinimumSize(20, 10) spacer.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) self._data_toolbar.addWidget(spacer) self.addToolBar(self._data_toolbar) # Selection mode toolbar tbar = EditSubsetModeToolBar() self._mode_toolbar = tbar self.addToolBar(self._mode_toolbar) # Error console toolbar self._console_toolbar = QtWidgets.QToolBar() self._console_toolbar.setIconSize(QtCore.QSize(16, 16)) spacer = QtWidgets.QWidget() spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self._console_toolbar.addWidget(spacer) self._button_preferences = QtWidgets.QToolButton() self._button_preferences.setText("Preferences") self._button_preferences.setIcon(get_icon('glue_settings')) self._button_preferences.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) self._button_preferences.clicked.connect( nonpartial(self._edit_settings)) self._console_toolbar.addWidget(self._button_preferences) self._button_console = QtWidgets.QToolButton() self._button_console.setText("View Error Console") self._button_console.setToolButtonStyle(Qt.ToolButtonTextOnly) self._console_toolbar.addWidget(self._button_console) self.addToolBar(self._console_toolbar) self._log = GlueLogger(button_console=self._button_console) self._log.window().setWindowTitle("Console Log") self._log.resize(550, 550) self._log.hide()