Beispiel #1
0
def main(argv):
	QTextCodec.setCodecForTr(QTextCodec.codecForName('utf-8'))

	parsed_args = parseArguments(argv)
	logger = createLogger(parsed_args.IsDebugging)

	logger.debug('Create application.')
	app = QApplication(argv)
	if hasattr(parsed_args, 'Language') and not parsed_args.Language is None:
		translator = createTranslator(parsed_args.Language)
		app.installTranslator(translator)

	window = MainWindow.MainWindow()

	logger.debug('Check to execute a CUI mode.')
	if(parsed_args.InputFiles):
		logger.debug('Enter the CUI mdoe.')

		for file in parsed_args.InputFiles:
			try:
				window.convert(file)
			except e as Exception:
				logger.error('Failed to conversion %s', file)
				logger.debug(e)

		logger.info('Finished to convert all files.')
		return

	logger.debug('Enter the GUI mode.')
	window.show()
	sys.exit(app.exec_())
Beispiel #2
0
def main():
    """
    """
    from MainWindow import MainWindow

    translator = QTranslator() #Build the translator
    translator.load(":/locales/df_%s" % QLocale.system().name())
    qttranslator = QTranslator()#A translator for Qt standard strings
    qttranslator.load("qt_%s" % (QLocale.system().name()))
    App = QApplication(sys.argv) #Creating the app
    App.setOrganizationName(ORGNAME) #Setting organization and application's
    App.setApplicationName(NAME)#name. It's only useful for QSettings
    App.setApplicationVersion(VERSION)
    App.setOrganizationDomain(URL)
    App.installTranslator(translator)#Install translators into the application.
    App.installTranslator(qttranslator)
    mw = MainWindow(App) #Now it's time to instantiate the main window
    mw.show() #And show it
    sys.exit(App.exec_()) #When the app finishes, exit.
def main():
    """
    """
    from MainWindow import MainWindow

    translator = QTranslator()  #Build the translator
    translator.load(":/locales/df_%s" % QLocale.system().name())
    qttranslator = QTranslator()  #A translator for Qt standard strings
    qttranslator.load("qt_%s" % (QLocale.system().name()))
    App = QApplication(sys.argv)  #Creating the app
    App.setOrganizationName(ORGNAME)  #Setting organization and application's
    App.setApplicationName(NAME)  #name. It's only useful for QSettings
    App.setApplicationVersion(VERSION)
    App.setOrganizationDomain(URL)
    App.installTranslator(
        translator)  #Install translators into the application.
    App.installTranslator(qttranslator)
    mw = MainWindow(App)  #Now it's time to instantiate the main window
    mw.show()  #And show it
    sys.exit(App.exec_())  #When the app finishes, exit.
Beispiel #4
0
def main(argv=None):
    app = QApplication(argv or sys.argv)
    locale = QLocale.system().name()
    trans = QTranslator()
    locale_path = '%s/locale/ifmon_%s' % (os.path.dirname(
        os.path.dirname(os.path.realpath(__file__))), locale.lower())
    trans.load(locale_path)
    app.installTranslator(trans)
    try:
        setup_db()
    except:
        QMessageBox.critical(
            None, 'Database error', 'Could not find the database.\n'
            'Please install it properly by running install.py on Ubuntu.\n'
            'For other Linux distributions, check the requirements.',
            QMessageBox.Ok)
        sys.exit(app.exit())
    else:
        mw = MainWindow()
        mw.show()
    sys.exit(app.exec_())
Beispiel #5
0
def main(argv=None):
    app = QApplication(argv or sys.argv)
    locale = QLocale.system().name()
    trans = QTranslator()
    locale_path = '%s/locale/ifmon_%s' % (os.path.dirname(os.path.dirname(
        os.path.realpath(__file__))), locale.lower())
    trans.load(locale_path)
    app.installTranslator(trans)
    try:
        setup_db()
    except:
        QMessageBox.critical(None, 'Database error',
            'Could not find the database.\n'
            'Please install it properly by running install.py on Ubuntu.\n'
            'For other Linux distributions, check the requirements.',
            QMessageBox.Ok)
        sys.exit(app.exit())
    else:
        mw = MainWindow()
        mw.show()
    sys.exit(app.exec_())
        splash.setStyleSheet("""
            font-family: inherit;
            font-weight: normal;
            font-size: 11pt;
            """)

        def splash_write(msg):
            if not splash is None:
                splash.showMessage("\t" + msg + "\n",
                                   color=QtCore.Qt.white,
                                   alignment=QtCore.Qt.AlignBottom)

        splash_write(NAME + " " + VERSION)
        app.processEvents()

        app.installTranslator(qtTranslator)
        if trasnlations: app.installTranslator(translator)

        frame = PinguinoIDE(splash_write=splash_write, argvs=parser)
        frame.show()

        if not splash is None:
            splash.finish(frame)

        #For PyInstaller compatibility
        if app is None:
            from PySide.QtGui import QApplication
            QApplication.instance().exec_()
        else:
            #sys.exit(app.exec_())
            app.exec_()
