Python PyQt5.QtCore.QLocale() Examples

The following are 13 code examples of PyQt5.QtCore.QLocale(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore , or try the search function .
Example #1
Source File: delegate.py    From pychemqt with GNU General Public License v3.0 6 votes vote down vote up
def createEditor(self, parent, option, index):
        widget = QtWidgets.QLineEdit(parent)
        widget.setAlignment(QtCore.Qt.AlignRight)
        validator = QtGui.QDoubleValidator(self)
        locale = QtCore.QLocale("en")
        validator.setLocale(locale)
        widget.setValidator(validator)
        return widget 
Example #2
Source File: __init__.py    From vorta with GNU General Public License v3.0 6 votes vote down vote up
def init_translations(app):
    """
    Loads translations for a given input app. If a scaling factor is defined for testing, we use
    our own subclass of QTranslator.
    """
    global application, translator, locale  # if we don't keep a reference on these, it stops working. pyqt bug?
    application = app
    translator = QTranslator() if trans_scale == 100 else VortaTranslator()

    locale = QLocale(os.environ.get('LANG', None))
    qm_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'qm'))
    ui_langs = locale.uiLanguages()
    succeeded = translator.load(locale, 'vorta', prefix='.', directory=qm_path)  # e.g. vorta/i18n/qm/vorta.de_DE.qm
    if succeeded:
        app.installTranslator(translator)
    logger.debug('Loading translation %s for %r.' % ('succeeded' if succeeded else 'failed', ui_langs)) 
Example #3
Source File: ui_FmvAbout.py    From QGISFMV with GNU General Public License v3.0 6 votes vote down vote up
def setupUi(self, FmvAbout):
        FmvAbout.setObjectName("FmvAbout")
        FmvAbout.resize(643, 559)
        FmvAbout.setMinimumSize(QtCore.QSize(200, 250))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/imgFMV/images/Information.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        FmvAbout.setWindowIcon(icon)
        FmvAbout.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.verticalLayout = QtWidgets.QVBoxLayout(FmvAbout)
        self.verticalLayout.setObjectName("verticalLayout")
        self.webView = QtWebKitWidgets.QWebView(FmvAbout)
        self.webView.setProperty("url", QtCore.QUrl("about:blank"))
        self.webView.setObjectName("webView")
        self.verticalLayout.addWidget(self.webView)

        self.retranslateUi(FmvAbout)
        QtCore.QMetaObject.connectSlotsByName(FmvAbout) 
Example #4
Source File: settings.py    From qhangups with GNU General Public License v3.0 5 votes vote down vote up
def populate_ui(self):
        """Load settings and populate dialog"""
        settings = QtCore.QSettings()

        self.sendClientActiveCheckBox.setChecked(settings.value("send_client_active", True, type=bool))
        self.sendReadStateCheckBox.setChecked(settings.value("send_read_state", True, type=bool))
        self.enterSendMessageCheckBox.setChecked(settings.value("enter_send_message", False, type=bool))
        self.connectionEventsCheckBox.setChecked(settings.value("connection_events", True, type=bool))
        self.autoConnectCheckBox.setChecked(settings.value("autoconnect", False, type=bool))

        lang_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "languages")

        self.languageComboBox.clear()
        self.languageComboBox.addItem(QtCore.QLocale.languageToString(QtCore.QLocale("en").language()), "en")

        for f in glob.glob(os.path.join(lang_path, "*.qm")):
            file_locale = os.path.splitext(os.path.basename(f))[0].split("_")[-1]
            file_lang = QtCore.QLocale.languageToString(QtCore.QLocale(file_locale).language())
            self.languageComboBox.addItem(file_lang, file_locale)

        language = settings.value("language")
        if not language:
            language = QtCore.QLocale.system().name().split("_")[0]

        i = self.languageComboBox.findData(language)
        if i == -1:
            self.languageComboBox.setCurrentIndex(0)
        else:
            self.languageComboBox.setCurrentIndex(i) 
