Python Dev Tool: XBMC Emulator scripts
#16
hi there poet !,

a word from the novice here (at least at python for xbox, xython perhaps aka jython for java...?)
downloaded your script, and yes it got further and no it didn't run fully succesfully....but you knew that haha.. :evil:

here is the error:
it stops at line 93 where the script calls the setlabel method of the controllabel class:
there is no such thing as an tkobj at the point of calling the setlabel method. if i look at the meteo.py script i see nowhere a method call for the create method of the controllabel class, so i guess that must be going wrong here.
does your class need to have this called prior to doing something with it? if so can you make it so that it checks for existence of the tkobj and if not found then calls the create method.
just thinking outloud here... don't really know what (self, win) properties of create are supposed to do you see..

greetz mikez
:help:
------------
demarrage
traceback (most recent call last):
 file "c:\program files\python 23\_xbox\xbox.media.center.v1.0.final.xbox-htb\scripts\meteo.py", line 93, in ?
   c2.setlabel('prévisions météo')
 file "c:\progra~1\python~1\lib\xbmcgui.py", line 326, in setlabel
   self.tkobj.config(text = self.text)
attributeerror: controllabel instance has no attribute 'tkobj'
----------------
Reply
#17
ack!

sorry, looks like another silly error on my part. i made a change in how i was building the widgets halfway through, and it just seems i didn't fully change label in the right way.

umm...yeah, i can definitely get this fixed tomorrow. i wish i had time to handle it tonight, but i've got commitments for the evening. should be a pretty simple fix, though, once i get into it.

thank you tons for the feedback. i use labels in all my scripts, but i use them in a fairly limited way, so i haven't been getting these crashes--so i wouldn't have even known my emulator was broken without your reports. i really want it to be as useful as possible, so i'm extremely grateful for your replies.

alexpoet
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#18
hi poet !,

thanx a million for the support. no need to loose sleep over this, ya know....
i am just happy someone bothers to look into it..

if i can be of assistance by nagging you with errors , hey thats ok with me :joker:

i'll see it coming.  

thx mikez
Reply
#19
hi poet

what is the requirements to run my scripts om my pc.

i have installed python 2.3
and i have installed your emulator scripts.

do i need dirextx or something?

i tried to start a hello.py script and nothing happend
i started it in command mode python.exe \<path>\hello.py

very bad english here...

by the way were nice script you have done Smile
Livingroom: MacMini Mid summer 2010 4Gb RAM HDMI to Pioneer PDP-434 Plasma 1080i
Kitchen: one xbox 1.1 executer 2.3 chip 120 GB in HD 720p mode
Bedroom: Computer Intel Quad 9400, 8 GB RAM, NVIDIA GTX260, Vista Ultimate 64, Ubuntu 10.10
Reply
#20
okay, get it now. you'll probably find similar errors with other control objects along the way. that's something i hadn't thought of before--altering a control object before adding it to the window.

i had setlabel doing two things: changing the label text stored on the object and updating the gui appearance of the object. if you setlabel before doing an addcontrol, though, there's no gui instance yet.

so i just surrounded the second statement with try:.../except:pass statements, which should take care of the issue (and still properly display the setlabel text once the instance is added.

so, in other words, this was an easy one. :-)

new version's up on my webpage. same name, but with that small change.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#21
hi there,

