Merge lp:~mcfletch/simplegc/suggestions into lp:simplegc

Proposed by Mike C. Fletcher
Status: Merged
Approved by: Sam Bull
Approved revision: no longer in the source branch.
Merged at revision: 244
Proposed branch: lp:~mcfletch/simplegc/suggestions
Merge into: lp:simplegc
Diff against target: 158 lines (+47/-50)
3 files modified
docs/tutorial.rst (+19/-48)
example/helloworld.py (+27/-0)
sgc/surface.py (+1/-2)
To merge this branch: bzr merge lp:~mcfletch/simplegc/suggestions
Reviewer Review Type Date Requested Status
Sam Bull Pending
Review via email: mp+107644@code.launchpad.net

Description of the change

Two suggested alterations for the docs:

 * keep the executable code as a separate file and use a literal include, that means a user can just run python helloworld.py to see the results of the code
 * given how brief the text is, it might be better to use comments?

I also merged in the fix for the __slots__ being ignored (old-style classes don't respect them).

To post a comment you must log in.
Revision history for this message
Mike C. Fletcher (mcfletch) wrote :

Oh, and you didn't check in 5 images for the docs:

/mnt/homevar/var/pylive/src/OpenGL-dev/simplegc/docs/sgc.widgets.rst:None: WARNING: image file not readable: images/fps_counter.png
/mnt/homevar/var/pylive/src/OpenGL-dev/simplegc/docs/sgc.widgets.rst:None: WARNING: image file not readable: images/input_box.png
/mnt/homevar/var/pylive/src/OpenGL-dev/simplegc/docs/sgc.widgets.rst:None: WARNING: image file not readable: images/label.png
/mnt/homevar/var/pylive/src/OpenGL-dev/simplegc/docs/sgc.widgets.rst:None: WARNING: image file not readable: images/radio_button.png
/mnt/homevar/var/pylive/src/OpenGL-dev/simplegc/docs/sgc.widgets.rst:None: WARNING: image file not readable: images/dialog.png

HTH

Revision history for this message
Sam Bull (dreamsorcerer) wrote :

The other widgets are not rendering very well on a white background, due to the transparency problems. They are currently just serving as reminders for me to add the other images once I've fixed the transparency stuff.

lp:~mcfletch/simplegc/suggestions updated
237. By Sam Bull

Allow widgets to override label behaviour.

238. By Sam Bull

Fix border not padding correctly in Container.

239. By Sam Bull

Changed get_size() calls.

240. By Sam Bull

Fix flashing during fade on dialog window.

241. By Sam Bull

Changed from rendering text to using size() for speed optimisation.

242. By Sam Bull

Improved speed and accuracy of calculating selectable labels. Thanks to Weeble for doing the research.

243. By Sam Bull

Improved accuracy of cursor position when characters are not mono-width in input box. Thanks to Weeble for doing the research.

244. By Sam Bull

Merged changes to tutorial.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/tutorial.rst'
2--- docs/tutorial.rst 2012-05-27 08:21:03 +0000
3+++ docs/tutorial.rst 2012-05-28 14:45:23 +0000
4@@ -7,60 +7,34 @@
5 Here is a simple example of using the SGC toolkit.
6 It is described in more detail below.
7
8-::
9-
10- import pygame
11- from pygame.locals import *
12-
13- import sgc
14- from sgc.locals import *
15-
16- pygame.display.init()
17- pygame.font.init()
18-
19- screen = sgc.surface.Screen((640,480))
20-
21- clock = pygame.time.Clock()
22-
23- btn = sgc.Button(label="Clicky", pos=(100, 100))
24- btn.add(0)
25-
26- while True:
27- time = clock.tick(30)
28-
29- for event in pygame.event.get():
30- sgc.event(event)
31- if event.type == QUIT:
32- exit()
33-
34- screen.fill((0,0,0))
35- sgc.update(time)
36- pygame.display.flip()
37+.. literalinclude:: ../example/helloworld.py
38+ :language: python
39+ :linenos:
40+ :emphasize-lines: 1-2,10,14-15,21,26
41+
42+The file is available as ``example/helloworld.py`` in the
43+source distribution.
44
45 Breakdown
46 +++++++++
47-::
48
49- import sgc
50- from sgc.locals import *
51+.. literalinclude:: ../example/helloworld.py
52+ :lines: 1-2
53
54 Here we import everything we need from sgc.
55
56 ----------
57
58-::
59-
60- pygame.display.init()
61- pygame.font.init()
62+.. literalinclude:: ../example/helloworld.py
63+ :lines: 4-8
64
65 The toolkit needs to have the display and font modules initialised;
66 ``pygame.init()`` would suffice.
67
68 ----------
69
70-::
71-
72- screen = sgc.surface.Screen((640,480))
73+.. literalinclude:: ../example/helloworld.py
74+ :lines: 10
75
76 This creates a screen object, in much the same way as
77 ``pygame.display.set_mode()`` does. This is required for the toolkit to
78@@ -68,10 +42,9 @@
79
80 ----------
81
82-::
83+.. literalinclude:: ../example/helloworld.py
84+ :lines: 14-15
85
86- btn = sgc.Button(label="Clicky", pos=(100, 100))
87- btn.add(0)
88
89 This creates a new button widget, setting the label to 'Clicky' and the top-left
90 position of the widget to (100,100). The other line adds the button to the
91@@ -81,18 +54,16 @@
92
93 ----------
94
95-::
96-
97- sgc.event(event)
98+.. literalinclude:: ../example/helloworld.py
99+ :lines: 21
100
101 This function sends an event through to the toolkit. This function should
102 appear in your event loop in order to handle all incoming events.
103
104 ----------
105
106-::
107-
108- sgc.update(time)
109+.. literalinclude:: ../example/helloworld.py
110+ :lines: 26
111
112 This function should be called on each frame before the screen is updated.
113 It should be given the time passed since the last frame; this is usually
114
115=== added file 'example/helloworld.py'
116--- example/helloworld.py 1970-01-01 00:00:00 +0000
117+++ example/helloworld.py 2012-05-28 14:45:23 +0000
118@@ -0,0 +1,27 @@
119+import sgc
120+from sgc.locals import *
121+
122+import pygame
123+from pygame.locals import *
124+
125+pygame.display.init()
126+pygame.font.init()
127+
128+screen = sgc.surface.Screen((640,480))
129+
130+clock = pygame.time.Clock()
131+
132+btn = sgc.Button(label="Clicky", pos=(100, 100))
133+btn.add(0)
134+
135+while True:
136+ time = clock.tick(30)
137+
138+ for event in pygame.event.get():
139+ sgc.event(event)
140+ if event.type == QUIT:
141+ exit()
142+
143+ screen.fill((0,0,0))
144+ sgc.update(time)
145+ pygame.display.flip()
146
147=== modified file 'sgc/surface.py'
148--- sgc/surface.py 2012-03-18 22:40:53 +0000
149+++ sgc/surface.py 2012-05-28 14:45:23 +0000
150@@ -12,8 +12,7 @@
151
152 import widgets._locals
153
154-class Screen():
155-
156+class Screen(object):
157 """
158 Class for the screen.
159

Subscribers

People subscribed via source and target branches