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

Re: [pygame] Tutorial... GUI



Hi!

    This is the file I ran to see how my screen reader would read it. I changed it to keep the buttons apart more instead of 10 I put 40 and it did not make any difference.

    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.

    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.

    So, any help will be appreciated. At least I have it working now.

# 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 the text "Button number one" and
# place it at screen offset 10, 10.
button_one = Button ("Button number one")
button_one.topleft = 10, 10

# 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 the text "Button number two" and
# place it 40 pixels beneath the first one.
button_two = Button ("Button number two")
button_two.topleft = button_one.left, button_one.bottom + 40

# 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 ()