コード例 #1
0
    def warning(parent, text):
        """
		Standardisierte Dialogbox für die Mitteilung einer Warnung an den Benutzer.

		Eine Warnung wird auch auf der kommandozeile ausgegeben, wenn "verbose" aktiviert ist.
		"""

        if GlobalState.is_verbose:
            Shell.print_warning(text)

        obj = QObject()
        QMessageBox.warning(parent, obj.tr("Warning"), str(text))
コード例 #2
0
	def warning( parent, text ):
		"""
		Standardisierte Dialogbox für die Mitteilung einer Warnung an den Benutzer.

		Eine Warnung wird auch auf der kommandozeile ausgegeben, wenn "verbose" aktiviert ist.
		"""

		if GlobalState.is_verbose:
			Shell.print_warning( text )

		obj = QObject()
		QMessageBox.warning( parent, obj.tr("Warning"), str( text ) )
コード例 #3
0
    def __init__(self, fileName=None, exportPath=None, parent=None):
        debug_timing_start = Debug.timehook()

        super(MainWindow, self).__init__(parent)

        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        QCoreApplication.setOrganizationName(Config.ORGANIZATION)
        QCoreApplication.setApplicationName(Config.PROGRAM_NAME)
        QCoreApplication.setApplicationVersion(Config.version())

        #Debug.debug(QApplication.style())

        self.setWindowTitle("")
        self.setWindowIcon(QIcon(":/icons/images/WoD.png"))

        self.__storage = StorageTemplate(self)
        self.storeTemplateData()
        self.__character = StorageCharacter(self.__storage)
        ## Später sollte ich mich für einen entscheiden!!
        self.__readCharacter = ReadXmlCharacter(self.__character)
        self.__writeCharacter = WriteXmlCharacter(self.__character)

        self.ui.pushButton_next.clicked.connect(
            self.ui.selectWidget_select.selectNext)
        self.ui.pushButton_previous.clicked.connect(
            self.ui.selectWidget_select.selectPrevious)
        self.ui.selectWidget_select.currentRowChanged.connect(
            self.ui.stackedWidget_traits.setCurrentIndex)
        self.ui.selectWidget_select.currentRowChanged.connect(
            self.setTabButtonState)
        #self.ui.selectWidget_select.currentRowChanged.connect(self.pageChanged.emit)
        self.__character.speciesChanged.connect(
            self.ui.selectWidget_select.changeIcons)

        self.__readCharacter.exception_raised.connect(
            self.showExceptionMessage)

        # Laden der Konfiguration
        self.readSettings()

        self.populateUi()

        Debug.timesince(debug_timing_start,
                        "Time neccessary to populate the UI.")

        debug_timing_between_start = Debug.timehook()

        self.activate()

        Debug.timesince(debug_timing_between_start,
                        "Time neccessary to activate the UI.")

        debug_timing_between_start = Debug.timehook()

        self.ui.selectWidget_select.currentRowChanged.connect(
            self.showCreationPoints)

        self.ui.actionSettings.triggered.connect(self.showSettingsDialog)
        self.ui.actionNew.triggered.connect(self.newCharacter)
        self.ui.actionOpen.triggered.connect(self.openCharacter)
        self.ui.actionSave.triggered.connect(self.saveCharacter)
        self.ui.actionExport.triggered.connect(self.exportCharacter)
        self.ui.actionPrint.triggered.connect(self.printCharacter)
        self.ui.actionAbout.triggered.connect(self.aboutApp)

        self.reset()
        Debug.timesince(debug_timing_between_start,
                        "Time neccessary to set all initial values.")

        debug_timing_between_start = Debug.timehook()

        ## Wird ein Dateiname angegeben, soll dieser sofort geladen werden.
        if fileName:
            if os.path.exists(fileName):
                if GlobalState.is_verbose:
                    print("Opening file {}.".format(fileName))
                self.openCharacter(fileName)
            elif fileName.lower() in [
                    species.lower()
                    for species in self.__storage.species.keys()
            ]:
                if GlobalState.is_verbose:
                    print(
                        "Empty Charactersheet of species {} will be created.".
                        format(fileName.lower()))
                self.__character.species = fileName[0].upper(
                ) + fileName[1:].lower()
                self.__character.setModified(False)
            else:
                Shell.print_warning(
                    "A file named \"{}\" does not exist.".format(fileName))

            Debug.timesince(debug_timing_between_start,
                            "Time neccessary to load a file at startup.")

        if exportPath:
            if GlobalState.is_verbose:
                print("Creating PDF {}".format(exportPath[0]))
            # exportPath ist eine Liste mit einem einzigen Element als Inhalt (argparse)
            self.__createPdf(exportPath[0])
            # Damit das Programm ordentlich geschlossen werden kann, muß auf das Starten der Event-Loop gewartet werden. dies geht am einfachsten mit einem QTimer.
            QTimer.singleShot(0, self.close)

        Debug.timesince(
            debug_timing_start,
            "The full time span neccessary to prepare the application for user input."
        )
