當前位置: 首頁>>代碼示例>>Python>>正文


Python QtGui.QCheckBox方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QCheckBox方法的典型用法代碼示例。如果您正苦於以下問題:Python QtGui.QCheckBox方法的具體用法?Python QtGui.QCheckBox怎麽用?Python QtGui.QCheckBox使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui的用法示例。


在下文中一共展示了QtGui.QCheckBox方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setupUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setupUi(self, Form):
        Form.setObjectName(_fromUtf8("Form"))
        Form.resize(400, 300)
        self.gridLayout = QtGui.QGridLayout(Form)
        self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
        self.sizeSpin = QtGui.QSpinBox(Form)
        self.sizeSpin.setProperty("value", 10)
        self.sizeSpin.setObjectName(_fromUtf8("sizeSpin"))
        self.gridLayout.addWidget(self.sizeSpin, 1, 1, 1, 1)
        self.pixelModeCheck = QtGui.QCheckBox(Form)
        self.pixelModeCheck.setObjectName(_fromUtf8("pixelModeCheck"))
        self.gridLayout.addWidget(self.pixelModeCheck, 1, 3, 1, 1)
        self.label = QtGui.QLabel(Form)
        self.label.setObjectName(_fromUtf8("label"))
        self.gridLayout.addWidget(self.label, 1, 0, 1, 1)
        self.plot = PlotWidget(Form)
        self.plot.setObjectName(_fromUtf8("plot"))
        self.gridLayout.addWidget(self.plot, 0, 0, 1, 4)
        self.randCheck = QtGui.QCheckBox(Form)
        self.randCheck.setObjectName(_fromUtf8("randCheck"))
        self.gridLayout.addWidget(self.randCheck, 1, 2, 1, 1)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:26,代碼來源:ScatterPlotSpeedTestTemplate_pyqt.py

示例2: setLang

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:27,代碼來源:UITranslator.py

