diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /python/pykde/examples/pykde-sampler/dialogs/input.py | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'python/pykde/examples/pykde-sampler/dialogs/input.py')
-rw-r--r-- | python/pykde/examples/pykde-sampler/dialogs/input.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/python/pykde/examples/pykde-sampler/dialogs/input.py b/python/pykde/examples/pykde-sampler/dialogs/input.py new file mode 100644 index 00000000..30edc6fb --- /dev/null +++ b/python/pykde/examples/pykde-sampler/dialogs/input.py @@ -0,0 +1,87 @@ +iconName = 'editclear' +labelText = 'KInputDialog' + +from qt import QFrame, QGridLayout, QLabel, QStringList, SIGNAL +from kdecore import i18n +from kdeui import KPushButton, KInputDialog, KTextEdit + + +helpText = ("KInputDialog allows the programmer to display a simple dialog to " + "request a bit of text, an integer value, a double value, or a " + "list item from the user.") + + +class MainFrame(QFrame): + items = ['Apples', 'Bananas', 'Mangos', 'Oranges', 'Pears', ] + + def __init__(self, parent=None): + QFrame.__init__(self, parent) + self.help = KTextEdit(helpText, '', self) + + layout = QGridLayout(self, 5, 2, 4) # five rows, two cols, four px spacing + layout.setRowStretch(0, 10) + layout.setColStretch(1, 10) + layout.addMultiCellWidget(self.help, 0, 1, 0, 1) + + button = KPushButton(i18n('Get Text'), self) + self.connect(button, SIGNAL('clicked()'), self.getText) + self.getTextLabel = QLabel('text value', self) + layout.addWidget(button, 2, 0) + layout.addWidget(self.getTextLabel, 2, 1) + layout.setRowStretch(2, 0) + + button = KPushButton(i18n('Get Integer'), self) + self.connect(button, SIGNAL('clicked()'), self.getInt) + self.getIntLabel = QLabel('0', self) + layout.addWidget(self.getIntLabel, 3, 1) + layout.addWidget(button, 3, 0) + layout.setRowStretch(3, 0) + + button = KPushButton(i18n('Get Double'), self) + self.connect(button, SIGNAL('clicked()'), self.getDouble) + self.getDoubleLabel = QLabel('0.0', self) + layout.addWidget(self.getDoubleLabel, 4, 1) + layout.addWidget(button, 4, 0) + layout.setRowStretch(4, 0) + + button = KPushButton(i18n('Get Item'), self) + self.connect(button, SIGNAL('clicked()'), self.getItem) + self.getItemLabel = QLabel(self.items[0], self) + layout.addWidget(button, 5, 0) + layout.addWidget(self.getItemLabel, 5, 1) + layout.setRowStretch(5, 0) + + def getText(self): + title = 'KInputDialog.getText Dialog' + label = 'Enter some text:' + default = self.getTextLabel.text() + value, accepted = KInputDialog.getText(title, label, default) + if accepted: + self.getTextLabel.setText(value) + + def getInt(self): + title = 'KInputDialog.getInteger Dialog' + label = 'Enter an integer:' + default = int('%s' % self.getIntLabel.text()) + value, accepted = KInputDialog.getInteger(title, label, default) + if accepted: + self.getIntLabel.setText('%s' % value) + + def getDouble(self): + title = 'KInputDialog.getDouble Dialog' + label = 'Enter a double:' + default = float('%s' % self.getDoubleLabel.text()) + value, accepted = KInputDialog.getDouble(title, label, default, -10.0, 10.0) + if accepted: + self.getDoubleLabel.setText('%s' % value) + + def getItem(self): + title = 'KInputDialog.getItem Dialog' + label = 'Select an item:' + current = self.items.index('%s' % self.getItemLabel.text()) + selections = QStringList() + for item in self.items: + selections.append(item) + value, accepted = KInputDialog.getItem(title, label, selections, current) + if accepted: + self.getItemLabel.setText('%s' % value) |