PDA

View Full Version : Something wrong with script


rothgar
2005-01-08, 02:00
hey everyone, i'm definatly new to scripting python and have been reading these forums for a little while now. i was trying to just lay out a user interface for a script im trying to write but it doesnt work. i really just took the great tutorial by alex and alexpoet and was making sure it would show up like i wanted it to. but when i try to run it nothing happens. just wondering if anyone can check out the script and see maybe where the error is. and i also know there was a way to see why the script was failing but i cant remember where that was in the forums. (sorta like a debug screen) if anyone can help that would be great.


import xbmc, xbmcgui
try: emulating = xbmcgui.emulating
except: emulating = false

#buttons that are defined
action_previous_menu = 10
action_select_item = 7
action_parent_dir = 9

class myclass(xbmcgui.window):
def (self):
if emulating: xbmcgui.window.(self)
self.addcontrol(xbmcgui.controlimage(0,0,720,480, background2.png))
self.stractioninfo = xbmcgui.controllabel(100,200,200,200,"","font13","0xffff00ff&quot
;)
self.addcontrol(self.stractioninfo)
self.stractioninfo.setlabel("push back to quit.")

#making button
self.button0 = xbmcgui.controlbutton(250, 150, 120, 30, "try")
self.addcontrol(self.button0)
self.setfocus(self.button0)

#make server list
self.list = xbmcgui.controllist(300, 250, 200, 200)
self.addcontrol(self.list)
items = ["sever 1", "sever 2", "server 3", "server 4"]
for item in items:
self.list.additem(item)

#keyboard
self.outputlabel = xbmcgui.controllabel(100, 300, 200, 200)
self.addcontrol(self.outputlabel)
keyboard = xbmc.keyboard("entered text")
keyboard.domodal()
if(keyboard.isconfirmed()):
self.outputlabel.setlabel(keyboard.gettext())
else:
self.outputlabel.setlabel("user canceled")

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

def oncontrol(self, control):
if control == self.button0:
self.message("test")
if control == self.list:
item = self.list.getselecteditem()
self.message( "join" + item.getlabel())

def message(self, message):
dialog = xbmcgui.dialog()
dialog.ok("does not really work!!", message)

def localinfo(self)
infoip = xbmc.getipaddress()
self.stripaddress = xbmcgui.controllabel(700, 460, 200, 200, "", "font13", "0xffffffff")
self.addcontrol(self.stripaddress)
self.stripaddress.setlabel(infoip)

mydisplay = myclass()
mydisplay.domodal()
del mydisplay

umm...the tab doesnt seem to work but i really dont think that is where the error is. i've checked as much as i know but it just doesnt do anything. thanks in advance.

Asteron
2005-01-09, 01:15
what do you mean by "nothing happens" exactly?
if the script doesnt run at all you can press the white button and see the script output... there will be a pertinent message there.

if the system locks up you have a mispelled var somewhere (though i didnt see it). i dont see any obvious problems in the code.

rothgar
2005-01-09, 04:05
all that happens is [running...] shows up next to the script like usual and the xbox just sits there. no lock up, nothing. i can run other scripts right after i try it and i can run scripts before i try it. it doesnt do anything besides show [running...] thanks for the key on the output though. ill try that.

solexalex
2005-01-10, 00:49
edit : i deleted all my post because some words were missing every time... i don't know what happen with this board tonight...

Asteron
2005-01-11, 15:41
try adding
self.show()
at the bottom of the windows constructor.

windows are invis until this is called.

solexalex
2005-01-11, 19:31
are you sure ? i disagree...

the end of his script should show the window. i do this way every times in my scripts...


i think there is an error... like a majuscule or minuscule (i'm not sure of these word as english words...)
a <> a
b <> b

maybe should you give us a link to donwload your script cause the forum is very buggy these times....

Asteron
2005-01-12, 05:17
are you sure ? i disagree...
i'm still voting for self.show()... i think the domodal() call would just trap the input but self.show() is what makes it visible.

this is my guess though but whatever it does he needs it.
i do that in my script, it is done in aqtbrowser... plenty of others too i think... but not in this one.

-ast

solexalex
2005-01-12, 19:14
so both of our solutions are working.

all the scripts i made works like this one is made (as for the window stuff)

solexalex
2005-01-12, 19:21
you can try this one.
it is one of mines (totaly french)
http://xstreampack.free.fr/canal%20plus.rar
you can check the code :
asteron for the windows stuff
rothgar for help, if it can help

Asteron
2005-01-12, 21:47
hmmmm.... maybe self.show() is needed after the gui is locked? i do that in mine as i create the buttons and whatnot. maybe that has an effect. ohh well

solexalex
2005-01-15, 00:01
i thought that the show() method was made to select some differents xbmcgui.window class

darkie
2005-01-15, 00:16
k, a bit of explanation then.
window.show() and window.domodal() are not the same.
both will display the window but window.domodal will never return until window.close() is called.
window.show() will show the window and return immidiatly to execute the rest of the script (code below window.show()). *now if there isn't any code below, the script will just end and cleanup all data nicely (including your window).

most of the time i use window.domodal() on the main window, and window.show() on the dialogs

hope this made it a bit clear.

solexalex
2005-01-16, 01:09
very very clear ! thanks a lot darkie

rothgar
2005-01-18, 23:31
thanks for your help guys. i hadn't checked back here for a little while and man i had been missing out.

here is a place you can get my script
script (http://home.apu.edu/~xrothgarx/download/link-test.txt)
feel free to try anything that works and i'll try the suggestions you guys gave. thanks again.

solexalex
2005-01-19, 02:02
hi ! much better like that !!
line 13 :
self.addcontrol(xbmcgui.controlimage(0,0,720,480, background2.png))
quotes are missings around background2.png
self.addcontrol(xbmcgui.controlimage(0,0,720,480, [b]'[/b]background2.png[b]'[/b]))

i haven't seen much more to say...

rothgar
2005-01-21, 09:19
thanks for all your help. i was wondering if this has worked successfully for anyone yet? i am still having problems with it.