示例3: setLang

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setLang(self, langName):
        uiList_lang_read = self.memoData['lang'][langName]
        for ui_name in uiList_lang_read:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setText(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtGui.QGroupBox, QtGui.QMenu ]:
                # uiType: QMenu, QGroupBox
                if uiList_lang_read[ui_name] != "":
                    ui_element.setTitle(uiList_lang_read[ui_name])
            elif type(ui_element) in [ QtGui.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                if uiList_lang_read[ui_name] != "":
                    tabNameList = uiList_lang_read[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != "":
                                ui_element.setTabText(i,tabNameList[i])
            elif type(ui_element) == str:
                # uiType: string for msg
                if uiList_lang_read[ui_name] != "":
                    self.uiList[ui_name] = uiList_lang_read[ui_name] 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:27,代碼來源:UITranslator_v1.0.py

示例4: createDEToptGroup

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def createDEToptGroup(self):
        self.detgroupBox = QtGui.QGroupBox("& DET options")
        self.enable_show_label_cb = QtGui.QCheckBox('enable show label name')


        self.label_font_size_sl = QtGui.QSlider(QtCore.Qt.Horizontal)
        self.label_font_size_sl.setRange(5,50)
        self.label_font_size_sp = QtGui.QSpinBox()
        self.label_font_size_sp.setRange(5,50)
        QtCore.QObject.connect(self.label_font_size_sl, QtCore.SIGNAL("valueChanged(int)"),

                               self.label_font_size_sp, QtCore.SLOT("setValue(int)"))
        self.label_font_size_sl.valueChanged.connect(self.change_label_font_size)
        self.label_font_size_sl.setValue(self.__class__.label_font_size)
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.enable_show_label_cb)
        vbox.addWidget(QtGui.QLabel('label font size'))
        vbox.addWidget(self.label_font_size_sl)
        vbox.addWidget(self.label_font_size_sp)
        vbox.addStretch()
        self.detgroupBox.setLayout(vbox)
        return self.detgroupBox 
開發者ID:lzx1413,項目名稱:LabelImgTool,代碼行數:24,代碼來源:settingDialog.py

示例5: createSEGoptGroup

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def createSEGoptGroup(self):
        self.seggroupBox = QtGui.QGroupBox("& SEG options")
        self.enable_color_map_cb = QtGui.QCheckBox('enable color map')
        self.instance_seg_label_cb = QtGui.QCheckBox('set instance seg')
        self.instance_seg_label_cb.setChecked(self.__class__.instance_seg_flag)
        self.instance_seg_label_cb.stateChanged.connect(self.change_instance_seg_label)
        if self.__class__.enable_color_map:
            self.enable_color_map_cb.toggle()
        self.enable_color_map_cb.stateChanged.connect(
            self.change_color_enable_state)
        if self.__class__.enable_color_map:
            self.enable_color_map_cb.setChecked(True)
        vbox = QtGui.QVBoxLayout()
        vbox.addWidget(self.enable_color_map_cb)
        vbox.addWidget(self.instance_seg_label_cb)
        vbox.addStretch(True)
        self.seggroupBox.setLayout(vbox)
        return self.seggroupBox 
開發者ID:lzx1413,項目名稱:LabelImgTool,代碼行數:20,代碼來源:settingDialog.py

示例6: setupUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(400, 240)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.checkBox = QtGui.QCheckBox(self.centralwidget)
        self.checkBox.setGeometry(QtCore.QRect(130, 80, 151, 41))
        font = QtGui.QFont()
        font.setPointSize(32)
        self.checkBox.setFont(font)
        self.checkBox.setObjectName(_fromUtf8("checkBox"))
        #MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 400, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        #MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        #MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
開發者ID:reza-arjmandi,項目名稱:rpi-course,代碼行數:24,代碼來源:gui_switch.py

示例7: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def __init__(self, tabletName, sensor, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.setFixedSize(250, 120)

        self.tabletName = tabletName
        self.sensor = sensor
        self.buttons = QtGui.QCheckBox("Inverse Buttons")
        self.buttons.setToolTip("Inverse mouse clicks on pen")
        self.buttons.stateChanged.connect(self.buttonChange)
        self.tiptouch = QtGui.QCheckBox("Pen Touch")
        self.tiptouch.setToolTip("When enabled, pen must touch tablet to work.\nWhen disabled, hover will register.")
        self.tiptouch.stateChanged.connect(self.tipChange)
        #layout code
        self.mainLayout = QtGui.QVBoxLayout()
        self.mainLayout.addWidget(self.penSettings())
        if sensor == 'stylus':
            self.mainLayout.addWidget(self.buttons)
        self.mainLayout.addWidget(self.tiptouch)
        self.mainLayout.setAlignment(QtCore.Qt.AlignCenter)
        self.setLayout(self.mainLayout) 
開發者ID:tb2097,項目名稱:wacom-gui,代碼行數:22,代碼來源:pressure.py

示例8: setupUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(820, 650)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setDocumentMode(False)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, -1, 0, 0)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.btnAdd = QtGui.QPushButton(self.centralwidget)
        self.btnAdd.setObjectName(_fromUtf8("btnAdd"))
        self.horizontalLayout.addWidget(self.btnAdd)
        self.chkMore = QtGui.QCheckBox(self.centralwidget)
        self.chkMore.setObjectName(_fromUtf8("chkMore"))
        self.horizontalLayout.addWidget(self.chkMore)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.matplotlibwidget = MatplotlibWidget(self.centralwidget)
        self.matplotlibwidget.setObjectName(_fromUtf8("matplotlibwidget"))
        self.verticalLayout.addWidget(self.matplotlibwidget)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
開發者ID:swharden,項目名稱:Python-GUI-examples,代碼行數:32,代碼來源:ui_main.py

示例9: setupUi

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(820, 650)
        MainWindow.setAutoFillBackground(False)
        MainWindow.setDocumentMode(False)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget)
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, -1, 0, 0)
        self.horizontalLayout.setSpacing(10)
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
        self.btnAdd = QtGui.QPushButton(self.centralwidget)
        self.btnAdd.setObjectName(_fromUtf8("btnAdd"))
        self.horizontalLayout.addWidget(self.btnAdd)
        self.chkMore = QtGui.QCheckBox(self.centralwidget)
        self.chkMore.setObjectName(_fromUtf8("chkMore"))
        self.horizontalLayout.addWidget(self.chkMore)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.grPlot = PlotWidget(self.centralwidget)
        self.grPlot.setObjectName(_fromUtf8("grPlot"))
        self.verticalLayout.addWidget(self.grPlot)
        MainWindow.setCentralWidget(self.centralwidget)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow) 
