Hello Mr. Gauld,

Your second guess about the scenario is right: I want to automate tests of 
Tcl/Tk GUIs.
I know about the GUI test automation tools like WATSUP, PyWinAuto, winGuiAuto 
etc., and will use one if necessary.
But test automation is usually easier at the lowest possible level for the test 
target (as per your suggestion to test the back-end functions directly).
In this case, my test target is the Tcl/Tk GUI itself.

The Tcl/Tk functions I mentioned (Tcl_QueueEvent etc.) are listed in my copy of 
the Tcl/Tk Man pages (downloadable from www.tcl.tk/man).
I believe they are C or C++ functions.

Thanks for the explanation of what Tkinter does and doesn't cover.
Is there another Python module that does include Python wrappers for Tcl/Tk C 
functions?

My first glance at send() and event_generate() gave me the idea they were for 
other purposes.  
Your suggestion triggered a second glance; maybe event_generate can do what I 
need.
I'll study it some more.  

Thanks for the clues
- Dan K.


"Alan Gauld" <[EMAIL PROTECTED]> wrote:

> > I'd like to simulate user input to TkInter applications from
> > another Python script, by inserting events in the Tcl event queue.
>
> There are two scenarios where I'd expect that to be needed:
> 1) To roboticise an existing app, particularly if you don;t have 
> source code access.
> 2) testing a GUI.
>
> Other than that it's usually easier to go in at the level below the 
> GUI and
> call the underlying commands directly. Is that a possibility here?
>
> > Tcl/Tk has a couple functions for this (Tk_QueueWindowEvent
> > and Tcl_QueueEvent).
>
> These were new to me and indeed don't appear in either of
> my Tcl refrence books (Ousterhout and O'Reilly Nutshell)
> Are they recent additions?
>
> > Is there a Python interface for either of those?  I can't find 
> > any...
>
> Neither can I.
>
> > My second choice would be to use Tcl_CreateEventSource,
> > but I don't see a Python interface for that, either.
>
> Nope, me neither. No references in my books and no
> Python/Tkinter equivalents. In fact my Tcl prompt doesn't
> recognise any of the 3 commands you cite. Are these
> actuially Tcl/Tk interpreter commands or C interface
> functions? Only interpreter commands are reproduced
> in Tkinter.
>
> > I'd rather not work through the actual GUI interface if I can avoid 
> > it.
>
> Why do you need to work through the GUI events?
> Normally the GUI is there to connect humans to the back end code.
> If an app needs access to the back end code it can usually call the
> functions directly using more conventional IPC mechanisms.
>
> There are a couple of higher level methods that might be of use?
>
> send(app, cmd, *args)
>
> event_generate(sequence, option=...)
>
> Dunno if they will help.
>
> -- 
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to