def nextButtonClicked(self): '''Called when the 'Next' or 'Finish' buttons are pressed''' currIndex = self.cardstack.currentIndex() currCard = self.cardPanels[ currIndex] # TODO: or get this direct from self.cardstack? if currCard.finish(): # Tab was successful, so we can go forward try: # prepare the coming tab, if necessary self.cardPanels[currIndex + 1].prepare() self.cardPanels[currIndex + 1].redrawLabels() self.cardstack.setCurrentIndex(currIndex + 1) self.enableButtons(self.cardPanels[currIndex + 1]) except IndexError: # we've gone past the end of the wizard, time to quit # Launch Murmeli self.murmeliWindow = MainWindow() self.murmeliWindow.show() # close this wizard but keep Tor, Db running self.close()
def nextButtonClicked(self): '''Called when the 'Next' or 'Finish' buttons are pressed''' currIndex = self.cardstack.currentIndex() currCard = self.cardPanels[currIndex] # TODO: or get this direct from self.cardstack? if currCard.finish(): # Tab was successful, so we can go forward try: # prepare the coming tab, if necessary self.cardPanels[currIndex + 1].prepare() self.cardPanels[currIndex + 1].redrawLabels() self.cardstack.setCurrentIndex(currIndex + 1) self.enableButtons(self.cardPanels[currIndex + 1]) except IndexError: # we've gone past the end of the wizard, time to quit # Launch Murmeli self.murmeliWindow = MainWindow() self.murmeliWindow.show() # close this wizard but keep Tor, Mongo running self.close()
class StartupWizard(QtGui.QMainWindow): '''Class to act as the main startup wizard using Qt''' def __init__(self, *args): '''Constructor''' QtGui.QMainWindow.__init__(*(self,) + args) self.setWindowTitle(I18nManager.getText("startupwizard.title")) # main pane with the stack and the button panel mainpane = QtGui.QWidget(self) mainlayout = QtGui.QVBoxLayout() mainpane.setLayout(mainlayout) self.setCentralWidget(mainpane) self.cardstack = QtGui.QStackedWidget(mainpane) self.cardPanels = [IntroPanel(), DependenciesPanel(), PathsPanel(), ServicesPanel(), \ KeygenPanel(), FinishedPanel()] for card in self.cardPanels: panel = card.getPanel() self.cardstack.addWidget(panel) self.connect(panel, QtCore.SIGNAL("redrawNavButtons()"), self.redrawButtons) # button panel at the bottom buttonPanel = QtGui.QFrame(self.cardstack) buttonPanel.setFrameStyle(QtGui.QFrame.Box + QtGui.QFrame.Sunken) self.backButton = QtGui.QPushButton(I18nManager.getText("button.exit")) self.nextButton = QtGui.QPushButton(I18nManager.getText("button.next")) layout = QtGui.QHBoxLayout() layout.addWidget(self.backButton) layout.addStretch(1) layout.addWidget(self.nextButton) buttonPanel.setLayout(layout) self.connect(self.backButton, QtCore.SIGNAL("clicked()"), self.backButtonClicked) self.connect(self.nextButton, QtCore.SIGNAL("clicked()"), self.nextButtonClicked) mainlayout.addWidget(self.cardstack) mainlayout.addWidget(buttonPanel) self.nextButton.setFocus() def backButtonClicked(self): '''Called when the 'Back' or 'Exit' buttons are pressed''' #print "back clicked" currIndex = self.cardstack.currentIndex() if currIndex == 0: # Do a controlled shutdown? Close Mongo, Tor? self.close() else: self.cardPanels[currIndex].cancel() self.cardPanels[currIndex-1].prepare() self.enableButtons(self.cardPanels[currIndex-1]) self.cardstack.setCurrentIndex(currIndex - 1) def nextButtonClicked(self): '''Called when the 'Next' or 'Finish' buttons are pressed''' currIndex = self.cardstack.currentIndex() currCard = self.cardPanels[currIndex] # TODO: or get this direct from self.cardstack? if currCard.finish(): # Tab was successful, so we can go forward try: # prepare the coming tab, if necessary self.cardPanels[currIndex + 1].prepare() self.cardPanels[currIndex + 1].redrawLabels() self.cardstack.setCurrentIndex(currIndex + 1) self.enableButtons(self.cardPanels[currIndex + 1]) except IndexError: # we've gone past the end of the wizard, time to quit # Launch Murmeli self.murmeliWindow = MainWindow() self.murmeliWindow.show() # close this wizard but keep Tor, Mongo running self.close() def enableButtons(self, card): '''Ask the card what the button texts and enabled status should be''' backKey, nextKey = card.getButtonKeys() self.backButton.setText(I18nManager.getText("button." + backKey)) self.nextButton.setText(I18nManager.getText("button." + nextKey)) backEnabled, nextEnabled = card.getButtonsEnabled() self.backButton.setEnabled(backEnabled) self.nextButton.setEnabled(nextEnabled) def redrawButtons(self): '''Change the texts of the back/next buttons and enable them both''' currIndex = self.cardstack.currentIndex() currCard = self.cardPanels[currIndex] self.enableButtons(currCard)
class StartupWizard(QtWidgets.QMainWindow): '''Class to act as the main startup wizard using Qt''' def __init__(self, *args): '''Constructor''' QtWidgets.QMainWindow.__init__(*(self, ) + args) self.setWindowTitle(I18nManager.getText("startupwizard.title")) # main pane with the stack and the button panel mainpane = QtWidgets.QWidget(self) mainlayout = QtWidgets.QVBoxLayout() mainpane.setLayout(mainlayout) self.setCentralWidget(mainpane) self.cardstack = QtWidgets.QStackedWidget(mainpane) self.cardPanels = [IntroPanel(), DependenciesPanel(), PathsPanel(), ServicesPanel(), \ KeygenPanel(), FinishedPanel()] for card in self.cardPanels: panel = card.getPanel() self.cardstack.addWidget(panel) card.redrawNavButtonsSignal.connect(self.redrawButtons) # button panel at the bottom buttonPanel = QtWidgets.QFrame(self.cardstack) buttonPanel.setFrameStyle(QtWidgets.QFrame.Box + QtWidgets.QFrame.Sunken) self.backButton = QtWidgets.QPushButton( I18nManager.getText("button.exit")) self.nextButton = QtWidgets.QPushButton( I18nManager.getText("button.next")) layout = QtWidgets.QHBoxLayout() layout.addWidget(self.backButton) layout.addStretch(1) layout.addWidget(self.nextButton) buttonPanel.setLayout(layout) self.backButton.clicked.connect(self.backButtonClicked) self.nextButton.clicked.connect(self.nextButtonClicked) mainlayout.addWidget(self.cardstack) mainlayout.addWidget(buttonPanel) self.nextButton.setFocus() def backButtonClicked(self): '''Called when the 'Back' or 'Exit' buttons are pressed''' #print "back clicked" currIndex = self.cardstack.currentIndex() if currIndex == 0: # Do a controlled shutdown? Close Db, Tor? self.close() else: self.cardPanels[currIndex].cancel() self.cardPanels[currIndex - 1].prepare() self.enableButtons(self.cardPanels[currIndex - 1]) self.cardstack.setCurrentIndex(currIndex - 1) def nextButtonClicked(self): '''Called when the 'Next' or 'Finish' buttons are pressed''' currIndex = self.cardstack.currentIndex() currCard = self.cardPanels[ currIndex] # TODO: or get this direct from self.cardstack? if currCard.finish(): # Tab was successful, so we can go forward try: # prepare the coming tab, if necessary self.cardPanels[currIndex + 1].prepare() self.cardPanels[currIndex + 1].redrawLabels() self.cardstack.setCurrentIndex(currIndex + 1) self.enableButtons(self.cardPanels[currIndex + 1]) except IndexError: # we've gone past the end of the wizard, time to quit # Launch Murmeli self.murmeliWindow = MainWindow() self.murmeliWindow.show() # close this wizard but keep Tor, Db running self.close() def enableButtons(self, card): '''Ask the card what the button texts and enabled status should be''' backKey, nextKey = card.getButtonKeys() self.backButton.setText(I18nManager.getText("button." + backKey)) self.nextButton.setText(I18nManager.getText("button." + nextKey)) backEnabled, nextEnabled = card.getButtonsEnabled() self.backButton.setEnabled(backEnabled) self.nextButton.setEnabled(nextEnabled) def redrawButtons(self): '''Change the texts of the back/next buttons and enable them both''' currIndex = self.cardstack.currentIndex() currCard = self.cardPanels[currIndex] self.enableButtons(currCard)
ownprofile.get("keyid", ""), "' so I'm going to start Murmeli") except Exception as e: print( "Exception thrown trying to get profile, so I can't start Murmeli:", e) canStartMurmeli = False # maybe authentication failed? if not canStartMurmeli: # Close database, ready for the startup wizard DbI.releaseDb() db = None # Get ready to launch a Qt GUI I18nManager.setLanguage() Config.registerSubscriber(I18nManager.instance()) app = QApplication([]) # Now start either the wizard or the main gui if canStartMurmeli: # Skip wizard, launch actual GUI from murmeli import MainWindow win = MainWindow() Config.registerSubscriber(win) win.show() else: win = StartupWizard() win.show() app.exec_()
ownprofile = DbClient.getProfile() if ownprofile is None or ownprofile.get("keyid", None) is None: print("I didn't get a profile or didn't get a key, so I can't start Murmeli") canStartMurmeli = False else: print("I think I got a profile and a keyid: '", ownprofile.get("keyid", ""), "' so I'm going to start Murmeli") except Exception: canStartMurmeli = False # maybe authentication failed? if not canStartMurmeli: # Ask DbClient to stop mongo again DbClient.stopDatabase() # Get ready to launch a Qt GUI I18nManager.setLanguage() Config.registerSubscriber(I18nManager.instance()) app = QtGui.QApplication([]) # Now start either the wizard or the main gui if canStartMurmeli: # Skip wizard, launch actual GUI (mongo is now started) from murmeli import MainWindow win = MainWindow() Config.registerSubscriber(win) win.show() else: win = StartupWizard() win.show() app.exec_()