[sugar] Injecting Code into main Sugar GUI routine

Tomeu Vizoso tomeu at tomeuvizoso.net
Mon Jul 7 06:03:36 EDT 2008

On Mon, Jul 7, 2008 at 11:23 AM, Zach Riggle <zachriggle at gmail.com> wrote:
> I would prefer not to modify the code to Sugar directly.  I was thinking of
> an approach that would allow me to launch sugar-jhbuild /inside/ of a
> running Python script.  This way, I can use the GUI hooks that I already
> have (and don't have to worry about breaking the code).  However, Sugar
> seems a bit fork-happy.  From where is main.py called?

Ok, then see bin/sugar-emulator and src/emulator.py, that ultimately
calls src/main.py. Perhaps we should move the call to gtk.main()
outside main.py, so people like you can initialize the shell, do
something else, and then call themselves the main loop.

Hope you have enough pointers for now, if you need to change some of
the sugar code to better accomodate your use case, feel free to
propose those changes or if they are simple enough, just post a patch.



> On Jul 7, 2008, at 3:04 AM, Tomeu Vizoso wrote:
>> Hi Zach,
>> On Mon, Jul 7, 2008 at 12:20 AM, Zach Riggle <zachriggle at gmail.com> wrote:
>>> I am a student working on a Google Summer of Code project, sugarbot
>>> (more information here: http://code.google.com/p/sugarbot/).  I am
>>> currently at a stage where I need to be able to hook into the Sugar
>>> GUI, to automate the process of launching Activities (e.g. simulate a
>>> mouse-click on the activity list, scroll down, click on the Activity
>>> name).  The process of automating the GUI is straightforward and
>>> should not be a problem, however I do not know where the best location
>>> would be to inject my code, or if there would be a way to create a
>>> launcher that, in turn, launched the Sugar interface inside of its own
>>> process.
>> Depends a bit on what that injected code would do. Supposing you want
>> to run it after everything has already been set up, try putting your
>> code in src/main.py, probably just before the main loop is started
>> (but outside the try..except block).
>> http://dev.laptop.org/git?p=sugar;a=blob;f=src/main.py
>>> Additionally, if anyone can point me in the direction of any materials
>>> related to the Sugar startup procedures/process, it would be greatly
>>> appreciated.
>> Sorry, we have very little docs right now, but any help is appreciated.
>> Good luck,
>> Tomeu

More information about the Sugar mailing list