PDA

View Full Version : Old Screenlets Create Session Fix


humus
July 25th, 2007, 03:09 PM
Hello, I just noticed today I was running an outdated screenlets version, maybe a link in official web page to these forums would be nice. Anyway, since I'veupgraded to the latest version some widgets were missing the "Quit" option in their menu, this was annoying since state of widgets was not saved. Fixing this is really simple:

Since this new version, screenlets need to create a session (I'm guessing here, haven't read any documentation, is there any?) in order to keep their state and other features, this was needed since there's no more daemon to control this (guessing again), ok, to the fix:

Open the widget you'll like to update in an editor, and at the end of it you'll find code similar to this:

if __name__ == "__main__":
sl = screenlets.create_new_instance('NowPlayingScreenle t')
sl.main()


just change it with this code:

if __name__ == "__main__":
import screenlets.session
screenlets.session.create_session(NowPlayingScreen let)


I hope this information was useful for you, and I only ask for a link in the "official" (is it?) screenlets homepage to these forums.

RYX
July 25th, 2007, 03:39 PM
Hi humus!

Thanks for the nice explanation of the new session-system. Your guess is absolutely correct - nothing to add from my side :) ...

btw: The official screenlets-website will get updated soon. It has been a bit complicated because I had no access to the server, but that recently changed ...

:)

bluebyt
July 26th, 2007, 03:47 AM
I tried this with the weather screenlet because it never keep settings, but doesn't work for me!

When I paste this code:
if __name__ == "__main__":
import screenlets.session
screenlets.session.create_session(WeatherScreenlet )

I get this error:
File "/usr/local/share/screenlets/Weather/WeatherScreenlet.py", line 766
import screenlets.session
^
IndentationError: expected an indented block

Lazesharp
July 26th, 2007, 11:16 AM
Python code blocks rely entirely on indentation.

You need a tab before every line after the "if".

RYX
July 26th, 2007, 12:10 PM
I just edited humus' post and added the missing indentation :) ... overlooked it yesterday.

humus
July 27th, 2007, 04:22 PM
Oops, missed indentation