summaryrefslogtreecommitdiffstats
path: root/python/pykde/examples/pykde-sampler/basic_widgets
diff options
context:
space:
mode:
Diffstat (limited to 'python/pykde/examples/pykde-sampler/basic_widgets')
-rw-r--r--python/pykde/examples/pykde-sampler/basic_widgets/__init__.py17
-rw-r--r--python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py42
-rw-r--r--python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py53
3 files changed, 112 insertions, 0 deletions
diff --git a/python/pykde/examples/pykde-sampler/basic_widgets/__init__.py b/python/pykde/examples/pykde-sampler/basic_widgets/__init__.py
new file mode 100644
index 00000000..2442375d
--- /dev/null
+++ b/python/pykde/examples/pykde-sampler/basic_widgets/__init__.py
@@ -0,0 +1,17 @@
+labelText = 'Widgets'
+iconName = 'about_kde'
+
+helpText = """KDE provides a large set of basic widgets for application use.
+Select the children of this item to see for yourself."""
+
+from qt import QFrame, QVBoxLayout
+from kdeui import KTextEdit
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ layout = QVBoxLayout(self)
+ self.text = KTextEdit(helpText, '', self)
+ layout.addWidget(self.text, 1)
+ layout.addStretch(1)
diff --git a/python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py b/python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py
new file mode 100644
index 00000000..aa36de52
--- /dev/null
+++ b/python/pykde/examples/pykde-sampler/basic_widgets/datepicker.py
@@ -0,0 +1,42 @@
+from qt import QFrame, QStringList, QVBoxLayout, SIGNAL, QLabel, QSizePolicy, Qt
+from qttable import QTable
+from kdeui import KTextEdit, KDatePicker, KDateWidget
+
+
+labelText = 'KDatePicker'
+iconName = 'date'
+helpText = """A date selection widget.
+
+Provides a widget for calendar date input.
+
+Different from the previous versions, it now emits two types of
+signals, either dateSelected() or dateEntered() (see documentation for
+both signals).
+
+A line edit has been added in the newer versions to allow the user to
+select a date directly by entering numbers like 19990101 or 990101.
+"""
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.dateDisplay = KDateWidget(self)
+
+ self.dateDisplay.setSizePolicy(QSizePolicy(QSizePolicy.Maximum,
+ QSizePolicy.Maximum))
+
+ self.datePicker = KDatePicker(self)
+
+ layout = QVBoxLayout(self)
+ layout.addWidget(self.help, 1)
+ layout.addWidget(self.datePicker, 0, Qt.AlignHCenter)
+ layout.addStretch(1)
+
+ self.other = QLabel('Selected Date:', self)
+ layout.addWidget(self.other, 0)
+ layout.addWidget(self.dateDisplay, 2)
+
+ self.connect(self.datePicker, SIGNAL('dateChanged(QDate)'),
+ self.dateDisplay.setDate)
+
diff --git a/python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py b/python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py
new file mode 100644
index 00000000..aa35b53f
--- /dev/null
+++ b/python/pykde/examples/pykde-sampler/basic_widgets/historycombo.py
@@ -0,0 +1,53 @@
+from qt import Qt, QFrame, QHBoxLayout, QVBoxLayout, QStringList, QLabel, \
+ SIGNAL, SLOT
+from kdeui import KHistoryCombo, KTextEdit
+
+
+iconName = 'history'
+labelText = 'KHistoryCombo'
+docParts = ('kdeui', 'KHistoryCombo')
+helpText = ('An example of the KHistoryCombo widget.'
+ '\n\n'
+ 'Completion is enabled via the setHistoryItems call; when the second '
+ 'parameter is True, matching items from the list appear as you type.'
+ '\n\n'
+ 'The activated signal is connected to the addToHistory '
+ 'slot to automatically add new items.')
+
+
+historyText = 'a quick brown fox jumps over the lazy dog'
+
+
+class MainFrame(QFrame):
+ def __init__(self, parent=None):
+ QFrame.__init__(self, parent)
+ self.help = KTextEdit(helpText, '', self)
+ self.historyCombo = KHistoryCombo(self)
+
+ self.historySelectionLabel = QLabel('Selected value: ', self)
+ self.historySelection = QLabel('(none)', self)
+
+ items = QStringList()
+ for item in historyText.split():
+ items.append(item)
+ self.historyCombo.setHistoryItems(items, True)
+
+ layout = QVBoxLayout(self, 4)
+ layout.addWidget(self.help, 3)
+ layout.addStretch(1)
+ selectionLayout = QHBoxLayout(layout, 4)
+ selectionLayout.addWidget(self.historySelectionLabel, 1)
+ selectionLayout.addWidget(self.historySelection, 10, Qt.AlignLeft)
+ layout.addWidget(self.historyCombo, 0)
+ layout.addStretch(10)
+
+ self.connect(self.historyCombo, SIGNAL('activated(const QString& )'),
+ self.historyCombo, SLOT('addToHistory(const QString&)'))
+ self.connect(self.historyCombo, SIGNAL('cleared()'),
+ self.historyCleared)
+ self.connect(self.historyCombo, SIGNAL('activated(const QString &)'),
+ self.historySelection.setText)
+
+ def historyCleared(self):
+ print 'History combo cleared.'
+