summaryrefslogtreecommitdiff
path: root/examples/python
Side-by-side diff
Diffstat (limited to 'examples/python') (more/less context) (show whitespace changes)
-rw-r--r--examples/python/.cvsignore1
-rw-r--r--examples/python/Makefile5
-rw-r--r--examples/python/config.in4
-rw-r--r--examples/python/python.pro0
-rw-r--r--examples/python/simple.py112
5 files changed, 122 insertions, 0 deletions
diff --git a/examples/python/.cvsignore b/examples/python/.cvsignore
new file mode 100644
index 0000000..17f883a
--- a/dev/null
+++ b/examples/python/.cvsignore
@@ -0,0 +1 @@
+config.in \ No newline at end of file
diff --git a/examples/python/Makefile b/examples/python/Makefile
new file mode 100644
index 0000000..00dddbc
--- a/dev/null
+++ b/examples/python/Makefile
@@ -0,0 +1,5 @@
+all:
+ install -d $(OPIEDIR)/bin/python/
+ install -m 0755 *.py $(OPIEDIR)/bin/python/
+
+
diff --git a/examples/python/config.in b/examples/python/config.in
new file mode 100644
index 0000000..d174e6b
--- a/dev/null
+++ b/examples/python/config.in
@@ -0,0 +1,4 @@
+ config PYTHON_EXMAPLES
+ boolean "Build Python Examples"
+ default "n"
+ depends ( LIBQPE || LIBQPE-X11 ) && EXAMPLES
diff --git a/examples/python/python.pro b/examples/python/python.pro
new file mode 100644
index 0000000..e69de29
--- a/dev/null
+++ b/examples/python/python.pro
diff --git a/examples/python/simple.py b/examples/python/simple.py
new file mode 100644
index 0000000..0ac9bd2
--- a/dev/null
+++ b/examples/python/simple.py
@@ -0,0 +1,112 @@
+#!pyquicklauncher
+# -*- coding: iso8859-15 -*-
+#--------------------------------------------------------------------------------------------------#
+""" =. This file is part of the PyQt examples collection
+ .=l. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
+           .>+-=
+ _;:,     .>    :=|. This program is free software; you can
+.> <`_,   >  .   <= redistribute it and/or modify it under
+:`=1 )Y*s>-.--   : the terms of the GNU General Public
+.="- .-=="i,     .._ License as published by the Free Software
+ - .   .-<_>     .<> Foundation; either version 2 of the License,
+     ._= =}       : or (at your option) any later version.
+    .%`+i>       _;_.
+    .i_,=:_.      -<s. This program is distributed in the hope that
+     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
+    : ..    .:,     . . . without even the implied warranty of
+    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
+  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.=       =       ; General Public License for more
+++=   -.     .`     .: details.
+ :     =  ...= . :.=-
+ -.   .:....=;==+<; You should have received a copy of the
+  -_. . .   )=.  = GNU General Public License along with
+    --        :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+"""
+#--------------------------------------------------------------------------------------------------#
+
+#--------------------------------------------------------------------------------------------------#
+__version__ = "1.0.0"
+__author__ = "Michael 'Mickey' Lauer <mickey@Vanille.de>"
+__license__ = "GPL"
+#--------------------------------------------------------------------------------------------------#
+
+import sys
+from qt import *
+from qtpe import *
+
+#--------------------------------------------------------------------------------------------------#
+class SimpleWidget( QWidget ):
+ """A simple main widget with a label and a push button."""
+
+ def __init__( self, parent, name = "SimpleWidget" ):
+ """Construct me."""
+ QWidget.__init__( self, parent, name )
+
+ #
+ # Set the caption of this toplevel widget.
+ # Encapsulate all user visible strings into self.tr to prepare for localization
+ #
+ self.setCaption( self.tr( "Simple Example Application" ) )
+
+ #
+ # A simple vertical layout.
+ # Either call layout.setAutoAdd( True ) or use layout.addWidget( wid ) to manually add widgets
+ #
+ layout = QVBoxLayout( self )
+ layout.setSpacing( 8 )
+ layout.setMargin( 11 )
+
+ #
+ # Create a label as child of this widget (self) and add it to the layout.
+ # A Qt object will be deleted when its parent is being deleted, hence it is not
+ # necessary to keep the reference for this widget except you want to change some
+ # of its attributes later, i.e. set a different text later on
+ # via label.setText( self.tr( "newText" ) )
+ #
+ label = QLabel( self.tr( "Click on the Button and watch what happens!" ), self )
+ layout.addWidget( label )
+
+ #
+ # Add a push button as child of this widget and add it to the layout.
+ #
+ button = QPushButton( self.tr( "Quit!" ), self )
+ layout.addWidget( button )
+
+ #
+ # Define what happens, when the user clicks on the button.
+ # This is being done by a signal-slot connection using QObject.connect.
+ # We could also have connected a SIGNAL to a SIGNAL or directly to the
+ # the application object slot quit().
+ #
+ QObject.connect( button, SIGNAL( "clicked()" ), self.slotQuitAppRequested )
+
+ def slotQuitAppRequested( self ):
+ """Leave the application when a user clicks on the button."""
+ #
+ # Leave the main loop by calling the quit() method of the application object
+ #
+ qApp.quit()
+
+#--------------------------------------------------------------------------------------------------#
+
+#
+# Create the one and only application object.
+# For plain Qt applications, use QApplication, for Qtopia/Opie applications, use QPEApplication
+#
+app = QPEApplication( sys.argv[1:] )
+#
+# Construct an instance of our main widget. Since it is the top level widget, is has no parent (None).
+#
+mw = SimpleWidget( None )
+#
+# Show the main widget. For plain Qt applications you should use app.setMainWidget( mw ) and mw.show()
+#
+app.showMainWidget( mw )
+#
+# Enter the event processing by calling the event loop which is implemented in the application object.
+#
+app.exec_loop()