コード例 #4
0
	def __init__(self, fileName=None, exportPath=None, parent=None):
		debug_timing_start = Debug.timehook()

		super(MainWindow, self).__init__(parent)

		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)

		QCoreApplication.setOrganizationName( Config.ORGANIZATION )
		QCoreApplication.setApplicationName( Config.PROGRAM_NAME )
		QCoreApplication.setApplicationVersion( Config.version() )

		#Debug.debug(QApplication.style())

		self.setWindowTitle( "" )
		self.setWindowIcon( QIcon( ":/icons/images/WoD.png" ) )

		self.__storage = StorageTemplate( self )
		self.storeTemplateData()
		self.__character = StorageCharacter(self.__storage)
		## Später sollte ich mich für einen entscheiden!!
		self.__readCharacter = ReadXmlCharacter(self.__character)
		self.__writeCharacter = WriteXmlCharacter(self.__character)

		self.ui.pushButton_next.clicked.connect(self.ui.selectWidget_select.selectNext)
		self.ui.pushButton_previous.clicked.connect(self.ui.selectWidget_select.selectPrevious)
		self.ui.selectWidget_select.currentRowChanged.connect(self.ui.stackedWidget_traits.setCurrentIndex)
		self.ui.selectWidget_select.currentRowChanged.connect(self.setTabButtonState)
		#self.ui.selectWidget_select.currentRowChanged.connect(self.pageChanged.emit)
		self.__character.speciesChanged.connect(self.ui.selectWidget_select.changeIcons)

		self.__readCharacter.exception_raised.connect(self.showExceptionMessage)

		# Laden der Konfiguration
		self.readSettings()

		self.populateUi()

		Debug.timesince( debug_timing_start, "Time neccessary to populate the UI." )

		debug_timing_between_start = Debug.timehook()

		self.activate()

		Debug.timesince( debug_timing_between_start, "Time neccessary to activate the UI." )

		debug_timing_between_start = Debug.timehook()

		self.ui.selectWidget_select.currentRowChanged.connect(self.showCreationPoints)

		self.ui.actionSettings.triggered.connect(self.showSettingsDialog)
		self.ui.actionNew.triggered.connect(self.newCharacter)
		self.ui.actionOpen.triggered.connect(self.openCharacter)
		self.ui.actionSave.triggered.connect(self.saveCharacter)
		self.ui.actionExport.triggered.connect(self.exportCharacter)
		self.ui.actionPrint.triggered.connect(self.printCharacter)
		self.ui.actionAbout.triggered.connect(self.aboutApp)

		self.reset()
		Debug.timesince( debug_timing_between_start, "Time neccessary to set all initial values." )

		debug_timing_between_start = Debug.timehook()

		## Wird ein Dateiname angegeben, soll dieser sofort geladen werden.
		if fileName:
			if os.path.exists(fileName):
				if GlobalState.is_verbose:
					print("Opening file {}.".format(fileName))
				self.openCharacter(fileName)
			elif fileName.lower() in [ species.lower() for species in self.__storage.species.keys() ]:
				if GlobalState.is_verbose:
					print("Empty Charactersheet of species {} will be created.".format(fileName.lower()))
				self.__character.species = fileName[0].upper() + fileName[1:].lower()
				self.__character.setModified(False)
			else:
				Shell.print_warning("A file named \"{}\" does not exist.".format(fileName))

			Debug.timesince( debug_timing_between_start, "Time neccessary to load a file at startup." )

		if exportPath:
			if GlobalState.is_verbose:
				print("Creating PDF {}".format(exportPath[0]))
			# exportPath ist eine Liste mit einem einzigen Element als Inhalt (argparse)
			self.__createPdf(exportPath[0])
			# Damit das Programm ordentlich geschlossen werden kann, muß auf das Starten der Event-Loop gewartet werden. dies geht am einfachsten mit einem QTimer.
			QTimer.singleShot(0, self.close)

		Debug.timesince( debug_timing_start, "The full time span neccessary to prepare the application for user input." )