def __init__(self): super(CircuitsEditors, self).__init__() self.setLayout(QVBoxLayout()) self.tabs = QTabWidget() self.layout().addWidget(self.tabs) self.tabs.addTab(Welcome(), tr("Witaj!")) self.tabs.addTab(QtCircuitCanvas(), tr("Przykład płótno!"))
def __init__(self): super(Welcome, self).__init__() self.setLayout(QGridLayout()) lbl = QLabel(tr("Witamy w przyjaznej aplikacji " "do rysowania schematow elektrycznych.")) self.layout().addWidget(lbl, 0, 0) self.web = QWebEngineView() self.layout().addWidget(self.web, 2, 0) start = tr("start.html") startFile = f"{os.path.dirname(os.path.realpath(__file__))}/{start}" self.web.load(QUrl(f"file:{startFile}"))
def create_menu(mw, actions): mainbar = mw.menuBar() # mFile = QMenu(tr("Plik"), mainbar) # mainbar.addMenu(mFile) mFile = mainbar.addMenu(tr("Plik")) mFile.addAction(actions.actions.get("create-circuit")) mFile.addAction(actions.actions.get("create-round")) mFile.addAction(actions.actions.get("close-app")) mFile2 = mainbar.addMenu(tr("Jezyk")) mFile2.addAction(actions.actions.get("polski")) mFile2.addAction(actions.actions.get("english"))
def create_menu(mw, actions): mainbar = mw.menuBar() # mFile = QMenu(tr("Plik"), mainbar) # mainbar.addMenu(mFile) mFile = mainbar.addMenu(tr("Plik")) mFile.addAction(actions.actions.get("create-circuit")) mFile.addAction(actions.actions.get("close-app"))
def __init__(self): super(QNewCircuitDialog, self).__init__() self.setWindowTitle("Utwórz nowy schemat") w = QWidget(self) w.setContentsMargins(0, 0, 0, 0) self.setCentralWidget(w) lay = QGridLayout() w.setLayout(lay) lay.addWidget(QLabel("Nazwa schematu"), 0, 0) self.txtName = QLineEdit() lay.addWidget(self.txtName, 0, 1) lv = QHBoxLayout() lay.addLayout(lv, 1, 1) lv.addStretch() cmdAdd = QPushButton(tr("Dodaj")) cmdAdd.clicked.connect(self.on_add) lv.addWidget(cmdAdd) cmdCancel = QPushButton(tr("Anuluj")) cmdCancel.clicked.connect(self.on_cancel) lv.addWidget(cmdCancel)
def __init__(self): self.actions = {} self.actions["create-circuit"] = CircuitCreateAction() self.actions["close-app"] = QAction(tr("Zamknij")) self.actions["close-app"].triggered.connect(self.on_close)
def __init__(self, *__args): super().__init__(tr("Nowy schemat")) self.triggered.connect(self.on_create)
def on_add(self): if len(self.txtName.text()) == 0: self.error( tr("Proszę podać nazwę schematu, lub użyć komendy Anuluj.")) else: self.accept()
def on_create(self): round_tab = CircuitsEditors.tabs() round_tab.addTab(QtCircuitRound(), tr("Kolo"))
def __init__(self, *__args): super().__init__(tr("Dodaj kolo")) self.triggered.connect(self.on_create)
def __init__(self): super(CircuitsLists, self).__init__() self.setLayout(QVBoxLayout()) self.list = QListWidget() self.layout().addWidget(self.list) self.list.addItem(tr("(Kliknij dodaj nowy)"))
# mFile = QMenu(tr("Plik"), mainbar) # mainbar.addMenu(mFile) mFile = mainbar.addMenu(tr("Plik")) mFile.addAction(actions.actions.get("create-circuit")) mFile.addAction(actions.actions.get("create-round")) mFile.addAction(actions.actions.get("close-app")) mFile2 = mainbar.addMenu(tr("Jezyk")) mFile2.addAction(actions.actions.get("polski")) mFile2.addAction(actions.actions.get("english")) # app = QApplication([]) translator = QTranslator() app = cirapp.init(translator) translator.load(QLocale(), "qtcircuits", "_", os.path.dirname(os.path.realpath(__file__))) print(app.installTranslator(translator)) mw = QMainWindow() mw.setWindowTitle(tr("QtCircuit (C) PW GUI Course (Step 1)")) dockList = QDockWidget(tr("Lista projektow"), mw) mw.addDockWidget(Qt.LeftDockWidgetArea, dockList) dockList.setWidget(CircuitsLists()) mw.setCentralWidget(CircuitsEditors()) actions = CircuitsActions() create_menu(mw, actions) mw.show() app.exec_()