bin away for awhile and started again on the meteo.py stuff again.
i downloaded the new version of the emulator and am using komodo 3.0
when i run the meteo.py script (ya'know this is the one i am trying to disect..) it fails in the tkinter lib. it looks like it doesn't know how to handle the gif it just stored.
it tries to download a gif from the meteo channel and store it on the q: drive.
this works since i can find the file there and intact.

but the error message is:
tclerror: couldn't recognize data in image file

actually if you look at the error line this is the last line in the meteo.py, so it looks we're almost there..

if you have a clue here  i would be very happy and one step closer to watching the traffic nightmare we have here in holland.. Confused

greet mikez
the total traceback info is:
traceback (most recent call last):
 file "c:\program files\python 23\_xbox\xbox.media.center.v1.0.final.xbox-htb\scripts\meteo.py", line 112, in
   meteo.chargement('meteoj',0,'am')
 file "c:\program files\python 23\_xbox\xbox.media.center.v1.0.final.xbox-htb\scripts\meteo.py", line 58, in chargement
   self.addcontrol(xbmcgui.controlimage(30,120,320,300, localfile))
 file "c:\progra~1\python~1\lib\xbmcgui.py", line 303, in
   self.pic = photoimage(file = filename)
 file "c:\progra~1\python~1\lib\lib-tk\tkinter.py", line 3176, in
   image.(self, 'photo', name, cnf, master, **kw)
 file "c:\progra~1\python~1\lib\lib-tk\tkinter.py", line 3132, in
   self.tk.call(('image', 'create', imgtype, name,) + options)
tclerror: couldn't recognize data in image file "q:\meteoj1.jpg"
Reply
#22
mikez, have you tried the same script on your xbox? that might seem like a silly question, but if it's getting that far, it might already work on the xbox--just not on the emulator.

i don't know why you're having that problem (and can't think of an easy way to fix it). i have, however, seen that error message before. lots.

for some reason, tkinter will just decide it doesn't like an image. i can't get it to read any of the .png files i use for backgrounds, for instance. i have some pretty ugly code in there, in fact, that makes the emulator try to load an identically named gif file if it sees a request for a png, just because pngs will always throw that error (for me).

i haven't seen it with jpg before...but then, i'm not even positive i've ever tried to load a jpg with the emulator. i know python can handle them, but i've been told python handles pngs just fine, too.

it's probably something i'm doing wrong in the emulator, i just haven't found it yet. anyway! the pngs that don't work on the emulator almost always work on the xbox. so give that a shot, and i'll start crawling through the controlimage emulation again, and let you know if i find anything.

alexpoet
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#23
hi

i got it working now and it rock´s :thumbsup:

thanks
Livingroom: MacMini Mid summer 2010 4Gb RAM HDMI to Pioneer PDP-434 Plasma 1080i
Kitchen: one xbox 1.1 executer 2.3 chip 120 GB in HD 720p mode
Bedroom: Computer Intel Quad 9400, 8 GB RAM, NVIDIA GTX260, Vista Ultimate 64, Ubuntu 10.10
Reply
#24
awesome! congrats. i just saw your post and i'm sorry i never replied.

i need to add some stub functions for the new id3 info, and probably do some cleanup throughout. maybe i'll have time to do that this week. it would be nice--i haven't made any improvements to the emulator for a couple of weeks.

anyway! i'm very glad you were able to get it to work. i hope it's very helpful!
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#25
hi alex,

the meteo.py(my test script) is one of the standard scripts from the xbmc (with python support packages) installs, and as such it is running fine on the xbox.
did some reading on the tkinter lib and it seems that it only supports gifs and another format.
from the help:
"...which can display colored images in gif, ppm/pgm format."

now since i am new to python the next things i am about to say may be completely wrong, or perhaps food for thought on how to improve the emulator.

the tkinter seems to be a wrapper class for the tcl library found at activestate.
-so can we use a new version ?
-or override the classes found in tkinter that handle images with our own, say with the pil library, that do support jpg's
-or go with pil altogether instead of tkinter, or just parts of it. say the parts in xbmcgui that deal with images ?
see here for doc at python tkinter
or this one for , i think an adiitional lib which might be able t do the trick (haven't looked properly)
tix
and i saw an interesting post on this site here about an extension for the tk image class here.

oh well let me know what you think..
gotta sleep now, Confusedleep:  thanx for the support
Reply
#26
new version of the emulator is now available! visit my website (old links won't work--the emulator now has its own subpage) for information and the newest download.

mikez....

ack. i'm actually fairly new to programming, but i already understand that this is one of the ugly realities of programming (especially the hobbyist sort):

switching gui builders away from tkinter might very well be the best thing to do. but the entire emulator (as it stands now) is built on tkinter. it's mostly just porting xbmcgui syntax over to tkinter syntax. so even though i could probably be convinced to use a different method, i probably won't put that much work into this all over again.

that said...i've included your suggestions concerning pil. not necessarily the way you intended it, but the emulator can now display (i think) any image supported by pil. to do this, it opens the image file, converts it to gif format, saves it as a temporary file in the same folder, then tkinter opens the gif, and then the script deletes the temporary file.

kinda ugly, but it gets the job done (without my having to rewrite the whole script). please give it a try, and let me know if it fixes your problem.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply
#27
thanks for the good scripts. pretty handy.
some comments:

a much easier way to create a q: drive:

Quote:c:\>subst q: "d:\documents\desktop\xbox\xbmc"
and there u go. u now got a q: drive mapped to your xbmc folder.

some defs missing:
xbmcgui.lock()
xbmcgui.unlock()
(i just studded with empty functions for now)

xbmcgui.dialogprogress
(trying to re-create that one myself atm)

xbmcgui.windowdialog
(not sure about what's that one... maybe a copy of window?)
Reply
#28
hi there alex,

i have finally a running version of my traffic script. unfortunately i don't have as much time as i would like to have so it has been a while.
did a first test on the xbox and noticed that the emulator doesn't scale the images as specified in the extra params for controlimage(x,y,height, width).
also what resolution is the emulator using when calculating the screen size (black part of tkgui)?
is this pal or ntsc size ?

greetz sofar mikez :pirate:
Reply
#29
class window:
def (self):
self.canvas = canvas(self.frame, width = 720, height = 480, bg = "black")

720x480 is ntsc native resolution.

as for the resize of controlimages, i made a quick fix:
you can just replace your controlimage class in xbmcgui.py by this one:

Quote:class controlimage(control):
def (self, top, left, width, height, filename):
type = "image"
control.(self, type, top, left, int(width / 8), int(height / 18))

tempname = "xbmcemulatorimagetemp.gif"
source = image.open(filename) # for every such picture, opens it as an image...
source = source.resize((width,height))
source.save(tempname)
filename = tempname
self.pic = photoimage(file = filename)
os.remove(filename)

def create(self, win):
self.tkobj = label(win.canvas, image = self.pic)
self.tkobj.pack()
Reply
#30
thanks for all the feedback, mouton! i noticed some of those missing features in the emulator a couple of weeks ago, but things have been so hectic at work that i hadn't gotten around to stubbing them. thanks for the reminder. i'll probably get a new version of the emulator out this week.

regarding the dynamically sized window, the problem is converting between pixel size (used by xbmc) and font size (used by the emulator). the /8 and /18 work reasonably well for guessing, but i'd commented out most of the sizing functions because i didn't feel like it was close enough. the elegant fix would be to switch from tkinter to a grid-based gui, but that would (as i've mentioned elsewhere) require a complete rework of the emulator.
For scripts, script development tools, and documentation, visit my website:
http://www.maskedfox.com/xbmc/
Reply

Logout Mark Read Team Forum Stats Members Help
Python Dev Tool: XBMC Emulator scripts0