projects
/
naja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
7372709
)
Allow centre=True
author
Neil
<neil@dip.sun.ac.za>
Fri, 16 May 2014 22:51:10 +0000
(
00:51
+0200)
committer
Neil
<neil@dip.sun.ac.za>
Fri, 16 May 2014 23:06:11 +0000
(
01:06
+0200)
naja/widgets/text.py
patch
|
blob
|
history
diff --git
a/naja/widgets/text.py
b/naja/widgets/text.py
index 7c1039ff4d2ef517f019c7d52b71f8a75c0149ea..02de03fd955be7f9b45324077df7390daa6a8dcd 100644
(file)
--- a/
naja/widgets/text.py
+++ b/
naja/widgets/text.py
@@
-40,7
+40,8
@@
class TextWidget(Widget):
VIEW_PORT_DY = 50
def __init__(self, pos, text, fontname=None, fontsize=None,
VIEW_PORT_DY = 50
def __init__(self, pos, text, fontname=None, fontsize=None,
- colour=None, unselectable_colour=None, view_port=None):
+ colour=None, unselectable_colour=None, view_port=None,
+ centre=False):
super(TextWidget, self).__init__(pos)
self.text = text
super(TextWidget, self).__init__(pos)
self.text = text
@@
-52,6
+53,8
@@
class TextWidget(Widget):
self.unselectable_colour = unselectable_colour
self.view_port = (
pygame.Rect((0, 0), view_port) if view_port is not None else None)
self.unselectable_colour = unselectable_colour
self.view_port = (
pygame.Rect((0, 0), view_port) if view_port is not None else None)
+ self.centre = centre
+ self.centre_pos = pos
def render_line(self, text):
colour = self.colour
def render_line(self, text):
colour = self.colour
@@
-68,6
+71,9
@@
class TextWidget(Widget):
self.size = self.view_port.size
else:
self.size = self.surface.get_rect().size
self.size = self.view_port.size
else:
self.size = self.surface.get_rect().size
+ if self.centre:
+ self.pos = (self.centre_pos[0] - self.size[0] // 2,
+ self.centre_pos[1])
def prepare(self):
self.font = resources.get_font(self.fontname, self.fontsize)
def prepare(self):
self.font = resources.get_font(self.fontname, self.fontsize)