開發者ID:swharden,項目名稱:Python-GUI-examples,代碼行數:32,代碼來源:ui_main.py

示例10: __init__

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def __init__(self, data, num, parent=None):
        super(Bit_container, self).__init__(parent)
        self.data = data
        self.setFrameStyle(widgets.QFrame.Sunken)
        self.setFrameShape(widgets.QFrame.Box)
        self.setFixedWidth(140)

        self.layout = widgets.QVBoxLayout()
        cblayout = widgets.QHBoxLayout()
        cblayout.setContentsMargins(0, 0, 0, 0)
        cblayout.setSpacing(0)
        data = int("0x" + data, 16)
        databin = bin(data)[2:].zfill(8)

        self.checkboxes = []
        for i in range(8):
            cb = widgets.QCheckBox()
            cb.setEnabled(False)
            if databin[i] == "1":
                cb.setChecked(True)
            self.checkboxes.append(cb)
            cblayout.addWidget(cb)
            cb.setStyleSheet("color: green")

        label = widgets.QLabel(str(num + 1).zfill(2))
        label.setAlignment(core.Qt.AlignHCenter | core.Qt.AlignVCenter)

        self.labelvaluehex = widgets.QLabel("$00")
        self.labelvaluehex.setAlignment(core.Qt.AlignHCenter | core.Qt.AlignVCenter)

        self.layout.addWidget(label)
        self.layout.addWidget(self.labelvaluehex)
        self.layout.addLayout(cblayout)
        self.setLayout(self.layout) 
開發者ID:cedricp,項目名稱:ddt4all,代碼行數:36,代碼來源:dataeditor.py

示例11: createIconGroupBox

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def createIconGroupBox(self): # Add the SysTray preferences window grouping
        self.iconGroupBox = QtGui.QGroupBox("Tray Icon")

        self.iconLabel = QtGui.QLabel("Icon:")

        self.iconComboBox = QtGui.QComboBox()
        self.iconComboBox.addItem(QtGui.QIcon('images/Airplay-Light'), "Black Icon")
        self.iconComboBox.addItem(QtGui.QIcon('images/Airplay-Dark'), "White Icon")

        self.showIconCheckBox = QtGui.QCheckBox("Show tray icon")
        self.showIconCheckBox.setChecked(self.settings.value('systrayicon', type=bool))
        print("Got systrayicon from settings:" + str(self.settings.value('systrayicon', type=bool)))

        self.systrayClosePromptCheckBox = QtGui.QCheckBox("Systray Close warning")
        self.systrayClosePromptCheckBox.setChecked(self.settings.value('promptOnClose_systray', type=bool))
        print("Got promptOnClose_systray from settings:" + str(self.settings.value('promptOnClose_systray', type=bool)))

        iconLayout = QtGui.QHBoxLayout()
        iconLayout.addWidget(self.iconLabel)
        iconLayout.addWidget(self.iconComboBox)
        iconLayout.addStretch()
        iconLayout.addWidget(self.showIconCheckBox)
        iconLayout.addWidget(self.systrayClosePromptCheckBox)
        self.iconGroupBox.setLayout(iconLayout)

    # Creates the device selection list. 
開發者ID:openairplay,項目名稱:openairplay,代碼行數:28,代碼來源:main.py

