5
5
Explore how applications start. Starts applications one after another, waiting for
6
6
each to be closed first.
7
7
'''
8
-
8
+ from __future__ import print_function
9
9
import sys
10
10
import re
11
11
from random import choice
19
19
from kivy .uix .floatlayout import FloatLayout
20
20
# Note that importing FloatLayout causes Kivy to execute, including
21
21
# starting up the Logger and some other messages.
22
- print "** In main program, done with imports"
22
+ print ( "** In main program, done with imports" )
23
23
24
24
class TestBuildApp (App ):
25
25
""" Use build() function to return a widget. """
@@ -28,7 +28,7 @@ def build(self):
28
28
Called after trying to load a .kv file.
29
29
Returns a new Button as a root widget.
30
30
"""
31
- print "** inside build()"
31
+ print ( "** inside build()" )
32
32
return Button (text = 'hello from TestBuildApp' )
33
33
34
34
class TestKVFileApp (App ):
@@ -53,17 +53,17 @@ class TestKVStringApp(App):
53
53
Kivy language string. """
54
54
def build (self ):
55
55
""" Called by kivy run(). """
56
- print "** inside build()"
56
+ print ( "** inside build()" )
57
57
widget = Builder .load_string ("Button:\n text: 'hello from TestKVStringApp'" )
58
- print "** widget built"
58
+ print ( "** widget built" )
59
59
return widget
60
60
61
61
class TestPrebuiltApp (App ):
62
62
""" Use the Builder to create a top level widget at the beginning
63
63
of the Python program, then use a dummy class for that widget.
64
64
This costs a bit more in start-up time. """
65
65
Builder .load_string ("<Prebuilt>\n Button:\n text:'hello from TestPrebuiltApp'" )
66
- print "** in TestPrebuiltApp, class initialization built <Prebuilt>"
66
+ print ( "** in TestPrebuiltApp, class initialization built <Prebuilt>" )
67
67
68
68
class Prebuilt (FloatLayout ):
69
69
""" Empty class to cause setting root to <Prebuilt> tag and
@@ -83,14 +83,14 @@ def print_class(class_name):
83
83
regex = "^(class " + class_name + "\\ b.*?)^\\ S"
84
84
match = re .search (regex , data , flags = re .MULTILINE | re .DOTALL )
85
85
if match :
86
- print match .group (1 )
86
+ print ( match .group (1 ) )
87
87
88
88
# the __name__ idiom executes when run from command line but not from import.
89
89
if __name__ == '__main__' :
90
90
dash = "-" * 40
91
91
92
92
arg = sys .argv [1 ][0 ].lower () if len (sys .argv ) > 1 else "h"
93
- print dash
93
+ print ( dash )
94
94
95
95
if arg == 'r' :
96
96
arg = choice ('bfds' )
@@ -111,22 +111,23 @@ def print_class(class_name):
111
111
print_class ("TestPrebuiltApp" )
112
112
TestPrebuiltApp ().run ()
113
113
else : # help
114
- print """
114
+ print ( """
115
115
This demo runs different application windows based on a command line argument.
116
116
117
117
Try using one of these:
118
118
b - Use build() method to return a widget
119
119
d - Use a kv file from a different directory
120
120
f - Use a kv file with the widget object
121
- s - Use a kiva language string to create the widget.
122
- p - Use prebuilt widget from a kivy string
121
+ p - Use prebuilt widget inside a layout
122
+ s - Use a kiva language string to create the widget
123
123
r - pick one of the demos at random.
124
124
125
125
h - show this help message.
126
126
127
- After closing the application window, this program will exit. While the run() method
128
- does return, kivy cannot run another application.
129
- """
127
+ After closing the application window, this program will exit.
128
+ While the run() method does return, kivy cannot run another
129
+ application window after one has been closed.
130
+ """ )
130
131
131
- print dash
132
- print "This program is gratified to be of use."
132
+ print ( dash )
133
+ print ( "This program is gratified to be of use." )
0 commit comments