summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore 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 @@
1all:
2 install -d $(OPIEDIR)/bin/python/
3 install -m 0755 *.py $(OPIEDIR)/bin/python/
4
5
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 @@
1 config PYTHON_EXMAPLES
2 boolean "Build Python Examples"
3 default "n"
4 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 @@
1#!pyquicklauncher
2# -*- coding: iso8859-15 -*-
3#--------------------------------------------------------------------------------------------------#
4""" =. This file is part of the PyQt examples collection
5 .=l. Copyright (C) 2004 Michael Lauer <mickey@Vanille.de>
6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; General Public License for more
20++=   -.     .`     .: details.
21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the
23  -_. . .   )=.  = GNU General Public License along with
24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28"""
29#--------------------------------------------------------------------------------------------------#
30
31#--------------------------------------------------------------------------------------------------#
32__version__ = "1.0.0"
33__author__ = "Michael 'Mickey' Lauer <mickey@Vanille.de>"
34__license__ = "GPL"
35#--------------------------------------------------------------------------------------------------#
36
37import sys
38from qt import *
39from qtpe import *
40
41#--------------------------------------------------------------------------------------------------#
42class SimpleWidget( QWidget ):
43 """A simple main widget with a label and a push button."""
44
45 def __init__( self, parent, name = "SimpleWidget" ):
46 """Construct me."""
47 QWidget.__init__( self, parent, name )
48
49 #
50 # Set the caption of this toplevel widget.
51 # Encapsulate all user visible strings into self.tr to prepare for localization
52 #
53 self.setCaption( self.tr( "Simple Example Application" ) )
54
55 #
56 # A simple vertical layout.
57 # Either call layout.setAutoAdd( True ) or use layout.addWidget( wid ) to manually add widgets
58 #
59 layout = QVBoxLayout( self )
60 layout.setSpacing( 8 )
61 layout.setMargin( 11 )
62
63 #
64 # Create a label as child of this widget (self) and add it to the layout.
65 # A Qt object will be deleted when its parent is being deleted, hence it is not
66 # necessary to keep the reference for this widget except you want to change some
67 # of its attributes later, i.e. set a different text later on
68 # via label.setText( self.tr( "newText" ) )
69 #
70 label = QLabel( self.tr( "Click on the Button and watch what happens!" ), self )
71 layout.addWidget( label )
72
73 #
74 # Add a push button as child of this widget and add it to the layout.
75 #
76 button = QPushButton( self.tr( "Quit!" ), self )
77 layout.addWidget( button )
78
79 #
80 # Define what happens, when the user clicks on the button.
81 # This is being done by a signal-slot connection using QObject.connect.
82 # We could also have connected a SIGNAL to a SIGNAL or directly to the
83 # the application object slot quit().
84 #
85 QObject.connect( button, SIGNAL( "clicked()" ), self.slotQuitAppRequested )
86
87 def slotQuitAppRequested( self ):
88 """Leave the application when a user clicks on the button."""
89 #
90 # Leave the main loop by calling the quit() method of the application object
91 #
92 qApp.quit()
93
94#--------------------------------------------------------------------------------------------------#
95
96#
97# Create the one and only application object.
98# For plain Qt applications, use QApplication, for Qtopia/Opie applications, use QPEApplication
99#
100app = QPEApplication( sys.argv[1:] )
101#
102# Construct an instance of our main widget. Since it is the top level widget, is has no parent (None).
103#
104mw = SimpleWidget( None )
105#
106# Show the main widget. For plain Qt applications you should use app.setMainWidget( mw ) and mw.show()
107#
108app.showMainWidget( mw )
109#
110# Enter the event processing by calling the event loop which is implemented in the application object.
111#
112app.exec_loop()