示例12: setLang

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def setLang(self, langName):
        lang_data = self.memoData['lang'][langName]
        for ui_name in lang_data.keys():
            if ui_name in self.uiList.keys() and lang_data[ui_name] != '':
                ui_element = self.uiList[ui_name]
                # '' means no translation availdanle in that data file
                if isinstance(ui_element, (QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox) ):
                    # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                    ui_element.setText(lang_data[ui_name])
                elif isinstance(ui_element, (QtWidgets.QGroupBox, QtWidgets.QMenu) ):
                    # uiType: QMenu, QGroupBox
                    ui_element.setTitle(lang_data[ui_name])
                elif isinstance(ui_element, QtWidgets.QTabWidget):
                    # uiType: QTabWidget
                    tabCnt = ui_element.count()
                    tabNameList = lang_data[ui_name].split(';')
                    if len(tabNameList) == tabCnt:
                        for i in range(tabCnt):
                            if tabNameList[i] != '':
                                ui_element.setTabText(i,tabNameList[i])
                elif isinstance(ui_element, QtWidgets.QComboBox):
                    # uiType: QComboBox
                    itemCnt = ui_element.count()
                    itemNameList = lang_data[ui_name].split(';')
                    ui_element.clear()
                    ui_element.addItems(itemNameList)
                elif isinstance(ui_element, QtWidgets.QTreeWidget):
                    # uiType: QTreeWidget
                    labelCnt = ui_element.headerItem().columnCount()
                    labelList = lang_data[ui_name].split(';')
                    ui_element.setHeaderLabels(labelList)
                elif isinstance(ui_element, QtWidgets.QTableWidget):
                    # uiType: QTableWidget
                    colCnt = ui_element.columnCount()
                    headerList = lang_data[ui_name].split(';')
                    cur_table.setHorizontalHeaderLabels( headerList )
                elif isinstance(ui_element, (str, unicode) ):
                    # uiType: string for msg
                    self.uiList[ui_name] = lang_data[ui_name] 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:41,代碼來源:universal_tool_template_1116.py

示例13: qui

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def qui(self, ui_list_string, parentObject_string='', opt=''):
        # pre-defined user short name syntax
        type_dict = {
            'vbox': 'QVBoxLayout','hbox':'QHBoxLayout','grid':'QGridLayout', 'form':'QFormLayout',
            'split': 'QSplitter', 'grp':'QGroupBox', 'tab':'QTabWidget',
            'btn':'QPushButton', 'btnMsg':'QPushButton', 'label':'QLabel', 'input':'QLineEdit', 'check':'QCheckBox', 'choice':'QComboBox',
            'txtEdit': 'LNTextEdit', 'txt': 'QTextEdit',
            'tree': 'QTreeWidget', 'table': 'QTableWidget',
            'space': 'QSpacerItem', 
        }
        # get ui_list, creation or existing ui object
        ui_list = [x.strip() for x in ui_list_string.split('|')]
        for i in range(len(ui_list)):
            if ui_list[i] in self.uiList:
                # - exisiting object
                ui_list[i] = self.uiList[ui_list[i]]
            else:
                # - string creation: 
                # get part info
                partInfo = ui_list[i].split(';',1)
                uiName = partInfo[0].split('@')[0]
                uiType = uiName.rsplit('_',1)[-1]
                if uiType in type_dict:
                    uiType = type_dict[uiType]
                # set quickUI string format
                ui_list[i] = partInfo[0]+';'+uiType
                if len(partInfo)==1:
                    # give empty button and label a place holder name
                    if uiType in ('btn', 'btnMsg', 'QPushButton','label', 'QLabel'):
                        ui_list[i] = partInfo[0]+';'+uiType + ';'+uiName 
                elif len(partInfo)==2:
                    ui_list[i]=ui_list[i]+";"+partInfo[1]
        # get parentObject or exisiting object
        parentObject = parentObject_string
        if parentObject in self.uiList:
            parentObject = self.uiList[parentObject]
        # process quickUI
        self.quickUI(ui_list, parentObject, opt) 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:40,代碼來源:UITranslator.py

