[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Tutorial... GUI



On, Fri Sep 28, 2007, RR4CLB wrote:

> Marcus,
> 
>     Hi! I got it working for now. What I did is disable trigger
> messages and also programmed it to read the title bar when the button
> is in focus. It reads the button now when tabbing to it. So that might
> be the temp fix for now. I just replaced the print statement with the
> re.title command and that resolved the issue.

Not elegant, but if it works, it's at least some primitive solution.

> 
>     I do have it working and saved the set file for it. I can read
>     status bars and title bars and such. But will play with it some
>     more and see if something else could also be used. Including a
>     text box on the screen instead of the title bar. But the title bar
>     is not really that bad to use, for who needs to know more about
>     that when playing a game.

Well, MSAA and co. allow one to gather nearly all information about the
user interface, how it's structured, related groups, actions that are
possible on a control and that stuff. But as long as we do not have any
support for it, we have to live with what's possible :-).

> 
>     It is interesting, but I will play with it and see where it goes
> from here. Including adding voice files maybe?

One easy solution would be the following code for a button click event.
First the event handler code as function:

def object_clicked (gui_widget, soundfile):
    print "Element %s was clicked" % gui_widget.text
    play_sound (soundfile)

What does the code do? It prints "Element XXX was clicked" to the
console window and calls the play_sound method with the passed
soundfile parameter. This allows you to play different sounds (spoken,
music, etc.) for different controls. The play_sound method has to be
implemented by you.

Now let's connect the method to the click event of the button:

button_one.connect_signal (SIG_CLICKED, object_clicked, button_one, "button_one.wav")

This connects the click event of button_one to the object_clicked
method. It passes the button object and an additional sound file to the
method, which then will be played.

The click event can be raised, when you press the space bar on your
keyboard once you focused the button.

The OcempGUI manual and API reference contain more information about
what you can do and how to do it.
http://ocemp.sourceforge.net/guidoc.html contains links to the API
reference and a usage manual.

The documentation of the different modules, controls and methods are
also accessible through the pydoc command on a console. Simply type
'pydoc ocempgui' (without the quotes) for a module overview. This might
be helpful, if the online API reference is not very accessible to you.
As it is generated from the information pydoc provides, there are no
differences between the HTML API and the pydoc output.

The whole documentation also ships with the package and there are
various examples within the "examples" directory beneath the "doc"
directory of the package.

I hope, the information are presented in a readable form. If not feel
free to mail me directly (so we do not spam this list ;-)) and I'll try
to provide some more information about how you can implement things with
it.

Regards
Marcus

Attachment: pgp8f6oxUuP4m.pgp
Description: PGP signature