Beispiel #7
0
        splash.show()
        splash.setStyleSheet("""
            font-family: inherit;
            font-weight: normal;
            font-size: 11pt;

        """)

        def splash_write(msg):
            if not splash is None:
                splash.showMessage("\t"+msg+"\n", color=QtCore.Qt.white, alignment=QtCore.Qt.AlignBottom)

        splash_write(NAME+" "+VERSION)
        app.processEvents()

        app.installTranslator(qtTranslator)
        if trasnlations: app.installTranslator(translator)

        frame = PinguinoIDE(splash_write=splash_write)
        frame.show()

        if not splash is None:
            splash.finish(frame)

        #For PyInstaller compatibility
        if app is None:
            from PySide.QtGui import QApplication
            QApplication.instance().exec_()
        else:
            app.exec_()
            return self.__settings.value(key)
        else:
            return ""

    def __setitem__(self, key, value):
        """Méthode magique sous-jacent à l'opérateur [] en écriture"""
        self.__settings.setValue(key, value)

    def __delitem__(self, key):
        """Méthode magique sous-jacent à l'opérateur del"""
        self.__settings.remove(key)

if __name__ == "__main__":
    """Main de test"""
    import sys
    from PySide.QtGui import QApplication
    from PySide.QtCore import QLibraryInfo, QLocale, QTranslator

    app = QApplication(sys.argv)

    locale = QLocale.system().name()
    translator = QTranslator()
    translator.load("qt_" + locale,
        QLibraryInfo.location(QLibraryInfo.TranslationsPath))
    app.installTranslator(translator)

    ui = ConfigUI()
    ui.show()
    ret = app.exec_()
    sys.exit(ret)
Beispiel #9
0
Datei: FCY.py Projekt: uheee/FCY
# -*- coding: utf-8 -*-
from PySide.QtGui import QApplication
from PySide.QtCore import Qt, QTranslator
from ui.MainWindow import MainWindow
import sys
if __name__ == "__main__":
    app = QApplication(sys.argv)
    translator = QTranslator()
    translator.load(":/zh/qt_zh_CN.qm")
    app.installTranslator(translator)
    window = MainWindow()
    #window.setWindowFlags(window.windowFlags() &~ Qt.WindowMinMaxButtonsHint)
    window.setWindowFlags(window.windowFlags() & ~Qt.WindowMaximizeButtonHint)
    #window.setWindowFlags(Qt.FramelessWindowHint)
    window.show()
    sys.exit(app.exec_())
from PySide.QtCore import QLocale
from PySide.QtCore import QLibraryInfo
from PySide.QtCore import Qt

from qrmainwindow import QtReduceMainWindow

app = QApplication(sys.argv)

app.setOrganizationName("The Reduce Project")
app.setOrganizationDomain("reduce-algebra.sourceforge.net")
app.setApplicationName("QReduce")

qtTranslator = QTranslator(app)
qtTranslator.load("qt_" + QLocale.system().name(),
                  QLibraryInfo.location(QLibraryInfo.TranslationsPath))
app.installTranslator(qtTranslator)

qreduceTranslator = QTranslator(app)
qreduceTranslator.load(sys.path[0] + "/" + "qreducetr." +
                       str(locale.getdefaultlocale()[0]))
#app.installTranslator(qreduceTranslator)

# app.setStyleSheet("QStatusBar::item { border: 0px solid black }");

app.setWindowIcon(QIcon(sys.path[0] + "/" + "Bumblebee.png"))

if os.uname()[0] == "Darwin":
    app.setAttribute(Qt.AA_DontShowIconsInMenus)

