[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Adonthell-devel] User interface open items
From: |
StyxD |
Subject: |
Re: [Adonthell-devel] User interface open items |
Date: |
Wed, 14 Sep 2011 18:18:14 +0200 |
Ok, a little help is needed. I can't get the canvas to show up, while
label is rendered normally. I made a simple test program to reproduce
the error:
----
#!/usr/bin/python
from adonthell import main, gfx, input, base, gui
letsexit = False
def exiter (ev):
if ev.key () == input.keyboard_event.ESCAPE_KEY:
global letsexit
letsexit = True
print 'Exiting...'
return letsexit
class App (main.AdonthellApp):
def main (self):
self.init_modules (self.GFX | self.INPUT)
gfx.screen.set_fullscreen (False)
gfx.screen.set_video_mode (500, 500)
il = input.listener ()
il.connect_keyboard_function (exiter)
input.manager.add (il)
cnv = gui.canvas (10, 10)
img = gfx.create_surface ()
img.resize (10, 10)
img.load_png ('test.png')
cnv.set_drawable (img)
lbl = gui.label (50, 50)
lbl.set_center (True, True)
lbl.set_string ('aaa')
lay = gui.layout (100, 100)
lay.add_child (lbl, 0, 0)
lay.add_child (cnv, 0, 50)
scr = gfx.screen.get_surface ()
print 'Entering main loop...'
while not letsexit:
base.Timer.update ()
input.manager.update ()
scr.fillrect (0, 0, scr.length (), scr.height (), 0)
lay.draw(0, 0, None, scr)
gfx.screen.update ()
return 0
if __name__=='__main__':
theApp = App ()
theApp.init (theApp.main)
----
To run it just make any non-black image, name it test.png and put it
on adonthell's path. Also modify py_gui.i to include canvas.h (I
assumed it didn't by mistake).
By the way, I think I could use adding a move_child method to layout,
so that layout members could change their coordinates without being
removed and readded. Is this acceptable?