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

Re: [pygame] Tutorial... GUI



On, Thu Sep 27, 2007, RR4CLB wrote:

> 
>     I noticed just only one graphic symbol present. I labeled it and
> the ladle stayed the same for both, that means they are the same
> color/image. So when tabbing back and forth the first screen said
> button 1 or button 2 but the screen reader only read the same
> label. Also when tabbing I got no text, which means no text label
> in the button itself.

Which label did the screen reader read? Does it receive the button
information or only the title text of the pygame window?

I think, the screen reader cannot receive any information from the AT
software, because pygame (and SDL in general) simply does not support
such accessibility features.

However, I attached a slightly modified version of the button example,
in which the first button now receives a red background colour, the
second one a green background colour. If you could give it a try, it'd
be helpful for me to figure out on what I have to focus for the
accessibility systems.

> 
>     So, I guess there has to be a different color or image I would
>  have to use for each button. Also, text label for the button, is
>  that in this or forced to be in first screen window? For when it
>  said which was focused I had to go to the other screen by alt
>  tab. Control tab went back to the first button but the text label
>  I placed on it with the screen reader still read Button 2, because
>  of button color/image.

The visual representation of the buttons displays a textual label on
them as done in the code. I simply added a print function (which goes to
the other console window) for the focus so you can distinguish between
both buttons in case the screen reader cannot deal with them correctly.

I hope, the screen reader can recognize the changed example correctly
now. If not, we have to think of another solution as it is likely that
the screen reader won't be able to deal with any content displayed on
the pygame window then. This would mean that each object to be shown
needs accessibility awareness through the MSAA library (or ATK/AT-SPI
for unix).

Regards
Marcus
# Import the necessary ocempgui parts.
from ocempgui.widgets import *
from ocempgui.widgets.Constants import *

# object_focused will print a widget's text to the console.
def object_focused (gui_widget):
    print "Element %s is focused" % gui_widget.text

# Create the first button with no text and place it at screen offset 10,
# 10.
button_one = Button ()
button_one.topleft = 10, 10

# Create a red background color for the first button and assign it a red
# label with the text "Button number one".
label_one = Label ("Button number one")
label_one.create_style()
label_one.style["bgcolor"][STATE_NORMAL] = (255, 0, 0)
button_one.create_style()
button_one.style["bgcolor"][STATE_NORMAL] = (255, 0, 0)
button_one.child = label_one

# Connect the focus event (for tab).
button_one.connect_signal (SIG_FOCUSED, object_focused, button_one)

# Connect the mouse enter event to the button to have some "hover"
# effect.
button_one.connect_signal (SIG_ENTER, object_focused, button_one)

# Create the second button with no text and place it 40 pixels beneath
# the first one.
button_two = Button ()
button_two.topleft = button_one.left, button_one.bottom + 40

# Create a green background color for the second button and assign it a
# green label with the text "Button number two".
label_two = Label ("Button number two")
label_two.create_style()
label_two.style["bgcolor"][STATE_NORMAL] = (0, 255, 0)
button_two.create_style()
button_two.style["bgcolor"][STATE_NORMAL] = (0, 255, 0)
button_two.child = label_two

# Connect the focus event (for tab or mouse "hover") of the second button.
button_two.connect_signal (SIG_FOCUSED, object_focused, button_two)

# Connect the mouse movement event to the button to have some "hover"
# effect.
button_two.connect_signal (SIG_ENTER, object_focused, button_two)

# Create the renderer object.
re = Renderer ()

# Let the renderer create a pygame screen with 200 pixels width and 200
# pixels height.
re.create_screen (200, 200)

# Set the window title to "Two button demo".
re.title = "Two button demo"

# Set the screen background color to a grey RGB value.
re.color = (200, 200, 200)

# Add the both buttons.
re.add_widget (button_one, button_two)

# Start the main loop for drawing and event processing.
re.start ()

Attachment: pgp3H9unko0ik.pgp
Description: PGP signature