mainwindow = QtReduceMainWindow()
class Application(QObject):
    def __init__(self):
        QObject.__init__(self)
        self.__translator = QTranslator()
        self.__rules = Rules.Rules()
        self.__facts = Facts.Facts()
        self.expert = ExpertSystem.Expert(self.__rules, self.__facts)
        self.__ui = None
        self.current_question = None
        self.__finished = False

        self.__rules.add_rule(Rules.Rule("Z", ["R"]))
        self.__rules.add_rule(Rules.Rule("C", ["A", "B"]))
        self.__rules.add_rule(Rules.Rule("E", ["C", "D", "F"]))
        self.__rules.add_rule(Rules.Rule("D", ["C"]))

        self.__app = QApplication(sys.argv)

        self.__setup_language()
        self.__init_ui()

        self.reset()

    def __setup_language(self):
        system_locale, _ = locale.getdefaultlocale()
        search_folder = os.path.dirname(__file__)
        search_folder = os.path.join(search_folder, "..", "translations")
        self.__translator.load(system_locale, search_folder)
        self.__app.installTranslator(self.__translator)

    def __init_ui(self):
        self.__load_ui()
        self.__setup_slots()

    def __load_ui(self):
        ui_path = os.path.dirname(__file__)
        ui_path = os.path.join(ui_path, "MainWindow.ui")
        ui_file = QFile(ui_path)
        ui_file.open(QFile.ReadOnly)
        ui_loader = QtUiTools.QUiLoader()
        self.__ui = ui_loader.load(ui_file, None)
        ui_file.close()

        self.__ui.answerTableWidget.setHorizontalHeaderLabels([self.tr("Question"), self.tr("Answer")])

    def __setup_slots(self):
        self.__ui.answer.button(QtGui.QDialogButtonBox.Yes).clicked.connect(self.slot_answer_clicked_yes)
        self.__ui.answer.button(QtGui.QDialogButtonBox.No).clicked.connect(self.slot_answer_clicked_no)
        self.__ui.actionNew.triggered.connect(self.reset)
        self.__ui.actionLoadRules.triggered.connect(self.load_rules)

    def slot_answer_clicked_yes(self):
        self.slot_answer_clicked(True)

    def slot_answer_clicked_no(self):
        self.slot_answer_clicked(False)

    def slot_answer_clicked(self, answer):
        self.__facts.set_fact_value(self.current_question, answer)
        self.add_answer_to_list(self.current_question, answer)

        conclusion_rule = self.expert.infer_forward()
        conclusion_text = self.tr("Can't conclude")
        if conclusion_rule is not None and self.__rules.is_terminal_rule(conclusion_rule):
            conclusion_text = conclusion_rule.conclusion
            self.finished()
        self.__ui.conclusionLabel.setText(conclusion_text)

        self.next_answer()

    def add_answer_to_list(self, question, answer):
        count = self.__ui.answerTableWidget.rowCount()
        self.__ui.answerTableWidget.setRowCount(count + 1)
        self.__ui.answerTableWidget.setItem(count, 0, QtGui.QTableWidgetItem(question))
        answer_text = self.tr("Yes") if answer else self.tr("No")
        self.__ui.answerTableWidget.setItem(count, 1, QtGui.QTableWidgetItem(answer_text))

    def reset(self):
        self.__facts.reset()
        self.__ui.answer.setEnabled(True)
        self.__ui.answerTableWidget.setRowCount(0)
        self.__ui.conclusionLabel.setText(self.tr("Can't conclude"))
        self.__finished = False
        self.next_answer()

    def run(self):
        self.__ui.show()
        self.__app.exec_()

    def next_answer(self):
        question = self.expert.infer_backward()
        if question is not None and not self.__finished:
            self.current_question = question
        else:
            question = None
            self.finished()
        question = self.tr("No more questions!") if question is None else question
        self.__ui.questionLabel.setText(question)

    def finished(self):
        self.__ui.answer.setEnabled(False)
        self.__finished = True

    def load_rules(self):
        file_path, file_filter = QtGui.QFileDialog.getOpenFileName(self.__ui, self.tr("Select rules file"), "",
                                                                   self.tr("Rules file") + " (*.rules)")
        if file_path != "" and file_filter != "":
            self.__rules = RulesJsonSerializer.charge_rules(file_path)
            self.expert = ExpertSystem.Expert(self.__rules, self.__facts)
            self.reset()