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