Re: GTK and accessibility



Hello Nagappan,

I'm doing fine, thanks. Still working on GUI automation.

I tried the GTK_MODULES trick you suggested, but to no avail. At first, there
are no errors, is just that the ldtp script freezes and there's nothing else to
do. However, if you wait long enough you get an 'Invalid response packet' error
(please have a look at ldtp.out).

As I said before the same set of subprocess.Popen invocations work correctly if
the calling script doesn't make use of GTK so there's an interaction problem there.

Please see the two files attached as an example:
- gedit.py: just opens gedit and closes it
- launcher.py: Launches gedit.py either from console or from gtk. For the gtk
version, please remember to use the '-g' option and to press the 'Launch LDTP'
button to call the gedit.py script.

As you will see when you call 'launcher.py' everything works correctly, but when
using 'launcher.py -g' it doesn't (ldtp.out). Please let me know if you have any
other advice.

By the way, I'm using Ubuntu Karmic and LDTP 1.7.1.

Best regards,
    Javier

Nagappan Alagappan wrote:
> Hi Javier,
> 
> After long time :) How are you doing ?
> 
> On Wed, Feb 3, 2010 at 3:36 AM, Javier Collado <javier collado canonical com
>> wrote:
> 
>> Hello,
>>
>> I'm trying to launch an LDTP script from a gtk application written in
>> python
>> using subprocess standard module in Ubuntu Karmic.
>>
> 
> I think you have unset some environment variables. I think this might help
> http://cgit.freedesktop.org/ldtp/ldtp/tree/python/ldtpeditor#n44
> 
> Hope the above info helps
> 
>> I've read that there are some problems with accessibility when threads are
>> being
>> used. However, my understanding is that I shouldn't have any problem if a
>> launch
>> a new process. Is that correct?
>>
>> According to my experience launching exactly the same command from a
>> console, or
>> from a text based application works, but from a gtk application doesn't.
>> Any
>> advice would appreciated. Thanks.
>>
> 
> Any error message ?
> 
> Thanks
> Nagappan
> 
>> Best regards,
>>     Javier
>>
>>
>> _______________________________________________
>> gnome-accessibility-list mailing list
>> gnome-accessibility-list gnome org
>> http://mail.gnome.org/mailman/listinfo/gnome-accessibility-list
>>
>>
> 
> 
#!/usr/bin/env python
import ldtp

ldtp.launchapp('gedit')
ldtp.click('frm*-gedit', 'mnuQuit')

#!/usr/bin/env python
import os, optparse, subprocess
import pygtk
pygtk.require("2.0")
import gtk


class App:
    def __init__(self):
        window = gtk.Window()
        window.connect('destroy', self.window_destroy_cb)

        button = gtk.Button('Launch LDTP')
        button.connect('clicked', self.launch_btn_clicked)
        window.add(button)

        window.show_all()

    def window_destroy_cb(self, widget):
        """
        Destroy main window
        """
        gtk.main_quit()

    def launch_btn_clicked(self, button):
        """
        Launch LDTP script
        """
        launch_ldtp()

    def run(self):
        """
        Run gtk mainloop
        """
        gtk.main()


def launch_ldtp():
    """
    Launch ldtp script
    """
    env = os.environ.copy()
    env['GTK_MODULES'] = ''
    subprocess.call('python gedit.py', shell=True,
                    env = env)


def main():
    parser = optparse.OptionParser()
    parser.add_option("-g", "--gtk", action="store_true")
    options, _ = parser.parse_args()

    if options.gtk:
        app = App()
        app.run()
    else:
        launch_ldtp()


if __name__ == "__main__":
    main()

GTK Accessibility Module initialized

** (gedit.py:4606): WARNING **: Trying to register gtype 'WnckWindowState' as flags when in fact it is of type 'GEnum'

** (gedit.py:4606): WARNING **: Trying to register gtype 'WnckWindowActions' as flags when in fact it is of type 'GEnum'

** (gedit.py:4606): WARNING **: Trying to register gtype 'WnckWindowMoveResizeMask' as flags when in fact it is of type 'GEnum'
Traceback (most recent call last):
  File "gedit.py", line 5, in <module>
    ldtp.click('frm*-gedit', 'mnuQuit')
  File "/usr/lib/pymodules/python2.6/ldtp.py", line 569, in click
    raise LdtpExecutionError (_responseStatus [1])
ldtplib.ldtplibutils.LdtpExecutionError: 'Invalid response packet'

Attachment: signature.asc
Description: OpenPGP digital signature



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