Python PyQt5.QtCore 模块,QLocale() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用PyQt5.QtCore.QLocale()

项目:StarCraft-Casting-Tool    作者:teampheenix    | 项目源码 | 文件源码
def main():
    """Run StarCraft Casting Tool."""
    global language
    from scctool.view.main import MainWindow

    currentExitCode = MainWindow.EXIT_CODE_REBOOT
    cntlr = None
    while currentExitCode == MainWindow.EXIT_CODE_REBOOT:
        try:
            app = QApplication(sys.argv)
            app.setStyle(QStyleFactory.create('Fusion'))
            translator = QTranslator(app)
            translator.load(QLocale(language), "qtbase",
                            "_",  getAbsPath('locales'), ".qm")
            app.installTranslator(translator)

            initial_download()
            cntlr = main_window(app, translator, cntlr)
            currentExitCode = app.exec_()
            app = None
        except Exception as e:
            logger.exception("message")

    sys.exit(currentExitCode)
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def __init__(self, id_, name, value):
        super().__init__()
        self.id_ = id_
        self.name = name
        self.value = value
        self.win = None

        self.label = QtWidgets.QLabel(name)
        self.input = QtWidgets.QDoubleSpinBox()
        self.input.setSuffix("€")

        self.input.setMaximum(999.99)
        self.input.setLocale(QtCore.QLocale('English'))
        self.label.setBuddy(self.input)
        self._build()

        self.layout = QtWidgets.QHBoxLayout(self)
        self.layout.addWidget(self.label)
        self.layout.addWidget(self.input)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self, parent = None):
        QDoubleSpinBox.__init__(self, parent)
        self.saved_suffix = ''
        #Let's use the locale decimal separator if it is different from the dot ('.')
        local_decimal_separator = QLocale().decimalPoint()
        if local_decimal_separator == '.':
            local_decimal_separator = ''
        self.lineEdit().setValidator(QRegExpValidator(QRegExp("-?[0-9]*[.{0}]?[0-9]*.*".format(local_decimal_separator)), self))
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def valueFromText(self, text):
        if c.PYQT5notPYQT4:
            #print("valueFromText({0})".format(text.encode('utf-8')))
            text = text.encode('utf-8').replace(self.saved_suffix.encode('utf-8'), '').replace(QLocale().decimalPoint(), '.')
        else:
            #print("valueFromText({0})".format(text))
            text = text.replace(self.saved_suffix, '').replace(QLocale().decimalPoint(), '.')
        try:
            #result = float(text.replace('.', QLocale().decimalPoint()))
            result = float(text) #python expect a dot ('.') as decimal separator
        except ValueError:
            result = 0.0
        return result
项目:Enibar    作者:ENIB    | 项目源码 | 文件源码
def __init__(self, selected_note):
        super().__init__()
        uic.loadUi('ui/refill_note_window.ui', self)
        self.to_add.set_validator(api.validator.NUMBER)
        self.to_add.setFocus()
        self.reason.set_validator(api.validator.NAME)
        self.reason.setPlaceholderText("Raison")
        self.setWindowTitle("Prendre d'une note")
        self.selected_note = selected_note
        self.to_add.setLocale(QtCore.QLocale('English'))

        self.show()
        self.to_add.selectAll()
项目:ETS2Autopilot    作者:BrunoTh    | 项目源码 | 文件源码
def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(400, 131)
        MainWindow.setLocale(QtCore.QLocale(QtCore.QLocale.German, QtCore.QLocale.Germany))
        self.pb_progress = QtWidgets.QProgressBar(MainWindow)
        self.pb_progress.setGeometry(QtCore.QRect(10, 60, 381, 23))
        self.pb_progress.setProperty("value", 0)
        self.pb_progress.setAlignment(QtCore.Qt.AlignCenter)
        self.pb_progress.setOrientation(QtCore.Qt.Horizontal)
        self.pb_progress.setObjectName("pb_progress")
        self.b_run = QtWidgets.QPushButton(MainWindow)
        self.b_run.setEnabled(False)
        self.b_run.setGeometry(QtCore.QRect(210, 90, 181, 30))
        self.b_run.setCheckable(False)
        self.b_run.setChecked(False)
        self.b_run.setObjectName("b_run")
        self.label = QtWidgets.QLabel(MainWindow)
        self.label.setGeometry(QtCore.QRect(10, 10, 81, 16))
        self.label.setObjectName("label")
        self.label_2 = QtWidgets.QLabel(MainWindow)
        self.label_2.setGeometry(QtCore.QRect(10, 30, 81, 16))
        self.label_2.setObjectName("label_2")
        self.b_check = QtWidgets.QPushButton(MainWindow)
        self.b_check.setGeometry(QtCore.QRect(10, 90, 181, 30))
        self.b_check.setObjectName("b_check")
        self.l_newVersion = QtWidgets.QLabel(MainWindow)
        self.l_newVersion.setGeometry(QtCore.QRect(100, 30, 81, 16))
        self.l_newVersion.setText("")
        self.l_newVersion.setObjectName("l_newVersion")
        self.l_currentVersion = QtWidgets.QLabel(MainWindow)
        self.l_currentVersion.setGeometry(QtCore.QRect(100, 10, 81, 16))
        self.l_currentVersion.setText("")
        self.l_currentVersion.setObjectName("l_currentVersion")

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def valueFromText(self, text: str):
        if text.endswith("G") or text.endswith("g"):
            return QLocale().toDouble(text[:-1])[0] * 10 ** 9
        elif text.endswith("M") or text.endswith("m"):
            return QLocale().toDouble(text[:-1])[0] * 10 ** 6
        elif text.endswith("K") or text.endswith("k"):
            return QLocale().toDouble(text[:-1])[0] * 10 ** 3
        else:
            return QLocale().toDouble(text[:-1])[0]
项目:qturtle    作者:Transpyler    | 项目源码 | 文件源码
def launchInstance(cls, transpyler, show=True, **kwargs):
        """
        Launches a new instance of application.
        """

        app = QtWidgets.QApplication(sys.argv)
        path = os.path.join(os.path.dirname(__file__), 'data')
        locale = QLocale()
        translator = QTranslator()
        translator.load(locale, 'qturtle', '_', path, '.qm')
        app.installTranslator(translator)
        window = cls(transpyler, **kwargs)
        if show:
            window.show()
        sys.exit(app.exec_())