我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt4.QtGui.QCheckBox()。
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]
def __init__(self, database_ref, parent=None): super(TeamMatchPage, self).__init__(parent) self.database_ref = database_ref ## Set up scroll bars self.scroll = QtGui.QScrollArea() self.scroll.setWidgetResizable(False) ## Create QWidget objects self.confirmCheckBox = QtGui.QCheckBox('Confirm') ## Register fields self.registerField('team_confirm*', self.confirmCheckBox)
def clearChildren (self, widget ): if ( isinstance(widget, QtGui.QLineEdit) or isinstance(widget, QtGui.QTextEdit)): widget.setText("") if ( isinstance(widget, QtGui.QComboBox) ): widget.setCurrentIndex( 0 ) if ( isinstance(widget, QtGui.QCheckBox) ): widget.setChecked( False ) if ( isinstance(widget, QtGui.QTableWidget) ): while widget.rowCount() > 0: widget.removeRow(0) # recursive call on chillun for child in widget.children(): self.clearChildren( child )
def __init__(self, parent=None): super(AnaSayfa, self).__init__(parent) self.setWindowTitle("%s adl? kullan?c?n?n geçmi?i" %(u.adi)) self.resize(1100, 600) self.layout = QtGui.QGridLayout() self.setLayout(self.layout) self.table = QtGui.QTableWidget() self.btn_eliminar = QtGui.QPushButton("Seçili sat?r? sil") self.chck=QtGui.QCheckBox("otomotik güncelleme yap?ls?n m? ") self.layout.addWidget(self.btn_eliminar) self.layout.addWidget(self.chck) self.layout.addWidget(self.table) self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.show() self.Seleccionar() self.btn_eliminar.clicked.connect(self.Eliminar) self.table.doubleClicked.connect(self.doubleClick) timer = QTimer(self) timer.timeout.connect(self.otoRefresh) timer.setInterval(5000) timer.start()
def __init__(self, pattern): super(Option, self).__init__() parts = [p.replace('+', ' ') for p in pattern.split(" ")] self.command = parts[0] self.params = [] hbox = QtGui.QHBoxLayout() self.checkbox = QtGui.QCheckBox(self.command) hbox.addWidget(self.checkbox) for part in parts[1:]: if '<int>' == part: self.params.append(ParamInt()) elif '<str>' == part: self.params.append(ParamStr()) elif '<select{' == part[:len('<select{')]: self.params.append(ParamSelect( (part[len('<select{'):-2]).split('|'))) else: # assert(False) break hbox.addWidget(self.params[-1]) self.params[-1].trigger.connect(self.onParamChanged) hbox.addStretch(1) self.setLayout(hbox)
def __init__(self, window): super().__init__(window) self.window = window self.setWindowTitle('Datasets') self.setModal(False) self.layout = QtGui.QGridLayout() self.checks = [] self.colorselection = [] self.colordisp_all = [] self.intensitysettings = [] self.setLayout(self.layout) self.wbackground = QtGui.QCheckBox('White background') self.layout.addWidget(self.wbackground,0,3) self.layout.addWidget(QtGui.QLabel('Path'), 1, 0) self.layout.addWidget(QtGui.QLabel('Color'), 1, 1) self.layout.addWidget(QtGui.QLabel('#'), 1, 2) self.layout.addWidget(QtGui.QLabel('Rel. Intensity'), 1, 3) self.wbackground.stateChanged.connect(self.update_viewport)
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]
def makeLayout(self, title, labels): layout = QtGui.QGridLayout() title = QtGui.QLabel(title) title.setFont(QtGui.QFont('MS Shell Dlg 2',pointSize=16)) layout.addWidget(title, 0,0,1,3) #editable fields self.TTLswitch = TextChangingButton(labels) self.TTLswitch.setAutoDefault(True) layout.addWidget(self.TTLswitch, 2,0, 2,1) self.enableSwitch = QtGui.QCheckBox('Enable Shutter') layout.addWidget(self.enableSwitch, 1,0, 1,1) self.setLayout(layout)
def eventFilter(self, object, event): if not self.submitType and not self.PH5View.helpEnable: return False if self.submitType and not self.helpEnable: return False if event.type() == QtCore.QEvent.Enter: if object not in self.EXPL.keys(): return False #print object P = object.pos() #print P if object.__class__.__name__ == 'QRadioButton' \ or (not self.submitType and object.__class__.__name__ == 'QCheckBox'): QtGui.QToolTip.showText(self.scrollPanel.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object]) else: QtGui.QToolTip.showText(self.mapToGlobal(QtCore.QPoint(P.x(), P.y()+20)), self.EXPL[object]) return True return False
def setupUi(self, TokenDialog): TokenDialog.setObjectName(_fromUtf8("TokenDialog")) TokenDialog.resize(361, 213) self.centralwidget = QtGui.QWidget(TokenDialog) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.verticalLayoutWidget = QtGui.QWidget(self.centralwidget) self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 361, 211)) self.verticalLayoutWidget.setObjectName(_fromUtf8("verticalLayoutWidget")) self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setMargin(0) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.listWidget = QtGui.QListWidget(self.verticalLayoutWidget) self.listWidget.setObjectName(_fromUtf8("listWidget")) self.verticalLayout.addWidget(self.listWidget) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.checkBox = QtGui.QCheckBox(self.verticalLayoutWidget) self.checkBox.setObjectName(_fromUtf8("checkBox")) self.horizontalLayout_2.addWidget(self.checkBox) self.spinBox = QtGui.QSpinBox(self.verticalLayoutWidget) self.spinBox.setMinimumSize(QtCore.QSize(50, 0)) self.spinBox.setMaximumSize(QtCore.QSize(50, 16777215)) self.spinBox.setObjectName(_fromUtf8("spinBox")) self.horizontalLayout_2.addWidget(self.spinBox) self.verticalLayout.addLayout(self.horizontalLayout_2) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.pushButton = QtGui.QPushButton(self.verticalLayoutWidget) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.horizontalLayout.addWidget(self.pushButton) self.pushButton_2 = QtGui.QPushButton(self.verticalLayoutWidget) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.horizontalLayout.addWidget(self.pushButton_2) self.verticalLayout.addLayout(self.horizontalLayout) TokenDialog.setCentralWidget(self.centralwidget) self.retranslateUi(TokenDialog) QtCore.QMetaObject.connectSlotsByName(TokenDialog)
def __init__(self, parent=None, item=None, title="Unnamed", default="a"): ''' :param parent: Parent `gui.DiagramEditor`. :param item: Store item for later processing. :param title: Window title. :param default: Default string text. ''' super(NameDialog, self).__init__(parent) self.setWindowTitle(title) self.lineEdit = QtGui.QLineEdit() self.lineEdit.setText( default ) self.lineEdit.setFocus( ) self.button = QtGui.QPushButton('Ok', self) self.button2 = QtGui.QPushButton('Cancel', self) vl = QtGui.QHBoxLayout(self) vl.addWidget(self.lineEdit) if isinstance(item, str): if "transition" in item: self.checkBox = QtGui.QCheckBox("Subnet") vl.addWidget(self.checkBox) hl = QtGui.QHBoxLayout() hl.addWidget(self.button) hl.addWidget(self.button2) vl.addLayout(hl) self.button.clicked.connect(self.ok) self.button2.clicked.connect(self.cancel) self.item = item #------------------------------------------------------------------------------------------------
def _init_ui(self): self.list_items = [] if self._columm == 2: self._box = QGridLayout() else: self._box = QVBoxLayout() j, i, x = 0, 0, 0 for item in self._list_apps: if self.objectName() != item.category.name: self.setObjectName(item.category.name) new_qcb = QCheckBox(item.title) new_qcb.setObjectName(item.name) new_qcb.clicked.connect(self._addcommand) if isinstance(self._box, QGridLayout): if i == 0: self._box.addWidget(new_qcb, j, i) i = 1 x += 1 else: self._box.addWidget(new_qcb, j, i) i = 0 x += 1 if x == 2: j += 1 x = 0 elif isinstance(self._box, QVBoxLayout): self._box.addWidget(new_qcb) self.setLayout(self._box)
def _set_up_min_max_widgets(self): check_box = QCheckBox() spin_box = ArraySpinBox([0]) spin_box.setDisabled(True) check_box.toggled.connect(spin_box.setEnabled) check_box.toggled.connect(self._min_max_value_changed) spin_box.valueChanged.connect(self._min_max_value_changed) return check_box, spin_box
def _set_up_opt_spin_box(self): check_box = QCheckBox() spin_box = QDoubleSpinBox() spin_box.setDecimals(5) spin_box.setSingleStep(0.01) spin_box.setMinimum(-sys.float_info.max) spin_box.setMaximum(sys.float_info.max) spin_box.setDisabled(True) check_box.toggled.connect(spin_box.setEnabled) return check_box, spin_box
def setupUi(self, CustomWidget): CustomWidget.setObjectName(_fromUtf8("CustomWidget")) CustomWidget.resize(400, 300) self.gridLayout = QtGui.QGridLayout(CustomWidget) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.plotWidget = PlotWidget(CustomWidget) self.plotWidget.setObjectName(_fromUtf8("plotWidget")) self.gridLayout.addWidget(self.plotWidget, 0, 0, 1, 1) self.checkBox = QtGui.QCheckBox(CustomWidget) self.checkBox.setChecked(True) self.checkBox.setObjectName(_fromUtf8("checkBox")) self.gridLayout.addWidget(self.checkBox, 1, 0, 1, 1) self.retranslateUi(CustomWidget) QtCore.QMetaObject.connectSlotsByName(CustomWidget)
def connectChildDirtyFlagSignals (self, widget ): if ( isinstance(widget, QtGui.QLineEdit)): widget.textEdited.connect(self.setDirtyFlag) if ( isinstance(widget, QtGui.QTextEdit)): widget.textChanged.connect(self.setDirtyFlag) if ( isinstance(widget, QtGui.QComboBox) ): widget.currentIndexChanged.connect(self.setDirtyFlag) if ( isinstance(widget, QtGui.QCheckBox) ): widget.stateChanged.connect(self.setDirtyFlag) # recursive call on chillun for child in widget.children(): if child != self.pageListEditor: self.connectChildDirtyFlagSignals( child )
def __init__(self, parent=None): super(Ui_Dialog, self).__init__(parent) self.setObjectName(_fromUtf8("Dialog")) parent.resize(320, 240) self.setMinimumSize(QtCore.QSize(550, 500)) self.setMaximumSize(QtCore.QSize(550, 500)) self.pushButton = QtGui.QPushButton(self) self.pushButton.setGeometry(QtCore.QRect(160, 100, 98, 27)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.lineEdit = QtGui.QLineEdit(MainWindow) self.lineEdit.setGeometry(QtCore.QRect(140, 20, 113, 27)) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.label = QtGui.QLabel(MainWindow) self.label.setGeometry(QtCore.QRect(40, 20, 91, 17)) self.label.setObjectName(_fromUtf8("label")) self.lineEdit_2 = QtGui.QLineEdit(MainWindow) self.lineEdit_2.setEnabled(True) self.lineEdit_2.setGeometry(QtCore.QRect(140, 50, 113, 27)) self.lineEdit_2.setEchoMode(QtGui.QLineEdit.Password) self.lineEdit_2.setObjectName(_fromUtf8("lineEdit_2")) self.label_2 = QtGui.QLabel(MainWindow) self.label_2.setGeometry(QtCore.QRect(90, 60, 41, 17)) self.label_2.setObjectName(_fromUtf8("label_2")) self.pushButton_2 = QtGui.QPushButton(MainWindow) self.pushButton_2.setGeometry(QtCore.QRect(50, 100, 98, 27)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.checkBox = QtGui.QCheckBox(MainWindow) self.checkBox.setGeometry(QtCore.QRect(80, 130, 141, 22)) self.checkBox.setObjectName(_fromUtf8("checkBox")) self.retranslateUi(MainWindow) QtCore.QObject.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.click) QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QObject.connect(self.pushButton_2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.uyeOl) self.yeniform = None
def initUI(self): self.grid = QtGui.QGridLayout() self.checkbox = [] i = 0 bold = QtGui.QFont() bold.setBold(True) for plot in range(len(self.plot_order)): if self.plot_order[plot] in self.spacers: label = QtGui.QLabel(self.spacers[self.plot_order[plot]]) label.setFont(bold) self.grid.addWidget(label, i, 0) i += 1 self.checkbox.append(QtGui.QCheckBox(self.hdrs[self.plot_order[plot]], self)) if self.plots[self.plot_order[plot]]: self.checkbox[plot].setCheckState(QtCore.Qt.Checked) self.grid.addWidget(self.checkbox[-1], i, 0) i += 1 self.grid.connect(self.checkbox[0], QtCore.SIGNAL('stateChanged(int)'), self.check_all) show = QtGui.QPushButton('Proceed', self) show.clicked.connect(self.showClicked) self.grid.addWidget(show, i, 0) frame = QtGui.QFrame() frame.setLayout(self.grid) self.scroll = QtGui.QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setWidget(frame) self.layout = QtGui.QVBoxLayout(self) self.layout.addWidget(self.scroll) commnt = QtGui.QLabel('Nearest weather files:\n' + self.comment) self.layout.addWidget(commnt) self.setWindowTitle('SIREN - Weather dialog for ' + str(self.base_year)) QtGui.QShortcut(QtGui.QKeySequence('q'), self, self.quitClicked) self.show_them = False self.show()
def initUI(self): self.chosen = [] self.grid = QtGui.QGridLayout() self.checkbox = [] self.checkbox.append(QtGui.QCheckBox('Check / Uncheck all', self)) self.grid.addWidget(self.checkbox[-1], 0, 0) i = 0 c = 0 icons = Icons() for stn in sorted(self.stations, key=lambda station: station.name): if stn.technology[:6] == 'Fossil' and not self.actual: continue if stn.technology == 'Rooftop PV' and stn.scenario == 'Existing' and not self.gross_load: continue self.checkbox.append(QtGui.QCheckBox(stn.name, self)) icon = icons.getIcon(stn.technology) if icon != '': self.checkbox[-1].setIcon(QtGui.QIcon(icon)) i += 1 self.grid.addWidget(self.checkbox[-1], i, c) if i > 25: i = 0 c += 1 self.grid.connect(self.checkbox[0], QtCore.SIGNAL('stateChanged(int)'), self.check_all) show = QtGui.QPushButton('Choose', self) self.grid.addWidget(show, i + 1, c) show.clicked.connect(self.showClicked) self.setLayout(self.grid) self.setWindowTitle('SIREN - Power Stations dialog') QtGui.QShortcut(QtGui.QKeySequence('q'), self, self.quitClicked) self.show_them = False self.show()
def addPauseButton(self,layout,func): freezeButton = QtGui.QCheckBox(self) freezeButton.setObjectName(_fromUtf8("freezeButton")) freezeButton.setText("Pause") layout.addWidget(freezeButton) QtCore.QObject.connect(freezeButton, QtCore.SIGNAL(_fromUtf8("toggled(bool)")), func) return freezeButton
def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(316, 70) self.gridLayout = QtGui.QGridLayout(Form) self.gridLayout.setContentsMargins(0, 2, 0, 2) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.line = QtGui.QFrame(Form) self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName(_fromUtf8("line")) self.gridLayout.addWidget(self.line, 0, 0, 1, 3) self.dataOptions = QtGui.QComboBox(Form) self.dataOptions.setObjectName(_fromUtf8("dataOptions")) self.gridLayout.addWidget(self.dataOptions, 2, 0, 1, 3) self.enable = QtGui.QCheckBox(Form) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.enable.sizePolicy().hasHeightForWidth()) self.enable.setSizePolicy(sizePolicy) self.enable.setMinimumSize(QtCore.QSize(20, 0)) self.enable.setText(_fromUtf8("")) self.enable.setObjectName(_fromUtf8("enable")) self.gridLayout.addWidget(self.enable, 1, 0, 1, 1) self.title = QtGui.QLabel(Form) self.title.setObjectName(_fromUtf8("title")) self.gridLayout.addWidget(self.title, 1, 1, 1, 1) self.toolButton = QtGui.QToolButton(Form) icon = QtGui.QIcon.fromTheme(_fromUtf8("window-close")) self.toolButton.setIcon(icon) self.toolButton.setObjectName(_fromUtf8("toolButton")) self.gridLayout.addWidget(self.toolButton, 1, 2, 1, 1) self.line_2 = QtGui.QFrame(Form) self.line_2.setFrameShape(QtGui.QFrame.HLine) self.line_2.setFrameShadow(QtGui.QFrame.Sunken) self.line_2.setObjectName(_fromUtf8("line_2")) self.gridLayout.addWidget(self.line_2, 3, 0, 1, 3) self.retranslateUi(Form) QtCore.QObject.connect(self.toolButton, QtCore.SIGNAL(_fromUtf8("clicked()")), Form.remove) QtCore.QMetaObject.connectSlotsByName(Form)
def addPlot(self,addr,param): newNode = self.I.newRadioLink(address=addr) self.nodeList.append(newNode) print ('made link',addr,param) #newNode.write_register(self.I.NRF.RF_SETUP,0x0E) #self.I.NRF.write_register(self.I.NRF.RF_SETUP,0x0E) #Change to 2MBPS cls=False cls_module = supported.get(param,None) if cls_module: cls = cls_module.connect(newNode) else: cls=None if cls: if hasattr(cls,'name'): label = cls.name else: label ='' if not self.active_device_counter: if len(label):self.plot.setLabel('left', label) curves=[self.addCurve(self.plot,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS)] else: if label: colStr = lambda col: hex(col[0])[2:]+hex(col[1])[2:]+hex(col[2])[2:] newplt = self.addAxis(self.plot,label=label)#,color='#'+colStr(cols[0].getRgb())) else: newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curves=[self.addCurve(newplt ,'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) for a in range(cls.NUMPLOTS)] #for a in range(cls.NUMPLOTS): # self.plotLegend.addItem(curves[a],'%s[%s]'%(label[:10],cls.PLOTNAMES[a])) self.createMenu(cls,param) for a in range(cls.NUMPLOTS): curves[a].checked=True Callback = functools.partial(self.setTraceVisibility,curves[a]) action=QtGui.QCheckBox('%s'%(cls.PLOTNAMES[a])) #self.curveMenu.addAction('%s[%d]'%(label[:12],a)) action.toggled[bool].connect(Callback) action.setChecked(True) action.setStyleSheet("background-color:rgb%s;"%(str(curves[a].opts['pen'].color().getRgb()))) self.paramMenus.insertWidget(1,action) self.actionWidgets.append(action) self.acquireList.append(self.plotItem(cls,np.zeros((cls.NUMPLOTS,self.POINTS)), curves)) self.active_device_counter+=1
def addPlot(self,cls,addr): bridge = cls.connect(self.I.I2C,address = addr) if bridge: self.createMenu(bridge) if bridge.NUMPLOTS: if hasattr(bridge,'name'): label = bridge.name else: label ='' if not self.active_device_counter: if len(label):self.plot.setLabel('left', label) curves=[self.addCurve(self.plot,'%s[%s]'%(label[:10],bridge.PLOTNAMES[a])) for a in range(bridge.NUMPLOTS)] else: if label: colStr = lambda col: hex(col[0])[2:]+hex(col[1])[2:]+hex(col[2])[2:] newplt = self.addAxis(self.plot,label=label)#,color='#'+colStr(cols[0].getRgb())) else: newplt = self.addAxis(self.plot) self.right_axes.append(newplt) curves=[self.addCurve(newplt ,'%s[%s]'%(label[:10],bridge.PLOTNAMES[a])) for a in range(bridge.NUMPLOTS)] #for a in range(bridge.NUMPLOTS): # self.plotLegend.addItem(curves[a],'%s[%s]'%(label[:10],bridge.PLOTNAMES[a])) for a in range(bridge.NUMPLOTS): curves[a].checked=True Callback = functools.partial(self.setTraceVisibility,curves[a]) action=QtGui.QCheckBox('%s'%(bridge.PLOTNAMES[a])) #self.curveMenu.addAction('%s[%d]'%(label[:12],a)) action.toggled[bool].connect(Callback) action.setChecked(True) action.setStyleSheet("background-color:rgb%s;"%(str(curves[a].opts['pen'].color().getRgb()))) self.paramMenus.insertWidget(1,action) self.actions.append(action) self.acquireList.append(self.plotItem(bridge,np.zeros((bridge.NUMPLOTS,self.POINTS)), curves)) self.active_device_counter+=1
def __init__(self,embryo,parent): super(defaultPinningDialog,self).__init__(parent) self.embryo = embryo self.useMin=True self.useMax=True self.debug=False #Labels self.lblUseMin = QtGui.QLabel("Use Min. Value for Background:", self) self.lblUseMax = QtGui.QLabel("Use Max. Value for Norming:", self) self.lblDebug = QtGui.QLabel("Show Debugging Output:", self) #Checkboxes self.cbUseMax = QtGui.QCheckBox('', self) self.cbUseMin = QtGui.QCheckBox('', self) self.cbDebug = QtGui.QCheckBox('', self) self.updateCBs() self.connect(self.cbUseMax, QtCore.SIGNAL('stateChanged(int)'), self.checkUseMax) self.connect(self.cbUseMin, QtCore.SIGNAL('stateChanged(int)'), self.checkUseMin) self.connect(self.cbDebug, QtCore.SIGNAL('stateChanged(int)'), self.checkDebug) #layout self.grid.addWidget(self.lblUseMin,1,1) self.grid.addWidget(self.lblUseMax,2,1) self.grid.addWidget(self.lblDebug,3,1) self.grid.addWidget(self.cbUseMin,1,2) self.grid.addWidget(self.cbUseMax,2,2) self.grid.addWidget(self.cbDebug,3,2) self.setWindowTitle("Basic Pinning Dialog") self.show()
def genSettingCB(parent,lblText,cbVal,callback=None): """Generates ``QLabel`` and ``QCheckbox`` with given label and connects to correct callback. .. note:: ``QCheckBox`` is conncect with ``stateChanged`` slot. Args: parent (QtGui.QWidget): Some parenting widget. lblText (str): Text displayed in label. cbVal (bool): Checked or not. Keyword Args: callback (function): Some callback function. Returns: tuple: Tuple containing: * lbl (QtGui.QLabel): Label. * cb (QtGui.QCheckBox): Checkbox. """ lbl = QtGui.QLabel(lblText, parent) cb = QtGui.QCheckBox('', parent) cb.setCheckState(2*int(cbVal)) if callback!=None: parent.connect(cb, QtCore.SIGNAL('stateChanged(int)'), callback) return lbl,cb
def __init__(self,ROI,parent): super(sliceROIDialog,self).__init__(ROI,parent) #Labels self.lblHeight = QtGui.QLabel("Height:", self) self.lblWidth = QtGui.QLabel("Width:", self) #LineEdits self.qleHeight = QtGui.QLineEdit(str(self.ROI.height)) self.qleWidth = QtGui.QLineEdit(str(self.ROI.width)) self.qleHeight.setValidator(self.doubleValid) self.qleWidth.setValidator(self.doubleValid) self.qleHeight.editingFinished.connect(self.setHeight) self.qleWidth.editingFinished.connect(self.setWidth) #Checkboxes self.cbSliceBottom = QtGui.QCheckBox('SliceBottom?', self) self.cbSliceBottom.setCheckState(2*int(self.ROI.sliceBottom)) self.connect(self.cbSliceBottom, QtCore.SIGNAL('stateChanged(int)'), self.checkSliceBottom) #Layout nRows=self.grid.rowCount() self.grid.addWidget(self.lblHeight,nRows+1,1) self.grid.addWidget(self.lblWidth,nRows+2,1) self.grid.addWidget(self.qleHeight,nRows+1,2) self.grid.addWidget(self.qleWidth,nRows+2,2) self.grid.addWidget(self.cbSliceBottom,nRows+3,2) self.updateZExtendQles() self.show()
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle("Convert old database to a new format") self.setMinimumWidth(500) # stary plik z modelami self.oldFilePath = QtGui.QLineEdit(os.path.join(__currentPath__, "param.py")) # nowy plik z modelami self.newFilePath = QtGui.QLineEdit(os.path.join(__currentPath__, "data/dane.cfg")) # self.pominDuplikaty = QtGui.QCheckBox(u"Skip duplicates") self.pominDuplikaty.setChecked(True) self.pominDuplikaty.setDisabled(True) # self.removeOld = QtGui.QCheckBox(u"Remove old database") self.removeOld.setChecked(True) # przyciski buttons = QtGui.QDialogButtonBox() buttons.addButton("Cancel", QtGui.QDialogButtonBox.RejectRole) buttons.addButton("Convert", QtGui.QDialogButtonBox.AcceptRole) self.connect(buttons, QtCore.SIGNAL("accepted()"), self.konwertuj) self.connect(buttons, QtCore.SIGNAL("rejected()"), self, QtCore.SLOT("reject()")) # self.mainLayout = QtGui.QGridLayout(self) #self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.addWidget(QtGui.QLabel(u"Old database"), 0, 0, 1, 1) self.mainLayout.addWidget(self.oldFilePath, 0, 1, 1, 1) self.mainLayout.addWidget(QtGui.QLabel(u"New database"), 1, 0, 1, 1) self.mainLayout.addWidget(self.newFilePath, 1, 1, 1, 1) self.mainLayout.addWidget(self.pominDuplikaty, 3, 0, 1, 2) self.mainLayout.addWidget(self.removeOld, 4, 0, 1, 2) self.mainLayout.addWidget(buttons, 5, 1, 1, 1, QtCore.Qt.AlignRight) self.mainLayout.setRowStretch(6, 10)
def __init__(self, Lang): form = QtGui.QFormLayout() self.comboColor = QtGui.QComboBox() self.comboColor.addItems(model.COLORS) form.addRow(Lang.value('PP_Color'), self.comboColor) self.piece_types = sorted(model.FairyHelper.glyphs.iterkeys()) self.comboType = QtGui.QComboBox() self.comboType.addItems( [x + ' (' + model.FairyHelper.glyphs[x]['name'] + ')' for x in self.piece_types]) form.addRow(Lang.value('PP_Type'), self.comboType) vbox = QtGui.QVBoxLayout() vbox.addLayout(form, 1) vbox.addWidget(QtGui.QLabel(Lang.value('PP_Fairy_properties'))) self.checkboxes = [QtGui.QCheckBox(x) for x in model.FAIRYSPECS] for box in self.checkboxes: vbox.addWidget(box) self.mainWidget = QtGui.QWidget() self.mainWidget.setLayout(vbox) super(AddFairyPieceDialog, self).__init__(Lang) self.setWindowTitle(Lang.value('MI_Add_piece'))
def __init__(self): super(DistinctionWidget, self).__init__() hbox = QtGui.QHBoxLayout() self.special = QtGui.QCheckBox(Lang.value('DSTN_Special')) hbox.addWidget(self.special) self.lo = QtGui.QSpinBox() hbox.addWidget(self.lo) self.hi = QtGui.QSpinBox() hbox.addWidget(self.hi) self.name = QtGui.QComboBox() self.name.addItems( ['X' * 15 for i in DistinctionWidget.names]) # spacers hbox.addWidget(self.name) self.comment = QtGui.QLineEdit() hbox.addWidget(self.comment) hbox.addStretch(1) self.setLayout(hbox) self.special.stateChanged.connect(self.onChanged) self.name.currentIndexChanged.connect(self.onChanged) self.lo.valueChanged.connect(self.onChanged) self.hi.valueChanged.connect(self.onChanged) self.comment.textChanged.connect(self.onChanged) Mainframe.sigWrapper.sigModelChanged.connect(self.onModelChanged) Mainframe.sigWrapper.sigLangChanged.connect(self.onLangChanged) self.skip_model_changed = False self.onLangChanged()
def add_entry(self,path): c = QtGui.QCheckBox(path) self.layout.addWidget(c) self.checks.append(c) self.checks[-1].setChecked(True)
def add_clusters(self, element, x_mean, y_mean, z_mean): c = QtGui.QCheckBox(str(element[0]+1)) self.layout_grid.addWidget(c,self.n_lines,4,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(x_mean)),self.n_lines,0,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(y_mean)),self.n_lines,1,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(z_mean)),self.n_lines,2,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(element[1])),self.n_lines,3,1,1) self.n_lines +=1 self.checks.append(c) self.checks[-1].setChecked(True)
def add_clusters(self, element, x_mean, y_mean): c = QtGui.QCheckBox(str(element[0]+1)) self.layout_grid.addWidget(c,self.n_lines,3,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(x_mean)),self.n_lines,0,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(y_mean)),self.n_lines,1,1,1) self.layout_grid.addWidget(QtGui.QLabel(str(element[1])),self.n_lines,2,1,1) self.n_lines +=1 self.checks.append(c) self.checks[-1].setChecked(True)
def __init__(self, window): super().__init__(window) self.window = window self.setWindowTitle('Enter movie info') vbox = QtGui.QVBoxLayout(self) grid = QtGui.QGridLayout() grid.addWidget(QtGui.QLabel('Byte Order:'), 0, 0) self.byte_order = QtGui.QComboBox() self.byte_order.addItems(['Little Endian (loads faster)', 'Big Endian']) grid.addWidget(self.byte_order, 0, 1) grid.addWidget(QtGui.QLabel('Data Type:'), 1, 0) self.dtype = QtGui.QComboBox() self.dtype.addItems(['float16', 'float32', 'float64', 'int8', 'int16', 'int32', 'uint8', 'uint16', 'uint32']) grid.addWidget(self.dtype, 1, 1) grid.addWidget(QtGui.QLabel('Frames:'), 2, 0) self.frames = QtGui.QSpinBox() self.frames.setRange(1, 1e9) grid.addWidget(self.frames, 2, 1) grid.addWidget(QtGui.QLabel('Height:'), 3, 0) self.movie_height = QtGui.QSpinBox() self.movie_height.setRange(1, 1e9) grid.addWidget(self.movie_height, 3, 1) grid.addWidget(QtGui.QLabel('Width'), 4, 0) self.movie_width = QtGui.QSpinBox() self.movie_width.setRange(1, 1e9) grid.addWidget(self.movie_width, 4, 1) self.save = QtGui.QCheckBox('Save info to yaml file') self.save.setChecked(True) grid.addWidget(self.save, 5, 0, 1, 2) vbox.addLayout(grid) hbox = QtGui.QHBoxLayout() vbox.addLayout(hbox) # OK and Cancel buttons self.buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) vbox.addWidget(self.buttons) self.buttons.accepted.connect(self.accept) self.buttons.rejected.connect(self.reject) # static method to create the dialog and return (date, time, accepted)
def __init__(self, window): super().__init__(window) self.window = window self.setWindowTitle('Contrast') self.resize(200, 0) self.setModal(False) grid = QtGui.QGridLayout(self) black_label = QtGui.QLabel('Black:') grid.addWidget(black_label, 0, 0) self.black_spinbox = QtGui.QSpinBox() self.black_spinbox.setKeyboardTracking(False) self.black_spinbox.setRange(0, 999999) self.black_spinbox.valueChanged.connect(self.on_contrast_changed) grid.addWidget(self.black_spinbox, 0, 1) white_label = QtGui.QLabel('White:') grid.addWidget(white_label, 1, 0) self.white_spinbox = QtGui.QSpinBox() self.white_spinbox.setKeyboardTracking(False) self.white_spinbox.setRange(0, 999999) self.white_spinbox.valueChanged.connect(self.on_contrast_changed) grid.addWidget(self.white_spinbox, 1, 1) self.auto_checkbox = QtGui.QCheckBox('Auto') self.auto_checkbox.setTristate(False) self.auto_checkbox.setChecked(True) self.auto_checkbox.stateChanged.connect(self.on_auto_changed) grid.addWidget(self.auto_checkbox, 2, 0, 1, 2) self.silent_contrast_change = False
def __init__(self, *args, **kwargs): QtGui.QCheckBox.__init__(self, *args, **kwargs) self.setSizePolicy(QtGui.QSizePolicy.Maximum, QtGui.QSizePolicy.Minimum) self.square = QtCore.QRectF() self.setChecked(True)
def __init__(self, data, num, parent=None): super(Bit_container, self).__init__(parent) self.data = data self.setFrameStyle(gui.QFrame.Sunken) self.setFrameShape(gui.QFrame.Box) self.setFixedWidth(130) self.layout = gui.QVBoxLayout() cblayout = gui.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 = gui.QCheckBox() cb.setEnabled(False) if databin[i] == "1": cb.setChecked(True) self.checkboxes.append(cb) cblayout.addWidget(cb) cb.setStyleSheet("color: green") label = gui.QLabel(str(num + 1).zfill(2)) label.setAlignment(core.Qt.AlignHCenter | core.Qt.AlignVCenter) self.labelvaluehex = gui.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)
def __init__(self, dataitem, parent=None): super(numericListPanel, self).__init__(parent) self.setFrameStyle(gui.QFrame.Sunken) self.setFrameShape(gui.QFrame.Box) self.data = dataitem layoutv = gui.QVBoxLayout() layout = gui.QGridLayout() labelnob = gui.QLabel(_("Number of bits")) lablelsigned = gui.QLabel(_("Signed")) newitem = gui.QPushButton(_("Add item")) delitem = gui.QPushButton(_("Del item")) newitem.clicked.connect(self.add_item) delitem.clicked.connect(self.def_item) layout.addWidget(labelnob, 0, 0) layout.addWidget(lablelsigned, 1, 0) layout.addWidget(newitem, 2, 0) layout.addWidget(delitem, 2, 1) self.inputnob = gui.QSpinBox() self.inputnob.setRange(1, 32) self.inputsigned = gui.QCheckBox() layout.addWidget(self.inputnob, 0, 1) layout.addWidget(self.inputsigned, 1, 1) layoutv.addLayout(layout) self.itemtable = gui.QTableWidget() self.itemtable.setRowCount(1) self.itemtable.setColumnCount(2) self.itemtable.verticalHeader().hide() self.itemtable.setSelectionBehavior(gui.QAbstractItemView.SelectRows) self.itemtable.setSelectionMode(gui.QAbstractItemView.SingleSelection) layoutv.addWidget(self.itemtable) self.setLayout(layoutv) self.init()
def __init__(self,node): QtGui.QCheckBox.__init__(self) self.stateChanged.connect(self.changed) self.node = node
def __init__(self, *args, **kwargs): super(H5Dialog, self).__init__(*args, **kwargs) self.setNameFilter("hdf5 Files (*.h5 *.hdf *.hdf5)") if "directory" not in kwargs.keys(): self.setDirectory('.') # get the grid layout of the dialog # TODO: make nice sub layout layout = self.layout() self.chk_branches = QtGui.QCheckBox("Branch Masks") self.chk_freehand = QtGui.QCheckBox("Freehand Masks") self.chk_pixel = QtGui.QCheckBox("Pixel Masks") self.chk_circles = QtGui.QCheckBox("Circle Masks") self.chk_traces = QtGui.QCheckBox("Traces") self.chk_data = QtGui.QCheckBox("Data") self.chk_mask = QtGui.QCheckBox("Threshold Mask") self.chk_segmentation = QtGui.QCheckBox("Segmentation") layout.addWidget(self.chk_branches) layout.addWidget(self.chk_freehand) layout.addWidget(self.chk_circles) layout.addWidget(self.chk_pixel) layout.addWidget(self.chk_traces) layout.addWidget(self.chk_mask) layout.addWidget(self.chk_data) layout.addWidget(self.chk_segmentation)
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)
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)
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]
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)
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 )