def run(self): app = QApplication(sys.argv) w = QMainWindow() w.resize(700, 700) w.move(400, 0) w.setWindowTitle('Simple') w.show() w.isDrawMode = self.isDrawMode w.fileMenu = w.menuBar().addMenu("&File") w.fileSaveMenuItem = SfAction("&Save", w, shortcut="CTRL+S", tip="Save current scenario") w.fileSaveMenuItem.triggered.connect(self.fileSave) w.fileMenu.addAction(w.fileSaveMenuItem) w.fileMenu.addAction(SfAction("&Quit", w, slot=self.fileQuit(), shortcut="ALT+F4", tip="Quit SimFrames")) w.toolbar = w.addToolBar("Activities Toolbar") w.toolbar.setObjectName("ActivitiesToolbar") playActionsGroup = QActionGroup(w) w.toolbar.addAction(SfAction("&Play", w, "play.png", self.play, "CTRL+P", "Start the project", True, actionGroup=playActionsGroup )) w.toolbar.addAction(SfAction("&Stop", w, "stop.png", self.stop, "CTRL+F", "Stop executing", True, actionGroup=playActionsGroup, checked=True )) w.toolbar.addAction(SfSeparator(w)) self.mouseModeGroup = QActionGroup(w) w.toolbar.addAction(SfAction("&Move", self.mouseModeGroup, "moveMode.png", shortcut="CTRL+M", tip="Turn on mode to move components around canvas", checkable=True, checked=True)) self.drawAction = SfAction("&Draw", self.mouseModeGroup, "connectMode.png", shortcut="CTRL+D", tip="Turn on mode to connect components in canvas", checkable=True) w.toolbar.addAction(self.drawAction) w.toolbar.addAction(SfSeparator(w)) w.accordion = SfAccordion() functions = SfAccordionSection("Functions") functions.addComponents([SfComponent("add.png",), SfComponent("minus.png"), SfComponent("multiplication.png")]) inputSection = SfAccordionSection("Input") inputSection.addComponents([SfComponent("scale.png", ), SfComponent("square.png"), SfComponent("constant.png" )]) outputSection = SfAccordionSection("Output") outputSection.addComponents([SfComponent("txt.png", ), SfComponent("graph.png", )]) w.accordion.addSections([functions, inputSection, outputSection]) scene = SfGraphicsScene(w) self.canvas = SfGraphicsView(scene) scene.sceneRectChanged.connect(self.canvas.updateSceneRect) centralWidget = QWidget() mainLayout = QBoxLayout(QBoxLayout.LeftToRight, centralWidget) mainLayout.addWidget(w.accordion) mainLayout.addWidget(self.canvas) centralWidget.setLayout(mainLayout) w.setCentralWidget(centralWidget) w.quitAction = SfAction("&Quit", w, slot=self.fileQuit(), shortcut="ALT+F4", tip="Quit SimFrames") app.exec_()
def setup_win(self, layout): win = QMainWindow() self.__window = win win.setLayout(layout) win.resize(250, 150) win.move(300, 300) win.setWindowTitle(Application.title) win.statusBar().showMessage("Ready") win.show() widget = QWidget() self.__parent_widget = widget widget.setLayout(layout) win.setCentralWidget(widget)
from sys import argv from sys import exit if __name__ == "__main__": # The following command allows the user to kill the app with crtl-c. signal(SIGINT, SIG_DFL) # Creating the Gui app = QApplication(argv) main_window = QMainWindow() screen = QDesktopWidget().screenGeometry(1) ui = Ui_Booklet() ui.setupUi(main_window) # Adjusting to the middle of the screen. main_window.move(screen.center() - main_window.frameGeometry().center()) viewer = BookletViewer(ui) # Connecting Signals and Slots. ui.actionOpen.triggered.connect(viewer.open_pdf) ui.actionSave.triggered.connect(viewer.save_pdf) ui.actionPrint.triggered.connect(viewer.print_pdf) ui.actionAbout.triggered.connect(viewer.open_about) ui.actionFirst.triggered.connect(viewer.go_first) ui.actionNext.triggered.connect(viewer.go_next) ui.actionPrevious.triggered.connect(viewer.go_previous) ui.actionLast.triggered.connect(viewer.go_last) # Running the Application. main_window.resizeEvent = viewer.onResize main_window.show()