def createMenus(self): self.mainMenu = QtWidgets.QMenu('TransformMenu') self.mainMenu.setObjectName('TransformMenu') self.mainMenu.setTearOffEnabled(True) self.mainMenu.addAction((QtWidgets.QAction('test0', self))) self.mainMenu.setStyleSheet( "QMenu::tearoff {height: 8px;} QMenu::tearoff:selected{ background-color: dimgray}" ) for action in self.Menuactions: self.mainMenu.addAction(self.Menuactions[action]) self.mainMenu.setLayoutDirection(Qt.LeftToRight) self.mainButton.setMenu(self.mainMenu) self.refMenu = QtWidgets.QMenu('RefMenu') self.refMenu.addAction((QtWidgets.QAction('Use Current Reference', self))) self.refMenu.addAction((QtWidgets.QAction('Pick New Reference', self))) self.refMenu.addSeparator() self.refMenu.addAction((QtWidgets.QAction('Pick Object Reference', self))) self.refMenu.addAction((QtWidgets.QAction('Pick Point Reference', self))) self.refMenu.addAction((QtWidgets.QAction('Pick Edge Reference', self))) self.refMenu.addAction((QtWidgets.QAction('Pick Face Reference', self))) self.refMenu.addSeparator() ag = QtWidgets.QActionGroup(self, exclusive=True) a = ag.addAction((QtWidgets.QAction('View', self, checkable=True))) self.refMenu.addAction(a) a = ag.addAction((QtWidgets.QAction('XY', self, checkable=True))) self.refMenu.addAction(a) a = ag.addAction((QtWidgets.QAction('XZ', self, checkable=True))) self.refMenu.addAction(a) a = ag.addAction((QtWidgets.QAction('YZ', self, checkable=True))) self.refMenu.addAction(a) self.refMenu.addSeparator() self.refMenu.addAction((QtWidgets.QAction('Reference Properties..', self))) self.symMenu = QtWidgets.QMenu('SymMenu') ag = QtWidgets.QActionGroup(self, exclusive=True) a = ag.addAction((QtWidgets.QAction('YZ', self, checkable=True))) self.symMenu.addAction(a) a = ag.addAction((QtWidgets.QAction('XZ', self, checkable=True))) self.symMenu.addAction(a) a = ag.addAction((QtWidgets.QAction('XY', self, checkable=True))) self.symMenu.addAction(a) self.symMenu.addSeparator() self.symMenu.addAction((QtWidgets.QAction('Symmetry Properties..', self)))
def _build_menu(self, default_names): """Create optional predefined subset names Args: default_names(list): all predefined names Returns: None """ # Get and destroy the action group group = self.btn_subset.findChild(QtWidgets.QActionGroup) if group: group.deleteLater() state = any(default_names) self.btn_subset.setEnabled(state) if state is False: return # Build new action group group = QtWidgets.QActionGroup(self.btn_subset) for name in default_names: if name == self.Separator: self.menu_subset.addSeparator() continue action = group.addAction(name) self.menu_subset.addAction(action) group.triggered.connect(self._on_action_clicked)
def __init__(self, exclusive=True, cascader=False, title="", parent=None): super(MMenu, self).__init__(title=title, parent=parent) self.setProperty("cascader", cascader) self.setCursor(QtCore.Qt.PointingHandCursor) self._action_group = QtWidgets.QActionGroup(self) self._action_group.setExclusive(exclusive) self._action_group.triggered.connect(self.slot_on_action_triggered) self._load_data_func = None self.set_value("") self.set_data([]) self.set_separator("/")
def __init__(self, args=None): super().__init__() MainWindow._self = self self.fileName = None self.simServer = args.server if args: settings.setDebug(args.debug) if args.file: # TODO absolute paths self.fileName = args.file self.setObjectName("ts2_main_window") self.editorWindow = None self.setGeometry(100, 100, 800, 600) self.setWindowTitle( self.tr("ts2 - Train Signalling Simulation - %s") % __VERSION__) # Simulation self.simulation = None self.webSocket = None self.serverPID = None if settings.debug: websocket.enableTrace(True) # Actions ====================================== self.openAction = QtWidgets.QAction(self.tr("&Open..."), self) self.openAction.setShortcut(QtGui.QKeySequence.Open) self.openAction.setToolTip( self.tr("Open a simulation or a " "previously saved game")) self.openAction.triggered.connect(self.onOpenSimulation) self.closeAction = QtWidgets.QAction(self.tr("&Close")) self.closeAction.setShortcut(QtGui.QKeySequence.Close) self.closeAction.setToolTip(self.tr("Close the current simulation")) self.closeAction.triggered.connect(self.simulationClose) self.openRecentAction = QtWidgets.QAction(self.tr("Recent"), self) menu = QtWidgets.QMenu() self.openRecentAction.setMenu(menu) menu.triggered.connect(self.onRecent) self.saveGameAsAction = QtWidgets.QAction(self.tr("&Save game"), self) self.saveGameAsAction.setShortcut(QtGui.QKeySequence.SaveAs) self.saveGameAsAction.setToolTip(self.tr("Save the current game")) self.saveGameAsAction.triggered.connect(self.saveGame) self.saveGameAsAction.setEnabled(False) # Properties self.propertiesAction = QtWidgets.QAction( self.tr("Sim &Properties..."), self) self.propertiesAction.setShortcut(QtGui.QKeySequence( self.tr("Ctrl+P"))) self.propertiesAction.setToolTip(self.tr("Edit simulation properties")) self.propertiesAction.triggered.connect(self.openPropertiesDialog) self.propertiesAction.setEnabled(False) # Settings self.settingsAction = QtWidgets.QAction(self.tr("Settings..."), self) self.settingsAction.setToolTip(self.tr("User Settings")) self.settingsAction.triggered.connect(self.openSettingsDialog) self.quitAction = QtWidgets.QAction(self.tr("&Quit"), self) self.quitAction.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+Q"))) self.quitAction.setToolTip(self.tr("Quit TS2")) self.quitAction.triggered.connect(self.close) self.editorAction = QtWidgets.QAction(self.tr("&Open Editor"), self) self.editorAction.setShortcut(QtGui.QKeySequence(self.tr("Ctrl+E"))) self.editorAction.setToolTip(self.tr("Open the simulation editor")) self.editorAction.triggered.connect(self.openEditor) self.editorCurrAction = QtWidgets.QAction(self.tr("&Edit"), self) self.editorCurrAction.setToolTip(self.tr("Open this sim in editor")) self.editorCurrAction.triggered.connect(self.onEditorCurrent) # Web Links self.actionGroupWwww = QtWidgets.QActionGroup(self) self.actionGroupWwww.triggered.connect(self.onWwwAction) self.aboutWwwHompage = QtWidgets.QAction(self.tr("&TS2 Homepage"), self) self.aboutWwwHompage.setProperty("url", __PROJECT_WWW__) self.actionGroupWwww.addAction(self.aboutWwwHompage) self.aboutWwwProject = QtWidgets.QAction(self.tr("&TS2 Project"), self) self.aboutWwwProject.setProperty("url", __PROJECT_HOME__) self.actionGroupWwww.addAction(self.aboutWwwProject) self.aboutWwwBugs = QtWidgets.QAction(self.tr("&TS2 Bugs && Feedback"), self) self.aboutWwwBugs.setProperty("url", __PROJECT_BUGS__) self.actionGroupWwww.addAction(self.aboutWwwBugs) # About self.aboutAction = QtWidgets.QAction(self.tr("&About TS2..."), self) self.aboutAction.setToolTip(self.tr("About TS2")) self.aboutAction.triggered.connect(self.showAboutBox) self.aboutQtAction = QtWidgets.QAction(self.tr("About Qt..."), self) self.aboutQtAction.setToolTip(self.tr("About Qt")) self.aboutQtAction.triggered.connect(QtWidgets.QApplication.aboutQt) # =============================================== # Menus # FileMenu self.fileMenu = self.menuBar().addMenu(self.tr("&File")) self.fileMenu.addAction(self.openAction) self.fileMenu.addAction(self.openRecentAction) self.fileMenu.addAction(self.saveGameAsAction) self.fileMenu.addAction(self.closeAction) self.fileMenu.addSeparator() self.fileMenu.addAction(self.propertiesAction) self.fileMenu.addAction(self.settingsAction) self.fileMenu.addSeparator() self.fileMenu.addAction(self.quitAction) # Editor Menu self.editorMenu = self.menuBar().addMenu(self.tr("&Editor")) self.editorMenu.addAction(self.editorAction) self.editorMenu.addAction(self.editorCurrAction) # Help Menu self.helpMenu = self.menuBar().addMenu(self.tr("&Help")) self.helpMenu.addAction(self.aboutWwwHompage) self.helpMenu.addAction(self.aboutWwwProject) self.helpMenu.addAction(self.aboutWwwBugs) self.helpMenu.addSeparator() self.helpMenu.addAction(self.aboutAction) self.helpMenu.addAction(self.aboutQtAction) self.menuBar().setCursor(Qt.PointingHandCursor) # ============================================================== # ToolBars # ========= # Actions tbar, tbg = self._make_toolbar_group(self.tr("Simulation"), bg="#dddddd") self.addToolBar(tbar) tbg.addAction(self.openAction) tbg.addAction(self.editorCurrAction) # ========= # Speed tbar, tbg = self._make_toolbar_group(self.tr("Speed"), bg="#aaaaaa") self.addToolBar(tbar) # Time factor spinBox self.timeFactorSpinBox = QtWidgets.QSpinBox(self) self.timeFactorSpinBox.setRange(1, 10) self.timeFactorSpinBox.setSingleStep(1) self.timeFactorSpinBox.setValue(1) self.timeFactorSpinBox.setSuffix("x") tbg.addWidget(self.timeFactorSpinBox) # ========= # Zoom tbar, tbg = self._make_toolbar_group(self.tr("Zoom"), bg="white") self.addToolBar(tbar) tbg.setMaximumWidth(300) self.zoomWidget = widgets.ZoomWidget(self) self.zoomWidget.valueChanged.connect(self.zoom) tbg.addWidget(self.zoomWidget) # ========= # Score tbar, tbg = self._make_toolbar_group(self.tr("Penalty"), bg="#dddddd") self.addToolBar(tbar) # Score display self.scoreDisplay = QtWidgets.QLCDNumber(self) self.scoreDisplay.setFrameShape(QtWidgets.QFrame.NoFrame) self.scoreDisplay.setFrameShadow(QtWidgets.QFrame.Plain) self.scoreDisplay.setSegmentStyle(QtWidgets.QLCDNumber.Flat) self.scoreDisplay.setNumDigits(5) self.scoreDisplay.setMinimumHeight(30) tbg.addWidget(self.scoreDisplay) # ========= # Clock tbar, tbg = self._make_toolbar_group(self.tr("Clock"), fg="Yellow", bg="#444444") self.addToolBar(tbar) # Pause button self.buttPause = QtWidgets.QToolButton(self) self.buttPause.setText(self.tr("Pause")) self.buttPause.setCheckable(True) self.buttPause.setAutoRaise(True) self.buttPause.setMaximumWidth(50) self.buttPause.setChecked(True) tbg.addWidget(self.buttPause) # Clock Widget self.clockWidget = widgets.ClockWidget(self) tbg.addWidget(self.clockWidget) # ==================== # Sim Title tbar = QtWidgets.QToolBar() tbar.setObjectName("toolbar_label_title") tbar.setFloatable(False) tbar.setMovable(False) self.addToolBar(tbar) self.lblTitle = QtWidgets.QLabel() lbl_sty = "background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0," \ " stop: 0 #fefefe, stop: 1 #CECECE);" lbl_sty += " color: #333333; font-size: 16pt; padding: 1px;" self.lblTitle.setStyleSheet(lbl_sty) self.lblTitle.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.lblTitle.setText("no sim loaded") tbar.addWidget(self.lblTitle) tbar.layout().setSizeConstraint(QtWidgets.QLayout.SetMaximumSize) # =============================================================== # Dock Widgets # Train Info self.trainInfoPanel = QtWidgets.QDockWidget( self.tr("Train Information"), self) self.trainInfoPanel.setObjectName("train_information") self.trainInfoPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.trainInfoView = QtWidgets.QTreeView(self) self.trainInfoView.setItemsExpandable(False) self.trainInfoView.setRootIsDecorated(False) self.trainInfoView.setContextMenuPolicy(Qt.CustomContextMenu) self.trainInfoView.customContextMenuRequested.connect( self.showContextMenu) self.trainInfoPanel.setWidget(self.trainInfoView) self.addDockWidget(Qt.RightDockWidgetArea, self.trainInfoPanel) # Service Info self.serviceInfoPanel = QtWidgets.QDockWidget( self.tr("Service Information"), self) self.serviceInfoPanel.setObjectName("service_information") self.serviceInfoPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) sty = "background-color: #444444; color: white; padding: 2px;" \ " font-size: 10pt" wid = QtWidgets.QScrollArea() self.serviceInfoPanel.setWidget(wid) grid = QtWidgets.QGridLayout() wid.setLayout(grid) self.lblServiceInfoCode = QtWidgets.QLabel() self.lblServiceInfoCode.setStyleSheet(sty) self.lblServiceInfoCode.setText("") self.lblServiceInfoCode.setMaximumWidth(100) grid.addWidget(self.lblServiceInfoCode, 0, 0) self.lblServiceInfoDescription = QtWidgets.QLabel() self.lblServiceInfoDescription.setText("") self.lblServiceInfoDescription.setStyleSheet(sty) self.lblServiceInfoDescription.setScaledContents(False) grid.addWidget(self.lblServiceInfoDescription, 0, 1) self.serviceInfoView = QtWidgets.QTreeView(self) self.serviceInfoView.setItemsExpandable(False) self.serviceInfoView.setRootIsDecorated(False) grid.addWidget(self.serviceInfoView, 1, 0, 1, 2) self.serviceInfoPanel.setWidget(wid) grid.setColumnStretch(0, 1) grid.setColumnStretch(1, 4) grid.setSpacing(0) grid.setContentsMargins(0, 0, 0, 0) self.addDockWidget(Qt.RightDockWidgetArea, self.serviceInfoPanel) # Stations + Places Info self.placeInfoPanel = QtWidgets.QDockWidget( self.tr("Station Information"), self) self.placeInfoPanel.setObjectName("place_information") self.placeInfoPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) wid = QtWidgets.QScrollArea() self.placeInfoPanel.setWidget(wid) hb = QtWidgets.QVBoxLayout() wid.setLayout(hb) self.lblPlaceInfoName = QtWidgets.QLabel() self.lblPlaceInfoName.setStyleSheet(sty) self.lblPlaceInfoName.setText("") hb.addWidget(self.lblPlaceInfoName) self.placeInfoView = QtWidgets.QTreeView(self) self.placeInfoView.setItemsExpandable(False) self.placeInfoView.setRootIsDecorated(False) self.placeInfoView.setModel(placeitem.Place.selectedPlaceModel) hb.addWidget(self.placeInfoView) hb.setSpacing(0) hb.setContentsMargins(0, 0, 0, 0) self.placeInfoPanel.setWidget(wid) self.addDockWidget(Qt.RightDockWidgetArea, self.placeInfoPanel) # Trains self.trainListPanel = QtWidgets.QDockWidget(self.tr("Trains"), self) self.trainListPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.trainListPanel.setObjectName("trains_panel") self.trainListView = trainlistview.TrainListView(self) self.simulationLoaded.connect(self.trainListView.setupTrainList) self.trainListPanel.setWidget(self.trainListView) self.addDockWidget(Qt.BottomDockWidgetArea, self.trainListPanel) # Services self.serviceListPanel = QtWidgets.QDockWidget(self.tr("Services"), self) self.serviceListPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.serviceListPanel.setObjectName("services_panel") self.serviceListView = servicelistview.ServiceListView(self) self.simulationLoaded.connect(self.serviceListView.setupServiceList) self.serviceListPanel.setWidget(self.serviceListView) self.addDockWidget(Qt.BottomDockWidgetArea, self.serviceListPanel) self.tabifyDockWidget(self.serviceListPanel, self.trainListPanel) # Message Logger self.loggerPanel = QtWidgets.QDockWidget(self.tr("Messages"), self) self.loggerPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.loggerPanel.setObjectName("logger_panel") self.loggerView = QtWidgets.QTreeView(self) self.loggerView.setItemsExpandable(False) self.loggerView.setRootIsDecorated(False) self.loggerView.setHeaderHidden(True) self.loggerView.setPalette(QtGui.QPalette(Qt.black)) self.loggerView.setVerticalScrollMode( QtWidgets.QAbstractItemView.ScrollPerItem) self.loggerPanel.setWidget(self.loggerView) self.addDockWidget(Qt.BottomDockWidgetArea, self.loggerPanel) # =========================================== # Main Board self.board = QtWidgets.QWidget(self) # Canvas self.view = widgets.XGraphicsView(self.board) self.view.setInteractive(True) self.view.setRenderHint(QtGui.QPainter.Antialiasing, False) self.view.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag) self.view.setPalette(QtGui.QPalette(Qt.black)) self.view.wheelChanged.connect(self.onWheelChanged) # Display self.grid = QtWidgets.QVBoxLayout() self.grid.setContentsMargins(0, 0, 0, 0) self.grid.addWidget(self.view) self.grid.setSpacing(0) self.board.setLayout(self.grid) self.setCentralWidget(self.board) # Editor self.editorOpened = False self.setControlsDisabled(True) self.refreshRecent() settings.restoreWindow(self) if args and args.file: if args.edit: self.openEditor(args.file) # else: # here we call after window is shown QtCore.QTimer.singleShot(100, self.onAfterShow)
def __initialize(self): ## force reload b = blockManager.BlockManager() b.reload() self.setObjectName(const.ObjectName) centeral = QtWidgets.QWidget() main_layout = QtWidgets.QVBoxLayout() self.setCentralWidget(centeral) centeral.setLayout(main_layout) # tabs self.__info_tabs = QtWidgets.QTabWidget() self.__editor_tabs = QtWidgets.QTabWidget() self.__editor_tabs.setMinimumHeight(200) self.__graph_tabs = QtWidgets.QTabWidget() self.__graph_tabs.setTabsClosable(True) # scene graph ## TODO : USE __new() self.__graph = graph.Graph(name=const.RootBoxName, parent=self) self.__graph_tabs.addTab(self.__graph, "Scene") btn = self.__graph_tabs.tabBar().tabButton(0, QtWidgets.QTabBar.RightSide) if not btn: btn = self.__graph_tabs.tabBar().tabButton(0, QtWidgets.QTabBar.LeftSide) if btn: btn.hide() self.__networks[self.__graph.box()] = {"graph": self.__graph} # editor tabs self.__parm_editor = paramEditor.ParamEditor() self.__parm_editor.NodeRefreshRequest.connect(self.__nodeRefresh) self.__editor_tabs.addTab(self.__parm_editor, "Param Editor") ## info tabs self.__packet_history = packetHistory.PacketHistory() self.__log_viewer = logViewer.LogViewer() self.__info_tabs.addTab(self.__packet_history, "Packet History") self.__info_tabs.addTab(self.__log_viewer, "Log") right_splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical) main_splitter = QtWidgets.QSplitter() main_splitter.addWidget(self.__graph_tabs) main_splitter.addWidget(right_splitter) right_splitter.addWidget(self.__editor_tabs) right_splitter.addWidget(self.__info_tabs) # scene state self.__scene_state = sceneState.SceneState() main_layout.addWidget(main_splitter) main_layout.addWidget(self.__scene_state) self.__resetTabIndice() # menu menubar = self.menuBar() ## file file_menu = QtWidgets.QMenu("&File", self) news_action = file_menu.addAction("&New Scene") news_action.setShortcut(QtGui.QKeySequence("Ctrl+N")) open_action = file_menu.addAction("&Open") open_action.setShortcut(QtGui.QKeySequence("Ctrl+O")) save_action = file_menu.addAction("Save") save_action.setShortcut(QtGui.QKeySequence("Ctrl+S")) save_as_action = file_menu.addAction("Save As") save_as_action.setShortcut(QtGui.QKeySequence("Ctrl+Shift+S")) import_action = file_menu.addAction("&Import") import_action.setShortcut(QtGui.QKeySequence("Ctrl+I")) file_menu.addAction(news_action) file_menu.addSeparator() file_menu.addAction(open_action) file_menu.addSeparator() file_menu.addAction(save_action) file_menu.addAction(save_as_action) file_menu.addSeparator() file_menu.addAction(import_action) news_action.triggered.connect(self.__new) save_action.triggered.connect(self.__save) save_as_action.triggered.connect(self.__saveAs) open_action.triggered.connect(self.__open) import_action.triggered.connect(self.__import) menubar.addMenu(file_menu) ## Edit edit_menu = QtWidgets.QMenu("&Edit", self) copy_action = edit_menu.addAction("&Copy") copy_action.setShortcut(QtGui.QKeySequence("Ctrl+C")) cut_action = edit_menu.addAction("C&ut") cut_action.setShortcut(QtGui.QKeySequence("Ctrl+X")) paste_action = edit_menu.addAction("&Paste") paste_action.setShortcut(QtGui.QKeySequence("Ctrl+V")) edit_menu.addAction(copy_action) edit_menu.addAction(cut_action) edit_menu.addSeparator() edit_menu.addAction(paste_action) menubar.addMenu(edit_menu) copy_action.triggered.connect(self.__copy) cut_action.triggered.connect(self.__cut) paste_action.triggered.connect(self.__paste) ## Blocks process_menu = QtWidgets.QMenu("&Blocks", self) run_action = process_menu.addAction("&Execute") run_action.setShortcut(QtGui.QKeySequence("F5")) run_action.triggered.connect(self.__runTriggered) menubar.addMenu(process_menu) ## settings setting_menu = QtWidgets.QMenu("Settings", self) log_menu = setting_menu.addMenu("Log") log_group = QtWidgets.QActionGroup(self) log_group.setExclusive(True) no_log = log_menu.addAction("No Log") error_log = log_menu.addAction("Error") warn_log = log_menu.addAction("Warning") debug_log = log_menu.addAction("Debug") no_log.setCheckable(True) error_log.setCheckable(True) warn_log.setCheckable(True) debug_log.setCheckable(True) log_group.addAction(no_log) log_group.addAction(error_log) log_group.addAction(warn_log) log_group.addAction(debug_log) warn_log.setChecked(True) no_log.triggered.connect(self.__noLogTriggered) error_log.triggered.connect(self.__errorLogTriggered) warn_log.triggered.connect(self.__warnLogTriggered) debug_log.triggered.connect(self.__debugLogTriggered) history_menu = setting_menu.addMenu("Packet History Size") history_group = QtWidgets.QActionGroup(self) history_group.setExclusive(True) history_10 = history_menu.addAction("10") history_50 = history_menu.addAction("50") history_100 = history_menu.addAction("100") history_infinite = history_menu.addAction("Infinite") history_10.setCheckable(True) history_50.setCheckable(True) history_100.setCheckable(True) history_infinite.setCheckable(True) history_group.addAction(history_10) history_group.addAction(history_50) history_group.addAction(history_100) history_group.addAction(history_infinite) history_100.setChecked(True) history_10.triggered.connect(self.__history10Triggered) history_50.triggered.connect(self.__history50Triggered) history_100.triggered.connect(self.__history100Triggered) history_infinite.triggered.connect(self.__historyInfiniteTriggered) self.__history100Triggered() thread_menu = setting_menu.addMenu("Threads") thread_group = QtWidgets.QActionGroup(self) thread_group.setExclusive(True) thread_single = thread_menu.addAction("Single") thread_multi = thread_menu.addAction("Multi") thread_single.setCheckable(True) thread_multi.setCheckable(True) thread_group.addAction(thread_single) thread_group.addAction(thread_multi) thread_single.setChecked(True) thread_single.triggered.connect(self.__singleThread) thread_multi.triggered.connect(self.__multiThread) self.__singleThread() menubar.addMenu(setting_menu) ## progress self.__progress = progress.Progress(self) self.__progress.hide() self.__graph_tabs.tabCloseRequested.connect(self.__closeGraphRequest) self.__graph_tabs.currentChanged.connect(self.__currentGraphTabChanged) self.__parm_editor.BlockRenamed.connect(self.__blockRenamed) self.__graph.CurrentNodeChanged.connect(self.__currentBlockChanged) self.__graph.RefreshParamRequest.connect(self.__parm_editor.forceRefresh) self.__graph.ShowGraphRequest.connect(self.__showGraphTab) self.__graph.BoxDeleted.connect(self.__boxDeleted) self.__graph.BoxCreated.connect(self.__boxCreated) self.__setPath(None)
def addMenuBarContents(self, menubar): # File Menu file_menu = QtWidgets.QMenu('File', menubar) # New Collection label = 'New Collection' tooltip = 'Create a new Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createNewCollectionNodeCB)) file_menu.addAction(action) # Rename Collection label = 'Rename Collection' tooltip = 'Rename a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.renameCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Remove Collection label = 'Remove Collection' tooltip = 'Remove a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.removeCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Close Window label = 'Close Window' tooltip = 'Close the mmSolver window.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.close)) file_menu.addAction(action) menubar.addMenu(file_menu) # Tools Menu tools_menu = QtWidgets.QMenu('Tools', menubar) # Create Marker label = 'Create Marker' tooltip = 'Create Markers on the selected camera.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createMarkerCB)) tools_menu.addAction(action) # Convert to Marker label = 'Convert to Marker' tooltip = 'Convert the selection to Markers.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.convertToMarkerCB)) tools_menu.addAction(action) # Load Markers label = 'Load Markers...' tooltip = 'Load Markers from a file.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.loadMarkerCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Create Bundle label = 'Create Bundle' tooltip = 'Create a default Bundle node.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createBundleCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Link Marker + Bundle label = 'Link Marker + Bundle' tooltip = 'Link the selected Marker and Bundle together.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.linkMarkerBundleCB)) tools_menu.addAction(action) # Unlink Marker from all Bundles label = 'Unlink Marker from all Bundles' tooltip = 'Unlink all selected Markers from their Bundle.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.unlinkMarkerBundleCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Toogle Marker / Bundle selection label = 'Toggle Marker / Bundle' tooltip = 'Select connected Markers, or Bundles.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.toggleMarkerBundleSelectionCB)) tools_menu.addAction(action) # Select Marker / Bundle label = 'Select Marker + Bundle' tooltip = 'Select the connected Markers and Bundles.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.selectBothMarkersAndBundlesCB)) tools_menu.addAction(action) # Rename Marker + Bundle label = 'Rename Markers + Bundles' tooltip = 'Rename the selected Markers and Bundles;' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.renameMarkerBundleCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Refresh Viewport During Solve label = 'Refresh Viewport' tooltip = 'Refresh the viewport while Solving.' refresh_value = lib_state.get_refresh_viewport_state() action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(refresh_value) action.toggled.connect(type(self).refreshActionToggledCB) tools_menu.addAction(action) menubar.addMenu(tools_menu) # Log Menu # This menu depicts a radio button allowing the user to choose # how much information is returned to the console (the logging # level). log_menu = QtWidgets.QMenu('Log', menubar) # Errors label = 'Errors' tooltip = 'Send Errors to the log.' logErrorAction = QtWidgets.QAction(label, log_menu) logErrorAction.setStatusTip(tooltip) logErrorAction.setCheckable(True) logErrorAction.triggered.connect(partial(self.logErrorCB)) log_menu.addAction(logErrorAction) # Warnings label = 'Warnings' tooltip = 'Send Warnings to the log.' logWarningAction = QtWidgets.QAction(label, log_menu) logWarningAction.setStatusTip(tooltip) logWarningAction.setCheckable(True) logWarningAction.triggered.connect(partial(self.logWarningCB)) log_menu.addAction(logWarningAction) # Information label = 'Info' tooltip = 'Send Information to the log.' logInfoAction = QtWidgets.QAction(label, log_menu) logInfoAction.setStatusTip(tooltip) logInfoAction.setCheckable(True) logInfoAction.triggered.connect(partial(self.logInfoCB)) log_menu.addAction(logInfoAction) # Verbose label = 'Verbose' tooltip = 'Send Verboses to the log.' logVerboseAction = QtWidgets.QAction(label, log_menu) logVerboseAction.setStatusTip(tooltip) logVerboseAction.setCheckable(True) logVerboseAction.triggered.connect(partial(self.logVerboseCB)) log_menu.addAction(logVerboseAction) # Debug label = 'Debug' tooltip = 'Send Debug messages to the log.' logDebugAction = QtWidgets.QAction(label, log_menu) logDebugAction.setStatusTip(tooltip) logDebugAction.setCheckable(True) logDebugAction.triggered.connect(partial(self.logDebugCB)) log_menu.addAction(logDebugAction) # 'Radio' button for logging levels log_actionGroup = QtWidgets.QActionGroup(log_menu) log_actionGroup.addAction(logErrorAction) log_actionGroup.addAction(logWarningAction) log_actionGroup.addAction(logInfoAction) log_actionGroup.addAction(logVerboseAction) log_actionGroup.addAction(logDebugAction) log_level = lib_state.get_log_level() if log_level == const.LOG_LEVEL_ERROR: logErrorAction.setChecked(True) elif log_level == const.LOG_LEVEL_WARNING: logWarningAction.setChecked(True) elif log_level == const.LOG_LEVEL_INFO: logInfoAction.setChecked(True) elif log_level == const.LOG_LEVEL_VERBOSE: logVerboseAction.setChecked(True) elif log_level == const.LOG_LEVEL_DEBUG: logDebugAction.setChecked(True) else: LOG.warning('Invalid log level given: %r' % log_level) menubar.addMenu(log_menu) # Help Menu help_menu = QtWidgets.QMenu('Help', menubar) # Launch Help label = 'Help...' tooltip = 'Show help.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchHelpCB)) help_menu.addAction(action) # # Launch About # label = 'About...' # tooltip = 'About this software.' # action = QtWidgets.QAction(label, help_menu) # action.setStatusTip(tooltip) # action.triggered.connect(partial(self.launchAboutCB)) # help_menu.addAction(action) menubar.addMenu(help_menu) return
def buildUI(self): # menu fileNewAction = self.createAction("&New...", self.fileNew, QtGui.QKeySequence.New, "filenew", "Create an image file") fileOpenAction = self.createAction("&Open...", self.fileNew, QtGui.QKeySequence.Open, "fileopen", "Open an existing image file") fileSaveAction = self.createAction("&Save", self.fileNew, QtGui.QKeySequence.Save, "filesave", "Save the image") fileSaveAsAction = self.createAction( "Save &As...", self.fileNew, icon="filesaveas", tip="Save the image using a new name") filePrintAction = self.createAction("&Print", self.fileNew, QtGui.QKeySequence.Print, "fileprint", "Print the image") fileQuitAction = self.createAction("&Quit", self.fileNew, "Ctrl+Q", "filequit", "Close the application") editInvertAction = self.createAction("&Invert", self.fileNew, "Ctrl+I", "editinvert", "Invert the image's colors", True, "toggled(bool)") editSwapRedAndBlueAction = self.createAction( "Sw&ap Red and Blue", self.fileNew, "Ctrl+A", "editswap", "Swap the image's red and blue color components", True, "toggled(bool)") editZoomAction = self.createAction("&Zoom...", self.fileNew, "Alt+Z", "editzoom", "Zoom the image") mirrorGroup = QtWidgets.QActionGroup(self) editUnMirrorAction = self.createAction("&Unmirror", self.fileNew, "Ctrl+U", "editunmirror", "Unmirror the image", True, "toggled(bool)") mirrorGroup.addAction(editUnMirrorAction) editMirrorHorizontalAction = self.createAction( "Mirror &Horizontally", self.fileNew, "Ctrl+H", "editmirrorhoriz", "Horizontally mirror the image", True, "toggled(bool)") mirrorGroup.addAction(editMirrorHorizontalAction) editMirrorVerticalAction = self.createAction( "Mirror &Vertically", self.fileNew, "Ctrl+V", "editmirrorvert", "Vertically mirror the image", True, "toggled(bool)") mirrorGroup.addAction(editMirrorVerticalAction) editUnMirrorAction.setChecked(True) helpAboutAction = self.createAction("&About Image Changer", self.helpAbout) helpHelpAction = self.createAction("&Help", self.helpHelp, QtGui.QKeySequence.HelpContents) self.fileMenu = self.menuBar().addMenu("&File") self.fileMenuActions = (fileNewAction, fileOpenAction, fileSaveAction, fileSaveAsAction, None, filePrintAction, fileQuitAction) # self.fileMenu.aboutToShow.connect(self.updateFileMenu) editMenu = self.menuBar().addMenu("&Edit") self.addActions( editMenu, (editInvertAction, editSwapRedAndBlueAction, editZoomAction)) mirrorMenu = editMenu.addMenu(QtGui.QIcon(":/editmirror.png"), "&Mirror") self.addActions(mirrorMenu, (editUnMirrorAction, editMirrorHorizontalAction, editMirrorVerticalAction)) helpMenu = self.menuBar().addMenu("&Help") self.addActions(helpMenu, (helpAboutAction, helpHelpAction)) fileToolbar = self.addToolBar("File") fileToolbar.setObjectName("FileToolBar") self.addActions(fileToolbar, (fileNewAction, fileOpenAction, fileSaveAsAction)) editToolbar = self.addToolBar("Edit") editToolbar.setObjectName("EditToolBar") self.addActions( editToolbar, (editInvertAction, editSwapRedAndBlueAction, editUnMirrorAction, editMirrorVerticalAction, editMirrorHorizontalAction)) self.zoomSpinBox = QtWidgets.QSpinBox() self.zoomSpinBox.setRange(1, 400) self.zoomSpinBox.setSuffix(" %") self.zoomSpinBox.setValue(100) self.zoomSpinBox.setToolTip("Zoom the image") self.zoomSpinBox.setStatusTip(self.zoomSpinBox.toolTip()) self.zoomSpinBox.setFocusPolicy(QtCore.Qt.NoFocus) self.zoomSpinBox.valueChanged[int].connect(self.fileNew) editToolbar.addWidget(self.zoomSpinBox) self.searchLineEdit = QtWidgets.QLineEdit("Search...") self.searchLineEdit.setToolTip("Searching") self.searchLineEdit.setMaximumWidth(200) self.searchLineEdit.returnPressed.connect(self.populate2) editToolbar.addWidget(self.searchLineEdit) # self.addActions(self.imageLabel, (editInvertAction, # editSwapRedAndBlueAction, editUnMirrorAction, # editMirrorVerticalAction, editMirrorHorizontalAction)) self.resetableActions = ((editInvertAction, False), (editSwapRedAndBlueAction, False), (editUnMirrorAction, True)) settings = QtCore.QSettings("MyCompany", "MyApp") self.recentFiles = settings.value("RecentFiles") self.restoreGeometry( QtCore.QByteArray(settings.value("MainWindow/Geometry"))) self.restoreState(QtCore.QByteArray( settings.value("MainWindow/State"))) # menu above mainSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal, self) self.tree = QtWidgets.QTreeWidget() # tree self.tree.setColumnCount(2) self.tree.setHeaderLabels([u'分类', '']) root = QtWidgets.QTreeWidgetItem(self.tree) root.setText(0, u'模型') search = "1" inputfiled = "pid" sql_info = self.sql_back(search, inputfiled) for i in sql_info: print i[1] QtWidgets.QTreeWidgetItem(root, [i[1]], 0) name_test = i[1] print name_test, type(name_test), 'name_test<<<<<<<<<<<<<<<<<<<<' self.sql_dict[name_test] = i[2] for k, v in self.sql_dict.items(): print k, v self.tree.addTopLevelItem(root) self.tree.clicked.connect(self.on_treeview_clicked3) mainSplitter.addWidget(self.tree) rightSplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical, mainSplitter) rightSplitter.setOpaqueResize(False) self.listWidget = ThumbListWidget(self) self.listWidget2 = ThumbListWidget(self) self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.listWidget.customContextMenuRequested.connect( self.listItemRightClicked) self.listWidget2.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.listWidget2.customContextMenuRequested.connect( self.listItemRightClicked2) self.listWidget2.addfile.connect(self.ref_something) rightSplitter.addWidget(self.listWidget) rightSplitter.addWidget(self.listWidget2) size = 64 buffer = 12 self.listWidget.setViewMode(QtWidgets.QListWidget.IconMode) self.listWidget.setIconSize(QtCore.QSize(size, size)) self.listWidget.setResizeMode(QtWidgets.QListWidget.Adjust) self.listWidget.setGridSize(QtCore.QSize(size + buffer, size + buffer)) self.listWidget.setDragEnabled(True) self.listWidget2.setIconSize(QtCore.QSize(size, size)) self.listWidget2.setResizeMode(QtWidgets.QListWidget.Adjust) self.listWidget2.setGridSize(QtCore.QSize(size + buffer, size + buffer)) self.listWidget2.setDragEnabled(True) mainSplitter.setStretchFactor(1, 20) rightSplitter.setStretchFactor(0, 5) self.setCentralWidget(mainSplitter) #停靠窗口 1 dock1 = QtWidgets.QDockWidget((u"停靠窗口 1"), self) dock1.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable) dock1.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea | QtCore.Qt.RightDockWidgetArea) te1 = QtWidgets.QTextEdit((u"窗口 1,可在 Main Window 的左部和右部停靠,不可浮动,不可关闭")) dock1.setWidget(te1) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock1) #停靠窗口 2 dock2 = QtWidgets.QDockWidget((u"停靠窗口 2"), self) dock2.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable | QtWidgets.QDockWidget.DockWidgetClosable) # dock2.setTitleBarWidget() te2 = QtWidgets.QTextEdit((u"窗口 2,只可浮动")) dock2.setWidget(te2) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock2) #停靠窗口 2 dock4 = QtWidgets.QDockWidget((u"停靠窗口 4"), self) dock4.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable | QtWidgets.QDockWidget.DockWidgetClosable) te4 = QtWidgets.QTextEdit((u"窗口 4,只可浮动")) dock4.setWidget(te4) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock4) #停靠窗口 3 # dock3=QtWidgets.QDockWidget((u"停靠窗口 3"),self) # dock3.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) # te3=QtWidgets.QTextEdit((u"窗口 3,可在 Main Window 任意位置停靠,可浮动,可关闭")) # dock3.setWidget(te3) # self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,dock3) #dock1 和dock4 合并 self.tabifyDockWidget(dock1, dock4)
def __init__(self): """ This is the constructor of the 'gui_top' class. This function will be executed when the class is used. This function initializes the default tabs (console, register), menus (File, Port) and the items related to that. Custom operations may be added to init_tabs """ #Initialize GUI super().__init__() self.setupUi(self) self.LibraryViewer = LibraryViewer(self) self.SchematicViewer = SchematicViewer(self) # ===================================================================== # connect actions # ===================================================================== self.actionQuit.triggered.connect( QtWidgets.QApplication.instance().quit) # SchematicViewer actions self.actionNew.triggered.connect(self.SchematicViewer.New) # self.actionOpen.triggered.connect( self.SchematicViewer.Open) # self.actionSave.triggered.connect( self.SchematicViewer.Save) # self.actionSave_as.triggered.connect( self.SchematicViewer.SaveAs) # self.actionPrint.triggered.connect( self.SchematicViewer.Print) # self.actionPrint_hierarchy.triggered.connect( self.SchematicViewer.PrintHierarchy) self.actionInput_Port.triggered.connect( self.SchematicViewer.inPortMode) self.actionOutput_Port.triggered.connect( self.SchematicViewer.outPortMode) self.actionConnection.triggered.connect( self.SchematicViewer.connectionMode) self.actionNormal.triggered.connect(self.SchematicViewer.normalMode) self.actionText.triggered.connect(self.SchematicViewer.textMode) # self.actionCut.triggered.connect( self.SchematicViewer.Cut) # self.actionCopy.triggered.connect( self.SchematicViewer.Copy) # self.actionPaste.triggered.connect( self.SchematicViewer.Paste) # self.actionProperties.triggered.connect( self.SchematicViewer.Properties) # Simulation actions # self.actionNetlist.triggered.connect( self.Simulation.Netlist) # self.actionNetlist_and_Run.triggered.connect (self.Simulation.NetlistAndRun) # help self.actionManual.triggered.connect(self.Manual) self.actionWebsite.triggered.connect(self.Website) self.actionabout.triggered.connect(self.About) # Library actions self.actionNew_Library.triggered.connect(self.LibraryViewer.New) self.actionimport_from_file.triggered.connect( self.LibraryViewer.ImportFromFile) self.actiontoggle_layout.triggered.connect( self.LibraryViewer.ToggleView) # ===================================================================== # create menuLanguage entries # ===================================================================== self.languageActionGroup = QtWidgets.QActionGroup(self) self.languageActionGroup.setExclusive(True) for lang in 'MyHdl SystemVerilog Xyce'.split(): va = self.menuLanguage.addAction(lang) va.setCheckable(True) va.setActionGroup(self.languageActionGroup) va.setData(lang) # select first entry self.languageActionGroup.actions()[0].setChecked(True)
def _setup_ui(self): """ Main ui creation and assembly """ # controls self.frame_image = QtWidgets.QFrame(self) self.frame_image.setObjectName('ImageFrame') self.frame_controls = QtWidgets.QFrame(self) self.label_display = QtWidgets.QLabel('Input Wisdom', self) self.label_display.setWordWrap(True) self.label_display.setAlignment(QtCore.Qt.AlignCenter) shadow = QtWidgets.QGraphicsDropShadowEffect(self) shadow.setBlurRadius(2) shadow.setOffset(2.0) shadow.setColor(QtGui.QColor(0, 0, 0, 255)) self.label_display.setGraphicsEffect(shadow) self.label_remaining = QtWidgets.QLabel('', self) self.label_remaining.setAlignment(QtCore.Qt.AlignRight) self.line_edit_wisdom = QtWidgets.QLineEdit(self) self.line_edit_wisdom.setMaxLength(140) random_phrase_button = QtWidgets.QPushButton('Randomise Phrase', self) random_image_button = QtWidgets.QPushButton('Randomise Image', self) save_button = QtWidgets.QPushButton('Save Wisdom Image', self) menubar = QtWidgets.QMenuBar(self) menubar.setNativeMenuBar(False) self.status_bar = QtWidgets.QStatusBar(self) # font family menu_font = menubar.addMenu('Font') menu_font_group = QtWidgets.QActionGroup(self) for font in self.font_list: action_font = menu_font.addAction(font, partial(self.set_font_family, font)) action_font.setCheckable(True) if str(font) == self.current_font: action_font.setChecked(True) menu_font_group.addAction(action_font) # font size menu_font_size = menubar.addMenu('Font Size') menu_font_size_group = QtWidgets.QActionGroup(self) for size in self.font_sizes: action_font_size = menu_font_size.addAction(str(size), partial(self.set_font_size, size)) action_font_size.setCheckable(True) if size == self.current_font_size: action_font_size.setChecked(True) menu_font_size_group.addAction(action_font_size) # layouts layout_v_main = QtWidgets.QVBoxLayout() layout_v_main.setContentsMargins(0, 0, 0, 0) layout_v_main.setSpacing(0) layout_v_image = QtWidgets.QVBoxLayout() layout_v_controls = QtWidgets.QVBoxLayout() layout_v_controls.setContentsMargins(130, 5, 130, 5) layout_h_buttons = QtWidgets.QHBoxLayout() layout_h_buttons.setContentsMargins(0, 2, 0, 2) # set layouts self.setLayout(layout_v_main) self.frame_image.setLayout(layout_v_image) self.frame_controls.setLayout(layout_v_controls) # add to layouts layout_v_main.addWidget(menubar) layout_v_main.addWidget(self.frame_image) layout_v_main.addWidget(self.frame_controls) layout_v_main.addWidget(self.status_bar) layout_v_image.addWidget(self.label_display) layout_v_controls.addWidget(self.line_edit_wisdom) layout_v_controls.addWidget(self.label_remaining) layout_v_controls.addLayout(layout_h_buttons) layout_h_buttons.addWidget(random_phrase_button) layout_h_buttons.addWidget(random_image_button) layout_h_buttons.addWidget(save_button) # layout settings layout_v_main.setStretch(0, 0) layout_v_main.setStretch(1, 1) layout_v_main.setStretch(2, 0) # connections self.line_edit_wisdom.textChanged.connect(self.update_ui) random_phrase_button.clicked.connect(self.get_random_wisdom) random_image_button.clicked.connect(self.set_random_bg_image) save_button.clicked.connect(self.take_screenshot) # style if self.current_font and self.current_font_size: self.set_font_style(self.current_font, self.current_font_size) # self.setWindowFlags(QtCore.Qt.FramelessWindowHint) self.setWindowTitle("Wisdom") controls_style = """ QWidget {background-color: white; padding: 7px;} QPushButton {border-radius: 6px; border: 2px solid #E0E0E0; height: 30;} """ self.frame_controls.setStyleSheet(controls_style) self.status_bar.showMessage("Click to randomise or type to alter text", 5000)
def addMenuBarContents(self, menubar): # Search Menu search_menu = QtWidgets.QMenu('Search', menubar) # New Search newSearchAction = QtWidgets.QAction('New Search', search_menu) newSearchAction.setShortcut('Ctrl+N') newSearchAction.setStatusTip('Start a new Asset search') newSearchAction.triggered.connect(partial(self.newSearchCallback)) # Save Search saveSearchAction = QtWidgets.QAction('Save Search', search_menu) saveSearchAction.setShortcut('Ctrl+S') saveSearchAction.setStatusTip('Save an Asset search') saveSearchAction.triggered.connect(partial(self.saveSearchCallback)) # Search Mode Menu search_mode_menu = QtWidgets.QMenu('Search Mode', search_menu) modeBasicAction = QtWidgets.QAction('Basic', search_mode_menu) modeBasicAction.setStatusTip('Use simple search text') modeBasicAction.setCheckable(True) modeBasicAction.setChecked(True) modeTagAction = QtWidgets.QAction('Tag Finder', search_mode_menu) modeTagAction.setStatusTip('Use tag browsing') modeTagAction.setCheckable(True) modeTagAction.setChecked(False) modeFieldAction = QtWidgets.QAction('Search Condtions', search_mode_menu) modeFieldAction.setStatusTip( 'Use custom Search condtions on database fields') modeFieldAction.setCheckable(True) modeFieldAction.setChecked(False) searchModeActionGroup = QtWidgets.QActionGroup(search_menu) searchModeActionGroup.addAction(modeBasicAction) searchModeActionGroup.addAction(modeTagAction) searchModeActionGroup.addAction(modeFieldAction) search_mode_menu.addAction(modeBasicAction) search_mode_menu.addAction(modeTagAction) search_mode_menu.addAction(modeFieldAction) search_menu.addAction(newSearchAction) search_menu.addAction(saveSearchAction) search_menu.addSeparator() search_menu.addMenu(search_mode_menu) menubar.addMenu(search_menu) # View Menu view_menu = QtWidgets.QMenu('View', menubar) assetViewListAction = QtWidgets.QAction('List Asset View', view_menu) assetViewListAction.setCheckable(True) assetViewListAction.setChecked(True) assetViewGridAction = QtWidgets.QAction('Grid Asset View', view_menu) assetViewGridAction.setCheckable(True) assetViewActionGroup = QtWidgets.QActionGroup(view_menu) assetViewActionGroup.addAction(assetViewGridAction) assetViewActionGroup.addAction(assetViewListAction) view_menu.addAction(assetViewListAction) view_menu.addAction(assetViewGridAction) menubar.addMenu(view_menu) # Version Menu version_menu = QtWidgets.QMenu('Versions', menubar) approvedVersionAction = QtWidgets.QAction('Approved Versions', version_menu) approvedVersionAction.setCheckable(True) approvedVersionAction.setChecked(True) latestVersionAction = QtWidgets.QAction('Latest Version', version_menu) latestVersionAction.setCheckable(True) deletedVersionAction = QtWidgets.QAction('Deleted Versions', version_menu) deletedVersionAction.setCheckable(True) customVersionAction = QtWidgets.QAction('Custom Versions', version_menu) customVersionAction.setCheckable(True) assetVersionActionGroup = QtWidgets.QActionGroup(version_menu) assetVersionActionGroup.addAction(approvedVersionAction) assetVersionActionGroup.addAction(latestVersionAction) assetVersionActionGroup.addAction(deletedVersionAction) assetVersionActionGroup.addAction(customVersionAction) version_menu.addAction(approvedVersionAction) version_menu.addAction(latestVersionAction) version_menu.addAction(deletedVersionAction) version_menu.addAction(customVersionAction) menubar.addMenu(version_menu) # Window Menu window_menu = QtWidgets.QMenu('Window', menubar) assetCartAction = QtWidgets.QAction('Asset Cart', window_menu) assetCartAction.setStatusTip('Show or hide the asset cart') assetCartAction.setCheckable(True) assetCartAction.setChecked(True) assetInfoAction = QtWidgets.QAction('Asset Info', window_menu) assetInfoAction.setStatusTip('Show or hide the asset info') assetInfoAction.setCheckable(True) assetInfoAction.setChecked(True) window_menu.addAction(assetCartAction) window_menu.addAction(assetInfoAction) menubar.addMenu(window_menu)
def setupUi(self, parent): self.transform_icon = QtGui.QIcon(':transform.svg') # Main layout self.gridLayout = QtWidgets.QGridLayout(parent) # Menu self.menu_bar = QtWidgets.QMenuBar() self.options_menu = self.menu_bar.addMenu('Freeze') self.refresh_menu = self.menu_bar.addMenu('Refresh') # Freeze options actions self.animlayer_action = QtWidgets.QAction('Add to AnimLayer', self) self.animlayer_action.setCheckable(True) self.options_menu.addAction(self.animlayer_action) self.options_menu.addSeparator() self.freeze_action_group = QtWidgets.QActionGroup(self) self.camera_space_action = QtWidgets.QAction('Freeze in Camera Space', self) self.camera_space_action.setCheckable(True) self.options_menu.addAction(self.camera_space_action) self.camera_space_action.setActionGroup(self.freeze_action_group) self.world_space_action = QtWidgets.QAction('Freeze in World Space', self) self.world_space_action.setCheckable(True) self.world_space_action.setChecked(True) self.options_menu.addAction(self.world_space_action) self.world_space_action.setActionGroup(self.freeze_action_group) # Refresh action self.refresh_action = QtWidgets.QAction('Refresh Rigs list', self) self.refresh_menu.addAction(self.refresh_action) self.gridLayout.setMenuBar(self.menu_bar) spacerItem = QtWidgets.QSpacerItem( 5, 17, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem, 0, 0, 1, 1) # Full bake radio button self.full_bake_rdo_btn = QtWidgets.QRadioButton() self.gridLayout.addWidget(self.full_bake_rdo_btn, 0, 1, 1, 1) spacerItem1 = QtWidgets.QSpacerItem( 5, 17, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem1, 0, 2, 1, 1) # Smart bake radio button self.smart_bake_rdo_btn = QtWidgets.QRadioButton() self.smart_bake_rdo_btn.setLayoutDirection(QtCore.Qt.LeftToRight) self.smart_bake_rdo_btn.setAutoFillBackground(False) self.smart_bake_rdo_btn.setChecked(True) self.gridLayout.addWidget(self.smart_bake_rdo_btn, 0, 3, 1, 1) spacerItem2 = QtWidgets.QSpacerItem( 5, 10, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.gridLayout.addItem(spacerItem2, 0, 4, 1, 1) self.horizontalLayout_2 = QtWidgets.QHBoxLayout() # Rigs label self.rigs_label = QtWidgets.QLabel() self.horizontalLayout_2.addWidget(self.rigs_label) # Rigs list self.rigs_list = QtWidgets.QTreeWidget() self.rigs_list.setFocusPolicy(QtCore.Qt.NoFocus) self.rigs_list.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.rigs_list.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.rigs_list.setIndentation(15) self.rigs_list.setHeaderHidden(True) self.horizontalLayout_2.addWidget(self.rigs_list) self.gridLayout.addLayout(self.horizontalLayout_2, 2, 0, 1, 5) self.horizontalLayout = QtWidgets.QHBoxLayout() # Name label self.name_label = QtWidgets.QLabel() self.horizontalLayout.addWidget(self.name_label) # Name line edit self.name_text = QtWidgets.QLineEdit() self.name_text.setFocusPolicy(QtCore.Qt.ClickFocus) self.horizontalLayout.addWidget(self.name_text) self.gridLayout.addLayout(self.horizontalLayout, 3, 0, 1, 5) # Widget labels self.full_bake_rdo_btn.setText('Full bake') self.smart_bake_rdo_btn.setText('Smart bake') self.rigs_label.setText('Rigs') self.name_label.setText('Name') self.context_menu = QtWidgets.QMenu() self.create_rig_action = QtWidgets.QAction('Create Screen-Space Rig', self) self.context_menu.addAction(self.create_rig_action) self.create_freeze_rig_action = QtWidgets.QAction('Create Freeze Rig', self) self.context_menu.addAction(self.create_freeze_rig_action) self.context_menu.addSeparator() self.match_rig_action = QtWidgets.QAction('Match Screen Z-Depth', self) self.context_menu.addAction(self.match_rig_action) self.context_menu.addSeparator() self.bake_rig_action = QtWidgets.QAction('Bake Rig', self) self.context_menu.addAction(self.bake_rig_action) self.delete_rig_action = QtWidgets.QAction('Delete Rig', self) self.context_menu.addAction(self.delete_rig_action) self.context_menu.addSeparator() self.select_action = QtWidgets.QAction('Select in Outliner', self) self.context_menu.addAction(self.select_action) return
def __init__(self, mainWindow, fileName=None): """Constructor for the editor window :params QMainWindow mainWindow: the parent main window :params string fileName: Optional filename to open on start """ super().__init__(mainWindow) self.setObjectName("editor_window") self.setGeometry(100, 100, 1024, 768) self.setWindowTitle( self.tr("ts2 - Train Signalling Simulation - Editor")) self._mainWindow = mainWindow self._dirty = False # Editor self.editor = editor.Editor(fileName=fileName) self.editor.initialize(self) # Actions self.newAction = QtWidgets.QAction(self.tr("&New"), self) self.newAction.setShortcut(QtGui.QKeySequence.New) newActionTip = self.tr("Create a new simulation") self.newAction.setToolTip(newActionTip) self.newAction.setStatusTip(newActionTip) self.newAction.triggered.connect(self.closeSimulation) self.openAction = QtWidgets.QAction(self.tr("&Open..."), self) self.openAction.setShortcut(QtGui.QKeySequence.Open) openActionTip = self.tr("Open a simulation") self.openAction.setToolTip(openActionTip) self.openAction.setStatusTip(openActionTip) self.openAction.triggered.connect(self.loadSimulation) self.saveAction = QtWidgets.QAction(self.tr("&Save"), self) self.saveAction.setShortcut(QtGui.QKeySequence.Save) saveActionTip = self.tr("Save the current simulation") self.saveAction.setToolTip(saveActionTip) self.saveAction.setStatusTip(saveActionTip) self.saveAction.triggered.connect(self.saveSimulation) self.saveAsAction = QtWidgets.QAction(self.tr("&Save as..."), self) self.saveAsAction.setShortcut(QtGui.QKeySequence.SaveAs) saveAsActionTip = self.tr( "Save the current simulation with a different file name") self.saveAsAction.setToolTip(saveAsActionTip) self.saveAsAction.setStatusTip(saveAsActionTip) self.saveAsAction.triggered.connect(self.saveAsSimulation) self.closeAction = QtWidgets.QAction(self.tr("&Close"), self) self.closeAction.setShortcut(QtGui.QKeySequence.Close) closeActionTip = self.tr("Close the editor") self.closeAction.setToolTip(closeActionTip) self.closeAction.setStatusTip(closeActionTip) self.closeAction.triggered.connect(self.close) self.panToolAction = QtWidgets.QAction(self.tr("&Pan tool"), self) panToolActionTip = self.tr("Set the pan tool") self.panToolAction.setToolTip(panToolActionTip) self.panToolAction.setStatusTip(panToolActionTip) self.panToolAction.setCheckable(True) self.panToolAction.triggered.connect(self.setPanTool) self.selectionToolAction = QtWidgets.QAction( self.tr("&Selection tool"), self) selectionToolActionTip = self.tr("Set the selection tool") self.selectionToolAction.setToolTip(selectionToolActionTip) self.selectionToolAction.setStatusTip(selectionToolActionTip) self.selectionToolAction.setCheckable(True) self.selectionToolAction.triggered.connect(self.setSelectionTool) self.toolActions = QtWidgets.QActionGroup(self) self.toolActions.addAction(self.panToolAction) self.toolActions.addAction(self.selectionToolAction) self.panToolAction.setChecked(True) self.copyAction = QtWidgets.QAction(self.tr("&Copy"), self) self.copyAction.setShortcut(QtGui.QKeySequence.Copy) copyActionTip = self.tr("Copy the current selection to the clipboard") self.copyAction.setToolTip(copyActionTip) self.copyAction.setStatusTip(copyActionTip) self.copyAction.triggered.connect(self.copyItems) self.pasteAction = QtWidgets.QAction(self.tr("&Paste"), self) self.pasteAction.setShortcut(QtGui.QKeySequence.Paste) pasteActionTip = self.tr("Paste the items of the clipboard") self.pasteAction.setToolTip(pasteActionTip) self.pasteAction.setStatusTip(pasteActionTip) self.pasteAction.triggered.connect(self.pasteItems) self.deleteAction = QtWidgets.QAction(self.tr("&Delete"), self) self.deleteAction.setShortcut(QtGui.QKeySequence.Delete) deleteActionTip = self.tr("Delete the selected items") self.deleteAction.setToolTip(deleteActionTip) self.deleteAction.setStatusTip(deleteActionTip) self.deleteAction.triggered.connect(self.deleteItems) self.selectAllAction = QtWidgets.QAction(self.tr("&Select All"), self) self.selectAllAction.setShortcut(QtGui.QKeySequence.SelectAll) selectAllActionTip = self.tr("Select all the items") self.selectAllAction.setToolTip(selectAllActionTip) self.selectAllAction.setStatusTip(selectAllActionTip) self.selectAllAction.triggered.connect(self.selectAll) self.aboutAction = QtWidgets.QAction(self.tr("&About TS2..."), self) aboutActionTip = self.tr("About TS2") self.aboutAction.setToolTip(aboutActionTip) self.aboutAction.setStatusTip(aboutActionTip) self.aboutAction.triggered.connect(self._mainWindow.showAboutBox) self.aboutQtAction = QtWidgets.QAction(self.tr("About Qt..."), self) aboutQtTip = self.tr("About Qt") self.aboutQtAction.setToolTip(aboutQtTip) self.aboutQtAction.setStatusTip(aboutQtTip) self.aboutQtAction.triggered.connect(QtWidgets.QApplication.aboutQt) # Menu self.fileMenu = self.menuBar().addMenu(self.tr("&File")) self.fileMenu.addAction(self.newAction) self.fileMenu.addAction(self.openAction) self.fileMenu.addAction(self.saveAction) self.fileMenu.addAction(self.saveAsAction) self.fileMenu.addSeparator() self.fileMenu.addAction(self.closeAction) self.editMenu = self.menuBar().addMenu(self.tr("&Edit")) self.editMenu.addAction(self.panToolAction) self.editMenu.addAction(self.selectionToolAction) self.editMenu.addSeparator() self.editMenu.addAction(self.copyAction) self.editMenu.addAction(self.pasteAction) self.editMenu.addAction(self.deleteAction) self.editMenu.addSeparator() self.editMenu.addAction(self.selectAllAction) self.helpMenu = self.menuBar().addMenu(self.tr("&Help")) self.helpMenu.addAction(self.aboutAction) self.helpMenu.addAction(self.aboutQtAction) self.menuBar().setCursor(Qt.PointingHandCursor) self.updateMenus(0) # Status bar statusBar = QtWidgets.QStatusBar() self.setStatusBar(statusBar) # Dock Widgets # >> TrackItems panel: TI Library self.toolsPanel = QtWidgets.QDockWidget(self.tr("Tools"), self) self.toolsPanel.setObjectName("toolsPanel") self.toolsPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.trackItemsLibraryView = QtWidgets.QGraphicsView(self) self.trackItemsLibraryView.setBackgroundBrush(QtGui.QBrush(Qt.black)) self.trackItemsLibraryView.setInteractive(True) self.trackItemsLibraryView.setRenderHint(QtGui.QPainter.Antialiasing, False) self.trackItemsLibraryView.setDragMode( QtWidgets.QGraphicsView.ScrollHandDrag) self.trackItemsLibraryView.setAlignment(Qt.AlignLeft | Qt.AlignTop) # >> TrackItems panel: layout toolBoard = QtWidgets.QWidget(self) toolGrid = QtWidgets.QVBoxLayout() toolGrid.addWidget(self.trackItemsLibraryView) toolGrid.setSpacing(5) toolBoard.setLayout(toolGrid) self.toolsPanel.setWidget(toolBoard) self.addDockWidget(Qt.RightDockWidgetArea, self.toolsPanel) # >> Properties panel self.propertiesPanel = QtWidgets.QDockWidget(self.tr("Properties"), self) self.propertiesPanel.setObjectName("propertiesPanel") self.propertiesPanel.setFeatures( QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.propertiesView = ts2.editor.views.PropertiesView(self) self.propertiesPanel.setWidget(self.propertiesView) self.addDockWidget(Qt.RightDockWidgetArea, self.propertiesPanel) # Central tab widget self.tabWidget = QtWidgets.QTabWidget(self) # ========================================== # General tab generalTab = QtWidgets.QWidget() titleLabel = QtWidgets.QLabel(self.tr("Simulation title: "), generalTab) self.titleTxt = QtWidgets.QLineEdit(generalTab) self.titleTxt.editingFinished.connect(self.updateTitle) descriptionLabel = QtWidgets.QLabel(self.tr("Description: "), generalTab) self.descriptionTxt = QtWidgets.QPlainTextEdit(generalTab) self.descriptionTxt.textChanged.connect(self.updateDescription) optionsLabel = QtWidgets.QLabel(self.tr("Options: ")) self.optionsView = QtWidgets.QTableView(generalTab) fgrid = QtWidgets.QGridLayout() row = 0 fgrid.addWidget(titleLabel, row, 0, Qt.AlignRight | Qt.AlignTop) fgrid.addWidget(self.titleTxt, row, 1) row += 1 fgrid.addWidget(descriptionLabel, row, 0, Qt.AlignRight | Qt.AlignTop) fgrid.addWidget(self.descriptionTxt, row, 1) row += 1 fgrid.addWidget(optionsLabel, row, 0, Qt.AlignRight | Qt.AlignTop) fgrid.addWidget(self.optionsView, row, 1) generalTab.setLayout(fgrid) fgrid.setColumnStretch(0, 0) fgrid.setColumnStretch(1, 4) fgrid.setRowStretch(0, 0) fgrid.setRowStretch(1, 1) fgrid.setRowStretch(2, 2) self.tabWidget.addTab(generalTab, self.tr("General")) # ========================================== # Scenery tab self.sceneryWidget = widgets.VBoxWidget() toolbarScenery = QtWidgets.QToolBar() self.sceneryWidget.addWidget(toolbarScenery) self.unlockSceneryBtn = QtWidgets.QPushButton( self.tr("Unlock Scenery"), self.sceneryWidget) self.unlockSceneryBtn.setEnabled(False) toolbarScenery.addWidget(self.unlockSceneryBtn) self.validateSceneryBtn = QtWidgets.QPushButton( self.tr("Validate Scenery"), self.sceneryWidget) self.validateSceneryBtn.clicked.connect(self.validateSceneryBtnClicked) toolbarScenery.addWidget(self.validateSceneryBtn) self.zoomWidget = widgets.ZoomWidget(self.sceneryWidget) self.zoomWidget.valueChanged.connect(self.zoom) toolbarScenery.addWidget(self.zoomWidget) self.sceneryView = widgets.XGraphicsView(self.sceneryWidget) self.sceneryView.setInteractive(True) self.sceneryView.setRenderHint(QtGui.QPainter.Antialiasing, False) self.sceneryView.setDragMode(QtWidgets.QGraphicsView.ScrollHandDrag) self.sceneryView.setAcceptDrops(True) self.sceneryView.setBackgroundBrush(QtGui.QBrush(Qt.black)) self.sceneryView.wheelChanged.connect(self.onSceneryViewWheelChanged) self.sceneryWidget.addWidget(self.sceneryView) self.tabWidget.addTab(self.sceneryWidget, self.tr("Scenery")) # ========================================== # Routes tab self.routesWidget = widgets.VBoxWidget() sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setVerticalStretch(1) self.routesGraphicView = QtWidgets.QGraphicsView(self.routesWidget) self.routesGraphicView.setInteractive(True) self.routesGraphicView.setRenderHint(QtGui.QPainter.Antialiasing, False) self.routesGraphicView.setDragMode( QtWidgets.QGraphicsView.ScrollHandDrag) self.routesGraphicView.setAcceptDrops(True) self.routesGraphicView.setBackgroundBrush(QtGui.QBrush(Qt.black)) self.routesGraphicView.setSizePolicy(sizePolicy) self.addRouteBtn = QtWidgets.QPushButton(self.tr("Add Route"), self.routesWidget) self.addRouteBtn.clicked.connect(self.addRouteBtnClicked) self.delRouteBtn = QtWidgets.QPushButton(self.tr("Delete Route"), self.routesWidget) self.delRouteBtn.clicked.connect(self.delRouteBtnClicked) hgrid = QtWidgets.QHBoxLayout() hgrid.setContentsMargins(0, 0, 0, 0) hgrid.addWidget(self.addRouteBtn) hgrid.addWidget(self.delRouteBtn) hgrid.addStretch() self.routesView = ts2.editor.views.RoutesEditorView(self.routesWidget) self.routesWidget.addWidget(self.routesGraphicView) self.routesWidget.addLayout(hgrid) self.routesWidget.addWidget(self.routesView) self.routesWidget.setEnabled(False) self.tabWidget.addTab(self.routesWidget, self.tr("Routes")) # ========================================== # Train types tab self.trainTypesWidget = widgets.VBoxWidget() tbar = QtWidgets.QToolBar() self.trainTypesWidget.addWidget(tbar) tbg = widgets.ToolBarGroup(title="Train Types") tbar.addWidget(tbg) # add train self.addTrainTypeBtn = QtWidgets.QToolButton(self.trainTypesWidget) self.addTrainTypeBtn.setText(self.tr("Add new")) self.addTrainTypeBtn.clicked.connect(self.addTrainTypeBtnClicked) tbg.addWidget(self.addTrainTypeBtn) # remove train self.delTrainTypeBtn = QtWidgets.QToolButton(self.trainTypesWidget) self.delTrainTypeBtn.setText(self.tr("Remove")) self.delTrainTypeBtn.clicked.connect(self.delTrainTypeBtnClicked) tbg.addWidget(self.delTrainTypeBtn) self.trainTypesView = ts2.editor.views.TrainTypesEditorView( self.trainTypesWidget) self.trainTypesWidget.addWidget(self.trainTypesView) self.tabWidget.addTab(self.trainTypesWidget, self.tr("Rolling Stock")) # =============================================================== # Services tab # =============================================================== self.servicesTabWidget = widgets.VBoxWidget() tbarServices = QtWidgets.QToolBar() self.servicesTabWidget.addWidget(tbarServices) # ================ # Service CRUD tbg = widgets.ToolBarGroup(title=self.tr("Services")) tbarServices.addWidget(tbg) # Add Service self.addServiceBtn = QtWidgets.QToolButton(self.servicesTabWidget) self.addServiceBtn.setText(self.tr("Add new")) self.addServiceBtn.clicked.connect(self.addServiceBtnClicked) tbg.addWidget(self.addServiceBtn) # Remove Service self.delServiceBtn = QtWidgets.QToolButton(self.servicesTabWidget) self.delServiceBtn.setText(self.tr("Remove")) self.delServiceBtn.clicked.connect(self.delServiceBtnClicked) tbg.addWidget(self.delServiceBtn) tbarServices.addSeparator() # ================ # CSV tbg = widgets.ToolBarGroup(title=self.tr("CSV")) tbarServices.addWidget(tbg) # Export CSV self.exportServicesBtn = QtWidgets.QToolButton(self.servicesTabWidget) self.exportServicesBtn.setText(self.tr("Export")) self.exportServicesBtn.clicked.connect(self.exportServicesBtnClicked) tbg.addWidget(self.exportServicesBtn) # Import CSV self.importServicesBtn = QtWidgets.QToolButton(self.servicesTabWidget) self.importServicesBtn.setText(self.tr("Import")) self.importServicesBtn.clicked.connect(self.importServicesBtnClicked) tbg.addWidget(self.importServicesBtn) # Services Table self.servicesView = ts2.editor.views.ServicesEditorView( self.servicesTabWidget) self.servicesTabWidget.addWidget(self.servicesView) tbarServiceLines = QtWidgets.QToolBar() self.servicesTabWidget.addWidget(tbarServiceLines) tbg = widgets.ToolBarGroup() tbg.setTitle(self.tr("Lines")) tbarServiceLines.addWidget(tbg) # Append line button self.appendServiceLineBtn = QtWidgets.QToolButton( self.servicesTabWidget) self.appendServiceLineBtn.setText(self.tr("Append New")) self.appendServiceLineBtn.clicked.connect( self.appendServiceLineBtnClicked) tbg.addWidget(self.appendServiceLineBtn) # Insert line button self.insertServiceLineBtn = QtWidgets.QToolButton( self.servicesTabWidget) self.insertServiceLineBtn.setText(self.tr("Insert New")) self.insertServiceLineBtn.clicked.connect( self.insertServiceLineBtnClicked) tbg.addWidget(self.insertServiceLineBtn) # Delete line button self.deleteServiceLineBtn = QtWidgets.QToolButton( self.servicesTabWidget) self.deleteServiceLineBtn.setText(self.tr("Remove")) self.deleteServiceLineBtn.clicked.connect( self.delServiceLineBtnClicked) tbg.addWidget(self.deleteServiceLineBtn) # ServiceLines table self.serviceLinesView = ts2.editor.views.ServiceLinesEditorView( self.servicesTabWidget) self.serviceLinesView.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.serviceLinesView.setSelectionMode( QtWidgets.QAbstractItemView.SingleSelection) self.servicesTabWidget.addWidget(self.serviceLinesView) self.tabWidget.addTab(self.servicesTabWidget, self.tr("Services")) # =============================================================== # Train tab # =============================================================== trainsTab = QtWidgets.QWidget() self.setupTrainsBtn = QtWidgets.QPushButton( self.tr("Setup trains from services"), trainsTab) self.setupTrainsBtn.clicked.connect(self.setupTrainsBtnClicked) hgride = QtWidgets.QHBoxLayout() hgride.addWidget(self.setupTrainsBtn) hgride.addStretch() self.trainsGraphicsView = ts2.editor.views.TrainsGraphicsView( trainsTab) self.reverseTrainBtn = QtWidgets.QPushButton( self.tr("Reverse train direction"), trainsTab) self.reverseTrainBtn.clicked.connect(self.reverseTrainBtnClicked) hgridr = QtWidgets.QHBoxLayout() hgridr.addWidget(self.reverseTrainBtn) hgridr.addStretch() self.trainsView = ts2.editor.views.TrainsEditorView(trainsTab) self.addTrainBtn = QtWidgets.QPushButton(self.tr("Add new train"), trainsTab) self.addTrainBtn.clicked.connect(self.addTrainBtnClicked) self.delTrainBtn = QtWidgets.QPushButton(self.tr("Remove train"), trainsTab) self.delTrainBtn.clicked.connect(self.delTrainBtnClicked) hgrid = QtWidgets.QHBoxLayout() hgrid.addWidget(self.addTrainBtn) hgrid.addWidget(self.delTrainBtn) hgrid.addStretch() grid = QtWidgets.QVBoxLayout() grid.addLayout(hgride) grid.addWidget(self.trainsGraphicsView) grid.addLayout(hgridr) grid.addWidget(self.trainsView) grid.addLayout(hgrid) trainsTab.setLayout(grid) self.tabWidget.addTab(trainsTab, self.tr("Trains")) self.setCentralWidget(self.tabWidget) sbar = widgets.StatusBar() self.setStatusBar(sbar) settings.restoreWindow(self) self.onServiceViewSelectionChanged(None) self.onServiceLinesViewSelectionChanged() self.onTrainTypesSelectionChanged() if fileName: QtCore.QTimer.singleShot(100, self.onStartupTimeout)
def __init__(self, parent=None): super(StyleTestApp, self).__init__(parent) self.parent = parent self.setupUI(**cfg) # Set window flags and other Qt attributes self.setWindowFlags(QtCore.Qt.Window) # # Restore widget state # try: # self.ui.splitter.restoreState(self.settings.value("splitterSizes")) #.toByteArray()) # #self.ui.renderQueue_treeWidget.header().restoreState(self.settings.value("renderQueueView")) #.toByteArray()) # except: # pass # # Set up about dialog # about = lambda: self.about( # app_name=cfg['window_title'], # app_version="v" + VERSION, # description="Template for Qt GUI application written in Python.\nUses Qt.py for compatibility with all Python bindings.\n", # credits="Principal developer: Mike Bonnington") self.show() # Load and set stylesheet - workaround for bug in Qt 4.8 where some # styles not being applied (including QHeaderView / QTableView) if # stylesheet is loaded before ui is displayed. # self.stylesheet = cfg['stylesheet'] # self.loadStyleSheet() self.info() # Set icons self.ui.toolButton_10.setIcon(self.iconSet('folder.svg')) self.ui.toolButton_11.setIcon(self.iconSet('computer-symbolic.svg')) self.ui.toolButton_12.setIcon( self.iconSet('utilities-terminal-symbolic.svg')) self.ui.toolButton_13.setIcon(self.iconSet('refresh.svg')) self.ui.toolButton_14.setIcon(self.iconSet('add.svg')) self.ui.toolButton_15.setIcon(self.iconSet('edit.svg')) self.ui.toolButton_16.setIcon(self.iconSet('merge.svg')) self.ui.toolButton_17.setIcon(self.iconSet('clear.svg')) # Connect signals & slots self.ui.actionOpen_UI.triggered.connect(self.openUI) self.ui.actionOpen_Stylesheet.triggered.connect(self.openQSS) self.ui.actionSave_Stylesheet.triggered.connect(self.saveQSS) self.ui.actionAbout.triggered.connect(self.about_dialog) self.ui.actionQuit.triggered.connect(self.exit) self.ui.buttonBox.button( QtWidgets.QDialogButtonBox.Cancel).clicked.connect(self.exit) #self.ui.buttonBox.button(QtWidgets.QDialogButtonBox.Ok).clicked.connect(self.loadStyleSheet) self.ui.colorChooser_button.setStyleSheet( "QWidget { background-color: %s }" % self.col['highlight'].name()) self.ui.colorChooser_button.clicked.connect(self.setAccentColor) self.ui.uiBrightness_slider.setValue(self.col['window'].lightness()) self.ui.uiBrightness_slider.valueChanged.connect( lambda value: self.setUIBrightness(value)) #self.ui.reloadUI_pushButton.clicked.connect(self.loadUIFile) self.ui.reloadStylesheet_pushButton.clicked.connect( self.loadStyleSheet) self.ui.unloadStylesheet_pushButton.clicked.connect( self.unloadStyleSheet) self.ui.saveStylesheet_pushButton.clicked.connect(self.saveStyleSheet) self.ui.loadedUIs_tabWidget.tabCloseRequested.connect( lambda index: self.ui.loadedUIs_tabWidget.removeTab(index) ) # Allow tabs to be closed # Set up image thumbnail browser button self.ui.thumbnail_imageButton = imagebutton.ImageButton( max_size=[512, 288]) # self.ui.thumbnail_verticalLayout.insertWidget(0, self.ui.thumbnail_imageButton) self.ui.thumbnail_verticalLayout.addWidget( self.ui.thumbnail_imageButton) self.ui.thumbnail_lineEdit.hide() # self.ui.thumbnail_imageButton.clicked.connect(lambda: self.browse_file(self.ui.thumbnail_lineEdit, 'Image files (*.jpg *.png *.gif)')) self.ui.thumbnail_imageButton.imageChanged.connect( lambda imgpath: self.ui.thumbnail_lineEdit.setText(imgpath)) self.ui.thumbnail_lineEdit.textChanged.connect( lambda text: self.ui.thumbnail_imageButton.updateThumbnail(text)) # Add 'Sort by' separator label label = QtWidgets.QLabel("Sort by:") sortBy_separator = QtWidgets.QWidgetAction(self) sortBy_separator.setDefaultWidget(label) self.ui.menuEdit.insertAction(self.ui.actionName, sortBy_separator) # Make 'Sort by' actions mutually exclusive alignmentGroup = QtWidgets.QActionGroup(self) alignmentGroup.addAction(self.ui.actionName) alignmentGroup.addAction(self.ui.actionSize) alignmentGroup.addAction(self.ui.actionType) alignmentGroup.addAction(self.ui.actionDate) # Add 'Other' separator label label = QtWidgets.QLabel("Other:") other_separator = QtWidgets.QWidgetAction(self) other_separator.setDefaultWidget(label) other_separator.setEnabled(False) self.ui.menuEdit.insertAction(self.ui.actionAttribute, other_separator) # Make 'Other' actions mutually exclusive otherGroup = QtWidgets.QActionGroup(self) otherGroup.addAction(self.ui.actionAttribute) otherGroup.addAction(self.ui.actionObject)
def buildUI(self): self.sizeLabel = QtWidgets.QLabel() self.sizeLabel.setFrameStyle(QtWidgets.QFrame.StyledPanel | QtWidgets.QFrame.Sunken) status = self.statusBar() status.setSizeGripEnabled(False) status.addPermanentWidget(self.sizeLabel) status.showMessage("Ready", 5000) # menu fileNewAction = self.createAction("&New...", self.fileNew, QtGui.QKeySequence.New, "filenew", "Create an image file") fileOpenAction = self.createAction("&Open...", self.fileNew, QtGui.QKeySequence.Open, "fileopen", "Open an existing image file") fileSaveAction = self.createAction("&Save", self.fileNew, QtGui.QKeySequence.Save, "filesave", "Save the image") fileSaveAsAction = self.createAction("Save &As...", self.fileNew, icon="filesaveas", tip="Save the image using a new name") filePrintAction = self.createAction("&Print", self.fileNew, QtGui.QKeySequence.Print, "fileprint", "Print the image") fileQuitAction = self.createAction("&Quit", self.fileNew, "Ctrl+Q", "filequit", "Close the application") editInvertAction = self.createAction("&Invert", self.fileNew, "Ctrl+I", "editinvert", "Invert the image's colors", True, "toggled(bool)") editSwapRedAndBlueAction = self.createAction( "Sw&ap Red and Blue", self.fileNew, "Ctrl+A", "editswap", "Swap the image's red and blue color components", True, "toggled(bool)") editZoomAction = self.createAction("&Zoom...", self.fileNew, "Alt+Z", "editzoom", "Zoom the image") mirrorGroup = QtWidgets.QActionGroup(self) editUnMirrorAction = self.createAction("&Unmirror", self.setSizeMid, "Ctrl+U", "editunmirror", "Unmirror the image", True, "toggled(bool)") mirrorGroup.addAction(editUnMirrorAction) editMirrorHorizontalAction = self.createAction( "Mirror &Horizontally", self.setSizeBig, "Ctrl+H", "editmirrorhoriz", "Horizontally mirror the image", True, "toggled(bool)") mirrorGroup.addAction(editMirrorHorizontalAction) editMirrorVerticalAction = self.createAction( "Mirror &Vertically", self.setSizeSmall, "Ctrl+V", "editmirrorvert", "Vertically mirror the image", True, "toggled(bool)") mirrorGroup.addAction(editMirrorVerticalAction) editUnMirrorAction.setChecked(True) helpAboutAction = self.createAction("&About Image Changer", self.helpAbout) helpHelpAction = self.createAction("&Help", self.helpHelp, QtGui.QKeySequence.HelpContents) self.fileMenu = self.menuBar().addMenu("&File") self.fileMenuActions = (fileNewAction, fileOpenAction, fileSaveAction, fileSaveAsAction, None, filePrintAction, fileQuitAction) # self.fileMenu.aboutToShow.connect(self.updateFileMenu) editMenu = self.menuBar().addMenu("&Edit") self.addActions(editMenu, (editInvertAction, editSwapRedAndBlueAction, editZoomAction)) mirrorMenu = editMenu.addMenu(QtGui.QIcon(":/editmirror.png"), "&Mirror") self.addActions(mirrorMenu, (editUnMirrorAction, editMirrorHorizontalAction, editMirrorVerticalAction)) helpMenu = self.menuBar().addMenu("&Help") self.addActions(helpMenu, (helpAboutAction, helpHelpAction)) fileToolbar = self.addToolBar("File") fileToolbar.setObjectName("FileToolBar") self.addActions(fileToolbar, (fileNewAction, fileOpenAction, fileSaveAsAction)) editToolbar = self.addToolBar("Edit") editToolbar.setObjectName("EditToolBar") self.addActions(editToolbar, (editInvertAction, editSwapRedAndBlueAction, editUnMirrorAction, editMirrorVerticalAction, editMirrorHorizontalAction)) self.zoomSpinBox = QtWidgets.QSpinBox() self.zoomSpinBox.setRange(1, 400) self.zoomSpinBox.setSuffix(" %") self.zoomSpinBox.setValue(100) self.zoomSpinBox.setToolTip("Zoom the image") self.zoomSpinBox.setStatusTip(self.zoomSpinBox.toolTip()) self.zoomSpinBox.setFocusPolicy(QtCore.Qt.NoFocus) self.zoomSpinBox.valueChanged[int].connect(self.setPicSize) editToolbar.addWidget(self.zoomSpinBox) self.searchLineEdit = QtWidgets.QLineEdit() self.searchLineEdit.setPlaceholderText(u"搜索...") self.searchLineEdit.setToolTip("Searching") self.searchLineEdit.setMaximumWidth(200) self.searchLineEdit.returnPressed.connect(self.populate2) editToolbar.addWidget(self.searchLineEdit) # self.addActions(self.imageLabel, (editInvertAction, # editSwapRedAndBlueAction, editUnMirrorAction, # editMirrorVerticalAction, editMirrorHorizontalAction)) self.resetableActions = ((editInvertAction, False), (editSwapRedAndBlueAction, False), (editUnMirrorAction, True)) settings = QtCore.QSettings("MyCompany", "MyApp") self.recentFiles = settings.value("RecentFiles") self.restoreGeometry( QtCore.QByteArray(settings.value("MainWindow/Geometry"))) self.restoreState(QtCore.QByteArray(settings.value("MainWindow/State"))) # menu above mainSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal, self) self.tree = QtWidgets.QTreeWidget() # tree self.tree.setColumnCount(2) self.tree.setHeaderLabels([u'分类', '']) root = QtWidgets.QTreeWidgetItem(self.tree) root.setText(0, u'模型') # ---------------layer1_list layer1_list = [] search = "1" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: print i, "<<<<<<<<<<<<<<sql_info1" # print i[1] layre1_item = QtWidgets.QTreeWidgetItem(root, [i[1]], 0) layer1_list.append(layre1_item) name_test = i[1] # print name_test, type(name_test), 'name_test<<<<<<<<<<<<<<<<<<<<' self.sql_dict[name_test] = i[2] except: pass print len(layer1_list),"<<<layer1_list" # ---------- layer2_list = [] # search = "2" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: # print i[1] # 角色 layre2_item = QtWidgets.QTreeWidgetItem(layer1_list[0], [i[1]], 0) layer2_list.append(layre2_item) name_test = i[1] # print name_test, type(name_test), 'name_test<<<<<<<<<<<<<<<<<<<<' self.sql_dict[name_test] = i[2] except: pass # search = "3" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: # 道具 layre2_item = QtWidgets.QTreeWidgetItem(layer1_list[1], [i[1]], 0) layer2_list.append(layre2_item) name_test = i[1] self.sql_dict[name_test] = i[2] except: pass # search = "4" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: # 场景 layre2_item = QtWidgets.QTreeWidgetItem(layer1_list[2], [i[1]], 0) layer2_list.append(layre2_item) name_test = i[1] self.sql_dict[name_test] = i[2] except: pass # search = "7" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: # 动物 layre2_item = QtWidgets.QTreeWidgetItem(layer2_list[1], [i[1]], 0) # layer2_list.append(layre2_item) name_test = i[1] self.sql_dict[name_test] = i[2] except: pass # search = "9" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: # 城市 layre2_item = QtWidgets.QTreeWidgetItem(layer2_list[3], [i[1]], 0) # layer2_list.append(layre2_item) name_test = i[1] self.sql_dict[name_test] = i[2] except: pass # search = "10" inputfiled = "pid" try: sql_info = self.sql_back(search, inputfiled) except: print 'Error<<<<<<<<<<<<<<' print "cant get information" sql_info = None # (i['pid'], i['name'], i['id'], i['description']) try: for i in sql_info: # 自然 layer2_list[4] layre2_item = QtWidgets.QTreeWidgetItem(layer2_list[4], [i[1]], 0) # layer2_list.append(layre2_item) name_test = i[1] self.sql_dict[name_test] = i[2] except: pass # ------------------ self.tree.addTopLevelItem(root) self.tree.clicked.connect(self.on_treeview_clicked3) self.tree.setItemsExpandable(True) mainSplitter.addWidget(self.tree) rightSplitter = QtWidgets.QSplitter(QtCore.Qt.Vertical, mainSplitter) rightSplitter.setOpaqueResize(False) self.listWidget = ThumbListWidget(self) self.listWidget2 = ThumbListWidget(self) self.listWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.listWidget.customContextMenuRequested.connect(self.listItemRightClicked) self.listWidget.itemDoubleClicked.connect(self.openImage) self.listWidget2.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.listWidget2.customContextMenuRequested.connect(self.listItemRightClicked2) self.listWidget2.addfile.connect(self.ref_something) rightSplitter.addWidget(self.listWidget) rightSplitter.addWidget(self.listWidget2) size = 128 buffer = 12 self.listWidget.setViewMode(QtWidgets.QListWidget.IconMode) self.listWidget.setIconSize(QtCore.QSize(size, size)) self.listWidget.setResizeMode(QtWidgets.QListWidget.Adjust) self.listWidget.setGridSize(QtCore.QSize(size + buffer, size + buffer)) self.listWidget.setDragEnabled(True) self.listWidget.itemClicked .connect(self.info_populate) self.listWidget2.setIconSize(QtCore.QSize(size, size)) self.listWidget2.setResizeMode(QtWidgets.QListWidget.Adjust) self.listWidget2.setGridSize(QtCore.QSize(size + buffer, size + buffer)) self.listWidget2.setDragEnabled(True) mainSplitter.setStretchFactor(1, 20) rightSplitter.setStretchFactor(0, 5) self.setCentralWidget(mainSplitter) # 停靠窗口 1 dock4=QtWidgets.QDockWidget((u"上传"),self) dock4.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) # dock4.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) te1=upload.UpLoad() dock4.setWidget(te1) self.addDockWidget(QtCore.Qt.RightDockWidgetArea,dock4) # 停靠窗口 4 dock1=QtWidgets.QDockWidget((u"详细信息"),self) dock1.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable) dock1.setAllowedAreas(QtCore.Qt.LeftDockWidgetArea|QtCore.Qt.RightDockWidgetArea) self.info_label = QtWidgets.QLabel((u"NULL")) dock1.setWidget(self.info_label) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, dock1) # 停靠窗口 2 dock2=QtWidgets.QDockWidget((u"截图"),self) dock2.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) # dock2.setFeatures(QtWidgets.QDockWidget.DockWidgetFloatable|QtWidgets.QDockWidget.DockWidgetClosable) # dock2.setTitleBarWidget() # te2=controllerLibraryte.showUI() # te2=QtWidgets.QTextEdit() te2 = screenshots.Screenshot() dock2.setWidget(te2) self.addDockWidget(QtCore.Qt.RightDockWidgetArea,dock2) # 停靠窗口 3 # dock3=QtWidgets.QDockWidget((u"停靠窗口 3"),self) # dock3.setFeatures(QtWidgets.QDockWidget.AllDockWidgetFeatures) # te3=QtWidgets.QTextEdit((u"窗口 3,可在 Main Window 任意位置停靠,可浮动,可关闭")) # dock3.setWidget(te3) # self.addDockWidget(QtCore.Qt.BottomDockWidgetArea,dock3) # dock4 和dock1 合并 self.tabifyDockWidget(dock4, dock1)
def addMenuBarContents(self, menubar): # File Menu file_menu = QtWidgets.QMenu('File', menubar) # New Collection label = 'New Collection' tooltip = 'Create a new Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createNewCollectionNodeCB)) file_menu.addAction(action) # Rename Collection label = 'Rename Collection' tooltip = 'Rename a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.renameCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Remove Collection label = 'Remove Collection' tooltip = 'Remove a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.removeCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Close Window label = 'Close Window' tooltip = 'Close the mmSolver window.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.close)) file_menu.addAction(action) menubar.addMenu(file_menu) # Edit Menu edit_menu = QtWidgets.QMenu('Edit', menubar) # Refresh Viewport During Solve label = 'Refresh Viewport' tooltip = 'Refresh the viewport while Solving.' refresh_value = lib_state.get_refresh_viewport_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(refresh_value) action.toggled.connect(type(self).refreshActionToggledCB) edit_menu.addAction(action) # Force DG evaluation. label = 'Force DG Update' tooltip = 'Force Maya DG Evaluation while solving.' force_dg_update_value = lib_state.get_force_dg_update_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(force_dg_update_value) action.toggled.connect(type(self).forceDgUpdateActionToggledCB) edit_menu.addAction(action) menubar.addMenu(edit_menu) # View Menu view_menu = QtWidgets.QMenu('View', menubar) # Display Object Weight label = 'Display Object Weight Column' tooltip = 'Display Object weight column' value = lib_state.get_display_object_weight_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect(self.subForm.displayObjectWeightColumnChanged) view_menu.addAction(action) # Display Object Deviation label = 'Display Object Frame Deviation' tooltip = 'Display per-frame deviation for each Marker/Camera.' value = lib_state.get_display_object_frame_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.displayObjectFrameDeviationColumnChanged) view_menu.addAction(action) # Display Object Deviation label = 'Display Object Average Deviation' tooltip = 'Display deviation column' value = lib_state.get_display_object_average_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.displayObjectAverageDeviationColumnChanged) view_menu.addAction(action) # Display Object Deviation label = 'Display Object Maximum Deviation' tooltip = 'Display deviation column' value = lib_state.get_display_object_maximum_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.displayObjectMaximumDeviationColumnChanged) view_menu.addAction(action) view_menu.addSeparator() # Display Attribute State label = 'Display Attribute State' tooltip = 'Display Attribute State column' value = lib_state.get_display_attribute_state_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect(self.subForm.displayAttributeStateColumnChanged) view_menu.addAction(action) # Display Attribute Min/Max label = 'Display Attribute Min/Max' tooltip = 'Display Attribute Minimum and Maximum columns' value = lib_state.get_display_attribute_min_max_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.displayAttributeMinMaxColumnChanged) view_menu.addAction(action) view_menu.addSeparator() # Display the Image Planes while solving. label = 'Display Image Planes (while solving)' tooltip = 'Display Image Planes while solving.' value = lib_state.get_display_image_plane_while_solving_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( type(self).displayImagePlaneWhileSolvingActionToggledCB) view_menu.addAction(action) # Isolate Objects while solving label = 'Isolate Objects (while solving)' tooltip = 'Isolate visibility of all Markers and Bundles while solving.' value = lib_state.get_display_image_plane_while_solving_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( type(self).isolateObjectWhileSolvingActionToggledCB) view_menu.addAction(action) menubar.addMenu(view_menu) # Tools Menu tools_menu = QtWidgets.QMenu('Tools', menubar) # Create Marker label = 'Create Marker' tooltip = 'Create Markers on the selected camera.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createMarkerCB)) tools_menu.addAction(action) # Convert to Marker label = 'Convert to Marker' tooltip = 'Convert the selection to Markers.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.convertToMarkerCB)) tools_menu.addAction(action) # Load Markers label = 'Load Markers...' tooltip = 'Load Markers from a file.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.loadMarkerCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Create Bundle label = 'Create Bundle' tooltip = 'Create a default Bundle node.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createBundleCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Link Marker + Bundle label = 'Link Marker + Bundle' tooltip = 'Link the selected Marker and Bundle together.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.linkMarkerBundleCB)) tools_menu.addAction(action) # Unlink Marker from all Bundles label = 'Unlink Marker from all Bundles' tooltip = 'Unlink all selected Markers from their Bundle.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.unlinkMarkerBundleCB)) tools_menu.addAction(action) tools_menu.addSeparator() # Toogle Marker / Bundle selection label = 'Toggle Marker / Bundle' tooltip = 'Select connected Markers, or Bundles.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.toggleMarkerBundleSelectionCB)) tools_menu.addAction(action) # Select Marker / Bundle label = 'Select Marker + Bundle' tooltip = 'Select the connected Markers and Bundles.' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.selectBothMarkersAndBundlesCB)) tools_menu.addAction(action) # Rename Marker + Bundle label = 'Rename Markers + Bundles' tooltip = 'Rename the selected Markers and Bundles;' action = QtWidgets.QAction(label, tools_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.renameMarkerBundleCB)) tools_menu.addAction(action) menubar.addMenu(tools_menu) # Log Menu # This menu depicts a radio button allowing the user to choose # how much information is returned to the console (the logging # level). log_menu = QtWidgets.QMenu('Log', menubar) # Errors label = 'Errors' tooltip = 'Send Errors to the log.' logErrorAction = QtWidgets.QAction(label, log_menu) logErrorAction.setStatusTip(tooltip) logErrorAction.setCheckable(True) logErrorAction.triggered.connect(partial(self.logErrorCB)) log_menu.addAction(logErrorAction) # Warnings label = 'Warnings' tooltip = 'Send Warnings to the log.' logWarningAction = QtWidgets.QAction(label, log_menu) logWarningAction.setStatusTip(tooltip) logWarningAction.setCheckable(True) logWarningAction.triggered.connect(partial(self.logWarningCB)) log_menu.addAction(logWarningAction) # Information label = 'Info' tooltip = 'Send Information to the log.' logInfoAction = QtWidgets.QAction(label, log_menu) logInfoAction.setStatusTip(tooltip) logInfoAction.setCheckable(True) logInfoAction.triggered.connect(partial(self.logInfoCB)) log_menu.addAction(logInfoAction) # Verbose label = 'Verbose' tooltip = 'Send Verboses to the log.' logVerboseAction = QtWidgets.QAction(label, log_menu) logVerboseAction.setStatusTip(tooltip) logVerboseAction.setCheckable(True) logVerboseAction.triggered.connect(partial(self.logVerboseCB)) log_menu.addAction(logVerboseAction) # Debug label = 'Debug' tooltip = 'Send Debug messages to the log.' logDebugAction = QtWidgets.QAction(label, log_menu) logDebugAction.setStatusTip(tooltip) logDebugAction.setCheckable(True) logDebugAction.triggered.connect(partial(self.logDebugCB)) log_menu.addAction(logDebugAction) # 'Radio' button for logging levels log_actionGroup = QtWidgets.QActionGroup(log_menu) log_actionGroup.addAction(logErrorAction) log_actionGroup.addAction(logWarningAction) log_actionGroup.addAction(logInfoAction) log_actionGroup.addAction(logVerboseAction) log_actionGroup.addAction(logDebugAction) log_level = lib_state.get_log_level() if log_level == const.LOG_LEVEL_ERROR: logErrorAction.setChecked(True) elif log_level == const.LOG_LEVEL_WARNING: logWarningAction.setChecked(True) elif log_level == const.LOG_LEVEL_INFO: logInfoAction.setChecked(True) elif log_level == const.LOG_LEVEL_VERBOSE: logVerboseAction.setChecked(True) elif log_level == const.LOG_LEVEL_DEBUG: logDebugAction.setChecked(True) else: LOG.warning('Invalid log level given: %r' % log_level) menubar.addMenu(log_menu) # Help Menu help_menu = QtWidgets.QMenu('Help', menubar) # Launch Help label = 'Help...' tooltip = 'Show help.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchHelpCB)) help_menu.addAction(action) # Launch System Info window. label = 'System Information...' tooltip = 'Display detailed information about software and hardware.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchSysInfoCB)) help_menu.addAction(action) # Launch About label = 'About mmSolver...' tooltip = 'About this software.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchAboutCB)) help_menu.addAction(action) menubar.addMenu(help_menu) return
def addMenuBarContents(self, menubar): # File Menu file_menu = QtWidgets.QMenu('File', menubar) # New Collection label = 'New Collection' tooltip = 'Create a new Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.createNewCollectionNodeCB)) file_menu.addAction(action) # Rename Collection label = 'Rename Collection' tooltip = 'Rename a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.renameCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Remove Collection label = 'Remove Collection' tooltip = 'Remove a Collection node.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.removeCollectionNodeCB)) file_menu.addAction(action) file_menu.addSeparator() # Close Window label = 'Close Window' tooltip = 'Close the mmSolver window.' action = QtWidgets.QAction(label, file_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.close)) file_menu.addAction(action) menubar.addMenu(file_menu) # Edit Menu edit_menu = QtWidgets.QMenu('Edit', menubar) edit_menu.setTearOffEnabled(True) if Qt.IsPySide2 or Qt.IsPyQt5: edit_menu.addSection('Undo / Redo') # Undo label = 'Undo (without UI update)' tooltip = ('Undo the Maya scene state, ' 'without updating the viewport or solver UI') action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.triggered.connect(self.undoTriggeredCB) edit_menu.addAction(action) # Redo label = 'Redo (without UI update)' tooltip = ('Redo the Maya scene state, ' 'without updating the viewport or solver UI') action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.triggered.connect(self.redoTriggeredCB) edit_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: edit_menu.addSection('Window Update') # Auto Update Solver Validation label = 'Auto-Update Solver Validation' tooltip = 'Auto-update details of the solver parameter/error numbers.' value = lib_state.get_auto_update_solver_validation_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.solver_settings.autoUpdateSolverValidationChanged) edit_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: edit_menu.addSection('Solver Execution') # Pre-Solve Force Evaluation label = 'Pre-Solve Force Evaluation' tooltip = ('Before starting a solve, ' 'update the scene to force an evaluation.') pre_solve_force_eval = lib_state.get_pre_solve_force_eval_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(pre_solve_force_eval) action.toggled.connect(type(self).preSolveForceEvalActionToggledCB) edit_menu.addAction(action) # Refresh Viewport During Solve label = 'Refresh Viewport' tooltip = 'Refresh the viewport while Solving.' refresh_value = lib_state.get_refresh_viewport_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(refresh_value) action.toggled.connect(type(self).refreshActionToggledCB) edit_menu.addAction(action) # Force DG evaluation. label = 'Force DG Update' tooltip = 'Force Maya DG Evaluation while solving.' force_dg_update_value = lib_state.get_force_dg_update_state() action = QtWidgets.QAction(label, edit_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(force_dg_update_value) action.toggled.connect(type(self).forceDgUpdateActionToggledCB) edit_menu.addAction(action) menubar.addMenu(edit_menu) # View Menu view_menu = QtWidgets.QMenu('View', menubar) view_menu.setTearOffEnabled(True) if Qt.IsPySide2 or Qt.IsPyQt5: view_menu.addSection('Input Object Display') # Display Object Weight label = 'Weight Column' tooltip = 'Display Object weight column' value = lib_state.get_display_object_weight_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayWeightColumnChanged) view_menu.addAction(action) # Display Object Frame Deviation label = 'Frame Deviation' tooltip = 'Display per-frame deviation for each Marker/Camera.' value = lib_state.get_display_object_frame_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayFrameDeviationColumnChanged) view_menu.addAction(action) # Display Object Average Deviation label = 'Average Deviation' tooltip = 'Display average deviation column' value = lib_state.get_display_object_average_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayAverageDeviationColumnChanged) view_menu.addAction(action) # Display Object Maximum Deviation label = 'Maximum Deviation' tooltip = 'Display maximum deviation column' value = lib_state.get_display_object_maximum_deviation_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.object_browser.displayMaximumDeviationColumnChanged) view_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: view_menu.addSection('Output Attribute Display') # Display Attribute State label = 'Display Attribute State' tooltip = 'Display Attribute State column' value = lib_state.get_display_attribute_state_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.attribute_browser.displayStateColumnChanged) view_menu.addAction(action) # Display Attribute Min/Max label = 'Display Attribute Min/Max' tooltip = 'Display Attribute Minimum and Maximum columns' value = lib_state.get_display_attribute_min_max_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( self.subForm.attribute_browser.displayMinMaxColumnChanged) view_menu.addAction(action) if Qt.IsPySide2 or Qt.IsPyQt5: view_menu.addSection('During Solve') # Display the Image Planes while solving. # # TODO: Add other object types to show/hide while solving, # such as camera, nurbsCurves, nurbsSurfaces, and locators. label = 'Display Image Planes' tooltip = 'Display Image Planes while solving.' value = lib_state.get_display_image_plane_while_solving_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( type(self).displayImagePlaneWhileSolvingActionToggledCB) view_menu.addAction(action) # Display the Meshes while solving. label = 'Display Meshes' tooltip = 'Display Meshes while solving.' value = lib_state.get_display_meshes_while_solving_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(value) action.toggled.connect( type(self).displayMeshesWhileSolvingActionToggledCB) view_menu.addAction(action) # Isolate Objects while solving label = 'Isolate Objects' tooltip = 'Isolate visibility of all Markers and Bundles while solving.' isolate_value = lib_state.get_isolate_object_while_solving_state() action = QtWidgets.QAction(label, view_menu) action.setStatusTip(tooltip) action.setCheckable(True) action.setChecked(isolate_value) action.toggled.connect( type(self).isolateObjectWhileSolvingActionToggledCB) view_menu.addAction(action) menubar.addMenu(view_menu) # Log Menu # This menu depicts a radio button allowing the user to choose # how much information is returned to the console (the logging # level). log_menu = QtWidgets.QMenu('Log', menubar) # Errors label = 'Errors' tooltip = 'Send Errors to the log.' logErrorAction = QtWidgets.QAction(label, log_menu) logErrorAction.setStatusTip(tooltip) logErrorAction.setCheckable(True) logErrorAction.triggered.connect(partial(self.logErrorCB)) log_menu.addAction(logErrorAction) # Warnings label = 'Warnings' tooltip = 'Send Warnings to the log.' logWarningAction = QtWidgets.QAction(label, log_menu) logWarningAction.setStatusTip(tooltip) logWarningAction.setCheckable(True) logWarningAction.triggered.connect(partial(self.logWarningCB)) log_menu.addAction(logWarningAction) # Information label = 'Info' tooltip = 'Send Information to the log.' logInfoAction = QtWidgets.QAction(label, log_menu) logInfoAction.setStatusTip(tooltip) logInfoAction.setCheckable(True) logInfoAction.triggered.connect(partial(self.logInfoCB)) log_menu.addAction(logInfoAction) # Verbose label = 'Verbose' tooltip = 'Send Verboses to the log.' logVerboseAction = QtWidgets.QAction(label, log_menu) logVerboseAction.setStatusTip(tooltip) logVerboseAction.setCheckable(True) logVerboseAction.triggered.connect(partial(self.logVerboseCB)) log_menu.addAction(logVerboseAction) # Debug label = 'Debug' tooltip = 'Send Debug messages to the log.' logDebugAction = QtWidgets.QAction(label, log_menu) logDebugAction.setStatusTip(tooltip) logDebugAction.setCheckable(True) logDebugAction.triggered.connect(partial(self.logDebugCB)) log_menu.addAction(logDebugAction) # 'Radio' button for logging levels log_actionGroup = QtWidgets.QActionGroup(log_menu) log_actionGroup.addAction(logErrorAction) log_actionGroup.addAction(logWarningAction) log_actionGroup.addAction(logInfoAction) log_actionGroup.addAction(logVerboseAction) log_actionGroup.addAction(logDebugAction) log_level = lib_state.get_log_level() if log_level == const.LOG_LEVEL_ERROR: logErrorAction.setChecked(True) elif log_level == const.LOG_LEVEL_WARNING: logWarningAction.setChecked(True) elif log_level == const.LOG_LEVEL_INFO: logInfoAction.setChecked(True) elif log_level == const.LOG_LEVEL_VERBOSE: logVerboseAction.setChecked(True) elif log_level == const.LOG_LEVEL_DEBUG: logDebugAction.setChecked(True) else: LOG.warning('Invalid log level given: %r' % log_level) menubar.addMenu(log_menu) # Help Menu help_menu = QtWidgets.QMenu('Help', menubar) # Launch Help label = 'Help...' tooltip = 'Show help.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchHelpCB)) help_menu.addAction(action) # Launch System Info window. label = 'System Information...' tooltip = 'Display detailed information about software and hardware.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchSysInfoCB)) help_menu.addAction(action) # Launch About label = 'About mmSolver...' tooltip = 'About this software.' action = QtWidgets.QAction(label, help_menu) action.setStatusTip(tooltip) action.triggered.connect(partial(self.launchAboutCB)) help_menu.addAction(action) menubar.addMenu(help_menu) return
def __initialize(self): ## force reload b = blockManager.BlockManager() b.reload() self.setObjectName(const.ObjectName) centeral = QtWidgets.QWidget() main_layout = QtWidgets.QVBoxLayout() self.setCentralWidget(centeral) centeral.setLayout(main_layout) # tabs self.__editor_tabs = QtWidgets.QTabWidget() self.__graph_tabs = QtWidgets.QTabWidget() self.__graph_tabs.setTabsClosable(True) # scene graph ## TODO : USE __new() self.__graph = graph.Graph(name=const.RootBoxName, parent=self, isTop=True) self.__graph_tabs.addTab(self.__graph, "Scene") self.__graph_tabs.tabBar().tabButton( 0, QtWidgets.QTabBar.RightSide).hide() self.__networks[self.__graph.box()] = { "graph": self.__graph, "init": False } # editor tabs self.__parm_editor = paramEditor.ParamEditor() self.__packet_history = packetHistory.PacketHistory() self.__log_viewer = logViewer.LogViewer() self.__editor_tabs.addTab(self.__parm_editor, "Param Editor") self.__editor_tabs.addTab(self.__packet_history, "Packet History") self.__editor_tabs.addTab(self.__log_viewer, "Log") main_contents = QtWidgets.QSplitter() main_contents.addWidget(self.__graph_tabs) main_contents.addWidget(self.__editor_tabs) # scene state self.__scene_state = sceneState.SceneState() main_layout.addWidget(main_contents) main_layout.addWidget(self.__scene_state) self.__resetTabIndice() # menu menubar = self.menuBar() file_menu = QtWidgets.QMenu("&File", self) news_action = file_menu.addAction("&New Scene") news_action.setShortcut(QtGui.QKeySequence("Ctrl+N")) open_action = file_menu.addAction("&Open") open_action.setShortcut(QtGui.QKeySequence("Ctrl+O")) save_action = file_menu.addAction("Save") save_action.setShortcut(QtGui.QKeySequence("Ctrl+S")) save_as_action = file_menu.addAction("Save As") save_as_action.setShortcut(QtGui.QKeySequence("Ctrl+Shift+S")) import_action = file_menu.addAction("&Import") import_action.setShortcut(QtGui.QKeySequence("Ctrl+I")) file_menu.addAction(news_action) file_menu.addSeparator() file_menu.addAction(open_action) file_menu.addSeparator() file_menu.addAction(save_action) file_menu.addAction(save_as_action) file_menu.addSeparator() file_menu.addAction(import_action) news_action.triggered.connect(self.__new) save_action.triggered.connect(self.__save) save_as_action.triggered.connect(self.__saveAs) open_action.triggered.connect(self.__open) import_action.triggered.connect(self.__importBox) menubar.addMenu(file_menu) process_menu = QtWidgets.QMenu("&Blocks", self) run_action = process_menu.addAction("&Execute") run_action.setShortcut(QtGui.QKeySequence("F5")) menubar.addMenu(process_menu) setting_menu = QtWidgets.QMenu("Log", self) log_group = QtWidgets.QActionGroup(self) log_group.setExclusive(True) no_log = setting_menu.addAction("No Log") error_log = setting_menu.addAction("Error") warn_log = setting_menu.addAction("Warning") debug_log = setting_menu.addAction("Debug") no_log.setCheckable(True) error_log.setCheckable(True) warn_log.setCheckable(True) debug_log.setCheckable(True) log_group.addAction(no_log) log_group.addAction(error_log) log_group.addAction(warn_log) log_group.addAction(debug_log) error_log.setChecked(True) no_log.triggered.connect(self.__noLogTriggered) error_log.triggered.connect(self.__errorLogTriggered) warn_log.triggered.connect(self.__warnLogTriggered) debug_log.triggered.connect(self.__debugLogTriggered) menubar.addMenu(setting_menu) ## progress self.__progress = progress.Progress(self) self.__progress.hide() run_action.triggered.connect(self.__runTriggered) self.__graph_tabs.tabCloseRequested.connect(self.__closeGraphRequest) self.__graph_tabs.currentChanged.connect(self.__currentGraphTabChanged) self.__parm_editor.BlockRenamed.connect(self.__blockRenamed) self.__graph.CurrentNodeChanged.connect(self.__currentBlockChanged) self.__graph.ItemDobleClicked.connect(self.__showGraphTab) self.__graph.BoxDeleted.connect(self.__boxDeleted) self.__graph.BoxCreated.connect(self.__boxCreated) self.__setPath(None)