示例14: loadLang

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def loadLang(self):
        self.quickMenu(['language_menu;&Language'])
        cur_menu = self.uiList['language_menu']
        self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
        cur_menu.addSeparator()
        self.uiList['langDefault_atnLang'].triggered.connect(partial(self.setLang,'default'))
        # store default language
        self.memoData['lang']={}
        self.memoData['lang']['default']={}
        for ui_name in self.uiList:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtWidgets.QLabel, QtWidgets.QPushButton, QtWidgets.QAction, QtWidgets.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.text())
            elif type(ui_element) in [ QtWidgets.QGroupBox, QtWidgets.QMenu ]:
                # uiType: QMenu, QGroupBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.title())
            elif type(ui_element) in [ QtWidgets.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                tabNameList = []
                for i in range(tabCnt):
                    tabNameList.append(str(ui_element.tabText(i)))
                self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
            elif type(ui_element) == str:
                # uiType: string for msg
                self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]
        
        # try load other language
        lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
        baseName = os.path.splitext( os.path.basename(self.location) )[0]
        for fileName in os.listdir(lang_path):
            if fileName.startswith(baseName+"_lang_"):
                langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
                self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
                self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
                self.uiList[langName+'_atnLang'].triggered.connect(partial(self.setLang,langName))
        # if no language file detected, add export default language option
        if len(self.memoData['lang']) == 1:
            self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
            self.uiList['langExport_atnLang'].triggered.connect(self.exportLang) 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:43,代碼來源:UITranslator.py

示例15: loadLang

# 需要導入模塊: from PyQt4 import QtGui [as 別名]
# 或者: from PyQt4.QtGui import QCheckBox [as 別名]
def loadLang(self):
        self.quickMenu(['language_menu;&Language'])
        cur_menu = self.uiList['language_menu']
        self.quickMenuAction('langDefault_atnLang', 'Default','','langDefault.png', cur_menu)
        cur_menu.addSeparator()
        QtCore.QObject.connect( self.uiList['langDefault_atnLang'], QtCore.SIGNAL("triggered()"), partial(self.setLang, 'default') )
        # store default language
        self.memoData['lang']={}
        self.memoData['lang']['default']={}
        for ui_name in self.uiList:
            ui_element = self.uiList[ui_name]
            if type(ui_element) in [ QtGui.QLabel, QtGui.QPushButton, QtGui.QAction, QtGui.QCheckBox ]:
                # uiType: QLabel, QPushButton, QAction(menuItem), QCheckBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.text())
            elif type(ui_element) in [ QtGui.QGroupBox, QtGui.QMenu ]:
                # uiType: QMenu, QGroupBox
                self.memoData['lang']['default'][ui_name] = str(ui_element.title())
            elif type(ui_element) in [ QtGui.QTabWidget]:
                # uiType: QTabWidget
                tabCnt = ui_element.count()
                tabNameList = []
                for i in range(tabCnt):
                    tabNameList.append(str(ui_element.tabText(i)))
                self.memoData['lang']['default'][ui_name]=';'.join(tabNameList)
            elif type(ui_element) == str:
                # uiType: string for msg
                self.memoData['lang']['default'][ui_name] = self.uiList[ui_name]
        
        # try load other language
        lang_path = os.path.dirname(self.location) # better in packed than(os.path.abspath(__file__))
        baseName = os.path.splitext( os.path.basename(self.location) )[0]
        for fileName in os.listdir(lang_path):
            if fileName.startswith(baseName+"_lang_"):
                langName = fileName.replace(baseName+"_lang_","").split('.')[0].replace(" ","")
                self.memoData['lang'][ langName ] = self.readRawFile( os.path.join(lang_path,fileName) )
                self.quickMenuAction(langName+'_atnLang', langName.upper(),'',langName + '.png', cur_menu)
                QtCore.QObject.connect( self.uiList[langName+'_atnLang'], QtCore.SIGNAL("triggered()"), partial(self.setLang, langName) )
        # if no language file detected, add export default language option
        if len(self.memoData['lang']) == 1:
            self.quickMenuAction('langExport_atnLang', 'Export Default Language','','langExport.png', cur_menu)
            QtCore.QObject.connect( self.uiList['langExport_atnLang'], QtCore.SIGNAL("triggered()"), self.exportLang ) 
開發者ID:shiningdesign,項目名稱:universal_tool_template.py,代碼行數:43,代碼來源:UITranslator_v1.0.py


注:本文中的PyQt4.QtGui.QCheckBox方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。