2015-10-23 15:27:01

I am using python 2.7 with pygame and accessible_output2.  I can put text on the window as a font object for the reader and I can output the same text as speech.  I would prefer an access solution where I produced accessible text, available for review by screen readers.  Can someone point me to a solution?

Try my free games and software at www.rockywaters.co.uk

2015-10-23 17:57:10

I know it can be done, but I don't know how. Maybe something related to wx?

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2015-10-26 19:21:16

Thanks, I see WX certainly has text boxes and a whole lot more.  I am reading stuff that assumes more knowledge than I have.  As a relative newby, anyone with some tips would be appreciated.  For example can I use WX to write to the pygame GUI?  My goal at the moment is simply to size, place and update accessible text.

Try my free games and software at www.rockywaters.co.uk

2015-10-26 23:07:08

@Rocky, accessible_output2 is only meant for Python2 because the python2 fanatics will not update to python 3.x to convert accessible_output2 to python 3.x, which is, might I add, the latest, and best python version available. (The python 2.x fanatics will disagree with me on that one. Just wait, guys. Soon enough you'll be forced to learn python 3 whether you like it or not. and it won't be by me.) Anyways, to convert it all, you'll have to run:
python -mlib2to3 -w <files>

  • The -mlib2to3 command line option of Python tells the python executable to load the module "lib2to3", which converts python 2.x code to 3.x code.

  • The -w switch is directly passed to the lib2to3 module. It tells lib2to3 to write any changes it makes to disk.

Of course, that doesn't mean that that will work. It doesn't work on everything.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2015-10-27 19:34:34

Ethin, thanks, though I'm not quite understanding you.  Are you saying that accessible_output2 works and compiles with python3x? I have a separate thread on accessible_output2 issues, probably best for us to discuss AO2 there.  I am happy to convert to python 3x, if such a solution works.  My request here is to find a solution for text rather than speech.  I see from a historical discussion on this forum, no such solution was offered up.  I am hoping however, someone comes up with some magic words like "Yes, I use python3, pygame, and WX and use them together", or perhaps simply "Rocky, we have been round the block on access with python and text on GUI's is simply not accessible".  So folks, any success on this one?

Try my free games and software at www.rockywaters.co.uk

2015-10-27 20:52:30

@Rocky, from what I can understand from the documentation, it is best that you use a library such as Tolk or AO2 because I don't know what accessible text is available while using pygame. I know that innoSetup can create dialogs with text that is read automatically by the screen reader of the user, but I haven't found what text coordinates are used for that.

"On two occasions I have been asked [by members of Parliament!]: 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out ?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question."    — Charles Babbage.
My Github

2015-10-28 00:38:35 (edited by SoundMUD 2015-10-28 00:45:43)

It depends on what kind of game you are trying to do.

How long is the text supposed to be available? Is it updated when the player presses a key or ends his turn, or when new information is available in real time? Is it just an intro before something more interactive? Is the player supposed to actively review the text?

Is the text supposed to be printed with a nice font or is the text displayed mostly for debugging?

I have successfully tested (but not adopted) the following combinations:
- wx for the window and the events (keyboard), wwise for the sound
- wx for the window and the events (keyboard), pyglet (OpenAL) for the sound

A similar wx combination with pygame mixer might work. I think pygame wouldn't be allowed to draw text on the screen (it would be wx's job).

Edit: In the previous examples, SAPI was used for the interactive speech. A Screen Reader API would have been OK too. Actually, what I expected from wx was the possibility to easily create complex familiar interfaces.

2015-10-29 15:24:43

Thanks SoundMUD.  Very happy to hear working combinations.  Trying WX with pygame is now on my to do list.  The text that I want is for review, in a turn based scenario.  Perhaps location plus the last 3 actions by the player.  Shorter text messages such as intro and menu items I am looking towards AO2 for an accessible solution.  As you'll see from that thread I have made some progress.  Back to text: any hints with WX much appreciated as I'm still in the learning process.  Cheers.

Try my free games and software at www.rockywaters.co.uk

2015-10-29 19:48:33

Did you try to simply print to a console? I am wondering if it is convenient enough to review the text in the console though. This solution is probably compatible with pygame mixer to add music and sound effects. If the printed string is Unicode, even the non ASCII characters will be printed correctly.

2015-11-23 21:50:34

If I understand properly, you want an option to create a text that shows up in Pygame and be read by the user. I am not working with fonts in pygame, but I think you could create a class and put methods for showing at screen (by passing the coords) and speaks (using accessibleOutput2). Btw, AccessibleOutput2 could be modified for using py3k (Christofer did some work at this respect). About the class, I think it could be something like this (note that I have no idea about how pygame shows things at screen):

class text(object):

    def __init__(self, text="", font=None):
        super(text, self).__init__()
        self.text = text
        self.font = font #this is the font you will use for showing at screen.

    def speak(self):
        """ Speaks text using accessibleOutput2. It needs the output module."""
        output.speak(self.text)

    def show(self, screenObject, coordinates=(0, 0), colour=(255, 255, 255)):
        """ Shows text using the given coordinates."""
        RenderedText = self.font.render(self.text, colour)
        screenObject.blit(RenderedText, coordinates)

About Pygame+wx I think it isn't a very good idea because when you will distribute your application as a windows executable it will increase the final size about 15 or 20 MB, I guess. Too much costs for showing texts.

Hth.