コード例 #1
0
class KComboListBox(KEditListBox):
    """
    A KEditListBox with a KComboBox as a custom editor that is not editable.
    See the feature request on kde-devel:
    [http://lists.kde.org/?l=kde-devel&m=120859565230461&w=2]
    """

    def __init__(self, parent, title=''):
        self.combo = KComboBox(True, parent)
        # as only writable comboboxes are allowed, we'll fake an editable first,
        #   reset to another line edit and disable editing afterwards
        self.lineEdit = KLineEdit(parent)
        self.lineEdit.setVisible(False)
        self.connect(self.combo, SIGNAL("activated(const QString &)"),
            self.lineEdit.setText),
        customEditor = KEditListBox.CustomEditor(self.combo)
        customEditor.setLineEdit(self.lineEdit)
        self.combo.setEditable(False)
        KEditListBox.__init__(self, title, customEditor, parent)

    def addItems(self, itemList):
        curIdx = self.combo.currentIndex()
        self.combo.addItems(itemList)
        if curIdx == -1:
            # select first element on first addition
            self.lineEdit.setText(self.combo.currentText())

    def comboBox(self):
        return self.combo
コード例 #2
0
ファイル: widgets.py プロジェクト: Alwnikrotikz/lilykde
def promptText(parent, message, title = None, text="", rx=None, help=None):
    """
    Prompts for a text. Returns None on cancel, otherwise the input string.
    rx = if given, regexp string that the input must validate against
    help = if given, the docbook id in the help menu handbook.
    """
    d = KDialog(parent)
    buttons = KDialog.Ok | KDialog.Cancel
    if help:
        buttons |= KDialog.Help
        d.setHelp(help)
    d.setButtons(KDialog.ButtonCode(buttons))
    if title:
        d.setCaption(title)
    v = KVBox()
    v.setSpacing(4)
    d.setMainWidget(v)
    QLabel(message, v)
    edit = KLineEdit(v)
    if rx:
        edit.setValidator(QRegExpValidator(QRegExp(rx), edit))
    edit.setText(text)
    d.show()
    edit.setFocus()
    if d.exec_():
        return edit.text()
コード例 #3
0
ファイル: dialog.py プロジェクト: lennykey/pRenamer
class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(442, 160)
        self.groupBox = QtGui.QGroupBox(Dialog)
        self.groupBox.setGeometry(QtCore.QRect(50, 10, 354, 121))
        self.groupBox.setObjectName("groupBox")
        self.formLayout = QtGui.QFormLayout(self.groupBox)
        self.formLayout.setObjectName("formLayout")
        self.dPfad = KUrlRequester(self.groupBox)
        self.dPfad.setObjectName("dPfad")
        self.dPfad.setMode(KFile.Mode(2))
        self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.dPfad)
        self.dNeuerName = KLineEdit(self.groupBox)
        self.dNeuerName.setEnabled(True)
        self.dNeuerName.setObjectName("dNeuerName")
        self.formLayout.setWidget(1, QtGui.QFormLayout.LabelRole, self.dNeuerName)
        self.dDateiEndung = QtGui.QLineEdit(self.groupBox)
        self.dDateiEndung.setObjectName("dDateiEndung")
        self.formLayout.setWidget(1, QtGui.QFormLayout.FieldRole, self.dDateiEndung)
        self.groupBox_2 = QtGui.QGroupBox(Dialog)
        self.groupBox_2.setGeometry(QtCore.QRect(50, 80, 351, 64))
        self.groupBox_2.setObjectName("groupBox_2")
        self.horizontalLayout = QtGui.QHBoxLayout(self.groupBox_2)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.dAbbrechen = QtGui.QPushButton(self.groupBox_2)
        self.dAbbrechen.setObjectName("dAbbrechen")
        self.horizontalLayout.addWidget(self.dAbbrechen)
        self.dAusfuehren = QtGui.QPushButton(self.groupBox_2)
        self.dAusfuehren.setDefault(False)
        self.dAusfuehren.setObjectName("dAusfuehren")
        self.horizontalLayout.addWidget(self.dAusfuehren)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retranslateUi(self, Dialog):
        Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
        self.groupBox.setTitle(QtGui.QApplication.translate("Dialog", "Renamer", None, QtGui.QApplication.UnicodeUTF8))
        self.dNeuerName.setText(QtGui.QApplication.translate("Dialog", "Neuer Name", None, QtGui.QApplication.UnicodeUTF8))
        self.dDateiEndung.setText(QtGui.QApplication.translate("Dialog", "Dateiendung", None, QtGui.QApplication.UnicodeUTF8))
        self.dAbbrechen.setText(QtGui.QApplication.translate("Dialog", "Abbrechen", None, QtGui.QApplication.UnicodeUTF8))
        self.dAusfuehren.setText(QtGui.QApplication.translate("Dialog", "Ok", None, QtGui.QApplication.UnicodeUTF8))