Multiple windows
#1
i have been trying to get a parent window to open a child window but for the life of me can't get it to work. either i get errors like "finally pops bad exception" or xbmc freezes. here is some stripped down code that causes xbmc to freeze (2004-04-13 build - didn't seem to include a new python dll though):

Quote:import xbmcgui

class mainwin( xbmcgui.window ):
def ( self ):
xbmcgui.window.( self, 9990 )
self.addcontrol( xbmcgui.controlimage( \
0, 0, self.getwidth(), self.getheight(), \
'background.png' ) )
self.addcontrol( xbmcgui.controllabel( \
50, 30, 200, 20, "parent", 'font16', '0xffffffff' ) )

def onaction( self, action ):
try:
if action == 10:
self.close()
elif action == 7:
child = childwin()
child.domodal()
del child

except exception, ex:
traceback.print_exc()
xbmcgui.dialog().ok( "error", str(ex) )

class childwin( xbmcgui.window ):
def ( self ):
xbmcgui.window.( self, 9991 )
self.addcontrol( xbmcgui.controlimage( \
0, 0, self.getwidth(), self.getheight(), \
'background.png' ) )
self.addcontrol( xbmcgui.controllabel( \
50, 30, 200, 20, "child", 'font16', '0xffffffff' ) )

def onaction( self, action ):
try:
if action == 10:
self.close()

except exception, ex:
traceback.print_exc()
xbmcgui.dialog().ok( "error", str(ex) )

parent = mainwin()
parent.domodal()
del parent

if this worked the way i wanted it to, you should be able to open the child by pressing the 'select' button. then you can close the child window by pressing the 'previous menu' button. any ideas?

also, my windows are a bit more complex than this example. i kept getting errors like "an integer is required" when i had additional parameters to the window constructor. i'm guessing that python is expecting the window id to be passed after the self parameter. this is not necessarily true for new window classes derived from xbmcgui.window.

my workaround for this was to not have any parameters for the constructor and then call a method to initialize the window object after it was constructed. the other way should've worked as well but for some reason it didn't.

i also tried using show() and close() with a loop at the end of my script instead of domodal() but it didn't seem to make a difference...

oh, i should add that if i use xbmcgui.dialog() from the parent, it seems to work fine. so xbmcgui.dialog() must be doing something different than xbmcgui.window().
Reply
#2
just out of curiosity madtw what are you exactly working on?
Reply
#3
i found the same thing as you, madtw. what i did instead is to simply draw background.png over the top of everything so you get a fresh screen to draw on. once you've finished with it just removecontrol on everything you've drawn for the child window, including the new background.png to get back to the main window.
Reply
#4
i'm working on the python mythtv frontend. the parent window currently shows you all your recorded shows. the child window will show you the details of the recorded show, plus a screenshot of the show, and give you the option to watch the show, delete it, and maybe edit some of the properties (e.g. auto expire, etc.). i have communication with the mythbackend all sorted out for generating pixmaps, deleting a show, retrieving show info, etc..

i want to use the same idea for browsing the tv schedule... a parent window to display the schedule stored in the myth database and a child window when you select a program. you'll be able to specify if you want to record the program once, everytime on this channel, etc. much like the mythtv web interface.

burriko: thanks for the idea... i guess that'll work. it messes up all my classes but it sounds like a work around.
Reply
#5
you have to be clever, i want to create a file manager like in ava for xbmc with a parent window and about four child windows, but it was not neccessary.

what i plan to do is use a main window. then use image labels to represent the child windows, and use list and text labels to display the directory contents. Image
reading must be magical or something, it's how i find all da anwsers!
------
Ubuntu 8.10 (64bit) | AMD Sempron 2600+ | ATi 2400HD Pro | Asus AE1 Barebone ---- Ubuntu 9.04RC (64bit) | AMD 5000+ | BIOSTAR TA790GX XE w/ ATi 3300
Reply
#6
Quote:if this worked the way i wanted it to, you should be able to open the child by pressing the 'select' button.  then you can close the child window by pressing the 'previous menu' button.  any ideas?
i have an idea Smile.
it was a nasty bug in the python sources but it is fixed now
btw, this is the code i used
Quote:import xbmcgui

action_select_item            = 7
action_previous_menu        = 10

class mainwin(xbmcgui.window):
 def (self):
   self.addcontrol( xbmcgui.controlimage(0, 0, self.getwidth(), self.getheight(), 'background.png' ))
   self.addcontrol( xbmcgui.controllabel(50, 200, 200, 20, "parent", 'font16', '0xffffffff'))

 def onaction(self, action):
   if action == action_previous_menu:
     self.close()
   elif action == action_select_item:
     child = childwin()
     child.domodal()
     del child

class childwin(xbmcgui.window):
 def (self):
   self.addcontrol(xbmcgui.controlimage(0, 0, self.getwidth(), self.getheight(), 'background.png'))
   self.addcontrol(xbmcgui.controllabel(50, 200, 200, 20, "child", 'font16', '0xffffffff'))

 def onaction(self, action):
   if action == action_previous_menu:
     self.close()

parent = mainwin()
parent.domodal()
del parent

edit:
just noticed that this board changed my code
def (self): should be def --init-- (self):



Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.


Image
Reply
#7
(darkie @ april 18 2004,09:00 Wrote:i have an idea Smile.
it was a nasty bug in the python sources but it is fixed now
excellent... i was hoping it was just a bug.

guess i'm waiting for a new build of the python lib... Smile
Reply

Logout Mark Read Team Forum Stats Members Help
Multiple windows0