Example #5
Source File: ebeam_table_ui.py    From ocelot with GNU General Public License v3.0 5 votes vote down vote up
def setupUi(self, Ebeam_Table):
        Ebeam_Table.setObjectName("Ebeam_Table")
        Ebeam_Table.resize(700, 500)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Ebeam_Table.sizePolicy().hasHeightForWidth())
        Ebeam_Table.setSizePolicy(sizePolicy)
        self.gridLayout_2 = QtWidgets.QGridLayout(Ebeam_Table)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.table = QtWidgets.QTableWidget(Ebeam_Table)
        self.table.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.table.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
        self.table.setRowCount(0)
        self.table.setColumnCount(2)
        self.table.setObjectName("table")
        item = QtWidgets.QTableWidgetItem()
        item.setTextAlignment(QtCore.Qt.AlignCenter)
        self.table.setHorizontalHeaderItem(0, item)
        item = QtWidgets.QTableWidgetItem()
        item.setTextAlignment(QtCore.Qt.AlignCenter)
        self.table.setHorizontalHeaderItem(1, item)
        self.table.verticalHeader().setVisible(False)
        self.gridLayout_2.addWidget(self.table, 0, 1, 1, 1)

        self.retranslateUi(Ebeam_Table)
        QtCore.QMetaObject.connectSlotsByName(Ebeam_Table) 
Example #6
Source File: lang.py    From parsec-cloud with GNU Affero General Public License v3.0 5 votes vote down vote up
def get_qlocale():
    q = QLocale(_current_locale_language)
    return q 
Example #7
Source File: ui_FmvOpenStream.py    From QGISFMV with GNU General Public License v3.0 5 votes vote down vote up
def setupUi(self, FmvOpenStream):
        FmvOpenStream.setObjectName("FmvOpenStream")
        FmvOpenStream.resize(355, 83)
        FmvOpenStream.setMinimumSize(QtCore.QSize(0, 0))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/imgFMV/images/stream.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        FmvOpenStream.setWindowIcon(icon)
        FmvOpenStream.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedStates))
        self.verticalLayout = QtWidgets.QVBoxLayout(FmvOpenStream)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.cmb_protocol = QtWidgets.QComboBox(FmvOpenStream)
        self.cmb_protocol.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
        self.cmb_protocol.setObjectName("cmb_protocol")
        self.cmb_protocol.addItem("")
        self.horizontalLayout_2.addWidget(self.cmb_protocol)
        self.ln_host = QtWidgets.QLineEdit(FmvOpenStream)
        self.ln_host.setText("")
        self.ln_host.setObjectName("ln_host")
        self.horizontalLayout_2.addWidget(self.ln_host)
        self.ln_port = QtWidgets.QLineEdit(FmvOpenStream)
        self.ln_port.setInputMethodHints(QtCore.Qt.ImhNone)
        self.ln_port.setText("")
        self.ln_port.setObjectName("ln_port")
        self.horizontalLayout_2.addWidget(self.ln_port)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.btn_Open = QtWidgets.QPushButton(FmvOpenStream)
        self.btn_Open.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        self.btn_Open.setObjectName("btn_Open")
        self.horizontalLayout_3.addWidget(self.btn_Open)
        self.verticalLayout.addLayout(self.horizontalLayout_3)

        self.retranslateUi(FmvOpenStream)
        self.btn_Open.clicked['bool'].connect(FmvOpenStream.OpenStream)
        QtCore.QMetaObject.connectSlotsByName(FmvOpenStream) 
Example #8
Source File: KillerDoubleSpinBox.py    From urh with GNU General Public License v3.0 5 votes vote down vote up
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.rstrip(self.suffix()))[0] 
Example #9
Source File: ui_updater.py    From ETS2Autopilot with MIT License 5 votes vote down vote up
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) 
Example #10
Source File: work_log.py    From Awesome-Scripts with MIT License 4 votes vote down vote up
def __init__(self, parent=None, repository=None, systemtray_icon=None):
        """Init window."""
        super(WorkLogPreviewer, self).__init__(parent)

        saveAct = QAction(QIcon(SAVE_ICON_PATH), '&Save', self)
        saveAct.setShortcut('Ctrl+S')
        saveAct.setStatusTip('Save work log')
        saveAct.triggered.connect(self.save)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(saveAct)

        self.repository = repository
        self.systemtray_icon = systemtray_icon

        self.statusBar()

        widget = QWidget()
        layout = QVBoxLayout()
        self.te = QPlainTextEdit()
        layout.addWidget(self.te)

        self.lbl = QLabel()
        self.lbl.hide()
        self.movie = QMovie(LOADER_PATH)
        self.lbl.setMovie(self.movie)
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(self.lbl)
        hlayout.addStretch()
        layout.addLayout(hlayout)

        self.generate_log()

        widget.setLayout(layout)
        widget.setFixedSize(500, 500)
        self.setCentralWidget(widget)

        self.setWindowTitle(f'Work log for {repository.full_name}')
        self.setWindowIcon(QIcon(ICON_PATH))
        self.setLocale(QtCore.QLocale())
        self.adjustSize()

        self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 
