Python should have a IDE like this...

Jeff Epler jepler at inetnebr.com
Wed Feb 14 22:20:34 EST 2001


On Wed, 14 Feb 2001 19:28:23 GMT, Robert L Hicks
 <bobhicks.nospam at adelphia.net> wrote:
>http://vtcl.sourceforge.net/snapshot.html
>
>This is a good GUI builder for Tcl...and would be nice to have a Python
>version.
>
>- Bob

If vtcl just outputs tcl code, it seems that it should be possible to
execute this tcl code using tk.call("source", filename) or tk.call("eval",
string) , and then create Python/Tkinter objects corresponding to each
widget after the fact.  Something like the following could perform the latter
task.

A better, but more complicate idea, would be to modify vtcl to output Python 
code directly.  And, of course, this code below does nothing to take care of
the functions to be called via -command or bind.  Lastly, a GUI builder
written in Python might be preferable to one written in some other
language.

import Tkinter, string

class _X: pass

# Take a tree of widgets created in pure tcl and make them
# into Tkinter objects
def widget_to_tkinter(path=".", master=None, tk=Tkinter.tkinter.main_interp):
	if master: tk = master.tk
        ret = _X()
        klass = tk.call("winfo", "class", path)

        if path == ".":
                klass = "Toplevel"
        try:
                ret.__class__ = getattr(Tkinter, klass)
        except AttributeError:
                ret.__class__ = Tkinter.Widget
        if path == ".":
                ret._w = "."
                assert master is None and tk is not None
                ret.tk = tk
                ret.children = {}
        else:
                assert master is not None
                name = string.split(path, ".")[-1]
                ret._setup(master, {"name": name})
        children = ret.tk.call("winfo", "children", path)
        if children:
                children = string.split(children, " ")
                for item in children:
                        widget_to_tkinter(item, master=ret)
        return ret




More information about the Python-list mailing list