def main(): home_dir = QtCore.QStandardPaths.writableLocation( QtCore.QStandardPaths.HomeLocation) os.chdir(home_dir) QtCore.QCoreApplication.setOrganizationName("David Andrs") QtCore.QCoreApplication.setOrganizationDomain("name.andrs") QtCore.QCoreApplication.setApplicationName(consts.APP_NAME) QtCore.QCoreApplication.setAttribute( QtCore.Qt.AA_EnableHighDpiScaling, True) QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) qapp = QtWidgets.QApplication(sys.argv) qapp.setQuitOnLastWindowClosed(False) qapp.setWindowIcon(Assets().icons['app']) otter_dir = os.path.dirname(os.path.realpath(__file__)) window = MainWindow() signal.signal(signal.SIGINT, handle_sigint) window.setPluginsDir(os.path.join(otter_dir, "plugins")) window.loadPlugins() window.show() # Repeatedly run python-noop to give the interpreter time to # handle signals safe_timer(50, lambda: None) qapp.exec() del window del qapp
def setupWidgets(self): self._frame = QtWidgets.QFrame(self) self._vtk_widget = QVTKRenderWindowInteractor(self._frame) self._vtk_renderer = vtk.vtkRenderer() self._vtk_widget.GetRenderWindow().AddRenderer(self._vtk_renderer) self._layout = QtWidgets.QVBoxLayout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.addWidget(self._vtk_widget) self._frame.setLayout(self._layout) self._view_menu = QtWidgets.QMenu() self._shaded_action = self._view_menu.addAction("Shaded") self._shaded_action.setCheckable(True) self._shaded_with_edges_action = self._view_menu.addAction( "Shaded with edges") self._shaded_with_edges_action.setCheckable(True) self._hidden_edges_removed_action = self._view_menu.addAction( "Hidden edges removed") self._hidden_edges_removed_action.setCheckable(True) if self._render_mode == self.SHADED: self._shaded_action.setChecked(True) elif self._render_mode == self.SILHOUETTE: self._hidden_edges_removed_action.setChecked(True) else: self._shaded_with_edges_action.setChecked(True) self._visual_repr = QtWidgets.QActionGroup(self._view_menu) self._visual_repr.addAction(self._shaded_action) self._visual_repr.addAction(self._shaded_with_edges_action) self._visual_repr.addAction(self._hidden_edges_removed_action) self._visual_repr.setExclusive(True) self._view_menu.addSeparator() self._perspective_action = self._view_menu.addAction("Perspective") self._perspective_action.setCheckable(True) perspective = self.plugin.settings.value("window/perspective", True) self._perspective_action.setChecked(perspective) self.onPerspectiveToggled(perspective) self._shaded_action.triggered.connect(self.onShadedTriggered) self._shaded_with_edges_action.triggered.connect( self.onShadedWithEdgesTriggered) self._hidden_edges_removed_action.triggered.connect( self.onHiddenEdgesRemovedTriggered) self._perspective_action.toggled.connect(self.onPerspectiveToggled) self._view_mode = QtWidgets.QPushButton(self._frame) self._view_mode.setFixedSize(60, 32) self._view_mode.setIcon(Assets().icons['render-mode']) self._view_mode.setMenu(self._view_menu) self._view_mode.setGeometry(10, 10, 80, 25) self._view_mode.show()
def setupViewModeWidget(self, frame): self._view_menu = QtWidgets.QMenu() self._shaded_action = self._view_menu.addAction("Shaded") self._shaded_action.setCheckable(True) self._shaded_action.setShortcut("Ctrl+1") self._shaded_w_edges_action = self._view_menu.addAction( "Shaded with edges") self._shaded_w_edges_action.setCheckable(True) self._shaded_w_edges_action.setShortcut("Ctrl+2") self._hidden_edges_removed_action = self._view_menu.addAction( "Hidden edges removed") self._hidden_edges_removed_action.setCheckable(True) self._hidden_edges_removed_action.setShortcut("Ctrl+3") self._transluent_action = self._view_menu.addAction("Transluent") self._transluent_action.setCheckable(True) self._transluent_action.setShortcut("Ctrl+4") self._shaded_w_edges_action.setChecked(True) self._render_mode = self.SHADED_WITH_EDGES self._visual_repr = QtWidgets.QActionGroup(self._view_menu) self._visual_repr.addAction(self._shaded_action) self._visual_repr.addAction(self._shaded_w_edges_action) self._visual_repr.addAction(self._hidden_edges_removed_action) self._visual_repr.addAction(self._transluent_action) self._visual_repr.setExclusive(True) self._view_menu.addSeparator() self._perspective_action = self._view_menu.addAction("Perspective") self._perspective_action.setCheckable(True) self._perspective_action.setChecked(True) self._view_menu.addSeparator() self._ori_marker_action = self._view_menu.addAction( "Orientation marker") self._ori_marker_action.setCheckable(True) self._ori_marker_action.setChecked(True) self._shaded_action.triggered.connect(self.onShadedTriggered) self._shaded_w_edges_action.triggered.connect( self.onShadedWithEdgesTriggered) self._hidden_edges_removed_action.triggered.connect( self.onHiddenEdgesRemovedTriggered) self._transluent_action.triggered.connect(self.onTransluentTriggered) self._perspective_action.toggled.connect(self.onPerspectiveToggled) self._ori_marker_action.toggled.connect( self.onOrientationmarkerVisibilityChanged) self._view_mode = QtWidgets.QPushButton(frame) self._view_mode.setFixedSize(60, 32) self._view_mode.setIcon(Assets().icons['render-mode']) self._view_mode.setMenu(self._view_menu) self._view_mode.show()
def main(): QtCore.QCoreApplication.setAttribute( QtCore.Qt.AA_EnableHighDpiScaling, True) QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) signal.signal(signal.SIGINT, handle_sigint) app = QtWidgets.QApplication(sys.argv) app.setQuitOnLastWindowClosed(True) app.setWindowIcon(Assets().icons['app']) plugin = CSVPlotterPlugin(None) plugin.create() # Repeatedly run python-noop to give the interpreter time to # handle signals safe_timer(50, lambda: None) app.exec() del app
def test_singleton(): assert Assets() is Assets() for key in Assets().icons: assert Assets().icons[key] is Assets().icons[key]
def test(): for key in Assets().icons: assert isinstance(Assets().icons[key], QtGui.QIcon)
def icon(): return Assets().icons['graph']
def icon(): return Assets().icons['movie']