Example #11
Source File: work_log.py    From Awesome-Scripts with MIT License 4 votes vote down vote up
def __init__(self, parent=None):
        """Init widget."""
        super(MainWidget, self).__init__(parent)

        layout = QVBoxLayout()

        self.parent = parent

        self.ght = QLineEdit()
        self.ght.setPlaceholderText("Github Token")
        self.ght_keyPressEvent = self.ght.keyPressEvent
        self.ght_original_style = self.ght.styleSheet()
        self.ght.keyPressEvent = self.line_keyPressEvent
        layout.addWidget(self.ght)

        self.btn = QPushButton("Connect to github")
        self.btn.clicked.connect(self.getRepos)
        layout.addWidget(self.btn)

        self.combo = QComboBox()
        self.combo.setDisabled(True)
        layout.addWidget(self.combo)

        self.btn_save = QPushButton("Open worklog")
        self.btn_save.setDisabled(True)
        self.btn_save.clicked.connect(self.open_log)
        layout.addWidget(self.btn_save)

        self.lbl = QLabel()
        self.lbl.hide()
        self.movie = QMovie(LOADER_PATH)
        self.lbl.setMovie(self.movie)
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(self.lbl)
        hlayout.addStretch()
        layout.addLayout(hlayout)

        self.setLayout(layout)

        self.setLocale(QtCore.QLocale())

        self.sig.connect(self.add_repo_to_combobox) 
Example #12
Source File: work_log.py    From Awesome-Python-Scripts with MIT License 4 votes vote down vote up
def __init__(self, parent=None, repository=None, systemtray_icon=None):
        """Init window."""
        super(WorkLogPreviewer, self).__init__(parent)

        saveAct = QAction(QIcon(SAVE_ICON_PATH), '&Save', self)
        saveAct.setShortcut('Ctrl+S')
        saveAct.setStatusTip('Save work log')
        saveAct.triggered.connect(self.save)

        menubar = self.menuBar()
        fileMenu = menubar.addMenu('&File')
        fileMenu.addAction(saveAct)

        self.repository = repository
        self.systemtray_icon = systemtray_icon

        self.statusBar()

        widget = QWidget()
        layout = QVBoxLayout()
        self.te = QPlainTextEdit()
        layout.addWidget(self.te)

        self.lbl = QLabel()
        self.lbl.hide()
        self.movie = QMovie(LOADER_PATH)
        self.lbl.setMovie(self.movie)
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(self.lbl)
        hlayout.addStretch()
        layout.addLayout(hlayout)

        self.generate_log()

        widget.setLayout(layout)
        widget.setFixedSize(500, 500)
        self.setCentralWidget(widget)

        self.setWindowTitle(f'Work log for {repository.full_name}')
        self.setWindowIcon(QIcon(ICON_PATH))
        self.setLocale(QtCore.QLocale())
        self.adjustSize()

        self.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5()) 
Example #13
Source File: work_log.py    From Awesome-Python-Scripts with MIT License 4 votes vote down vote up
def __init__(self, parent=None):
        """Init widget."""
        super(MainWidget, self).__init__(parent)

        layout = QVBoxLayout()

        self.parent = parent

        self.ght = QLineEdit()
        self.ght.setPlaceholderText("Github Token")
        self.ght_keyPressEvent = self.ght.keyPressEvent
        self.ght_original_style = self.ght.styleSheet()
        self.ght.keyPressEvent = self.line_keyPressEvent
        layout.addWidget(self.ght)

        self.btn = QPushButton("Connect to github")
        self.btn.clicked.connect(self.getRepos)
        layout.addWidget(self.btn)

        self.combo = QComboBox()
        self.combo.setDisabled(True)
        layout.addWidget(self.combo)

        self.btn_save = QPushButton("Open worklog")
        self.btn_save.setDisabled(True)
        self.btn_save.clicked.connect(self.open_log)
        layout.addWidget(self.btn_save)

        self.lbl = QLabel()
        self.lbl.hide()
        self.movie = QMovie(LOADER_PATH)
        self.lbl.setMovie(self.movie)
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(self.lbl)
        hlayout.addStretch()
        layout.addLayout(hlayout)

        self.setLayout(layout)

        self.setLocale(QtCore.QLocale())

        self.sig.connect(self.add_repo_to_combobox)