[Tutor] How to put an event into the Tcl/Tk event queue?

2007-08-26 Thread Daniel Knierim
Hi All,

I'm starting to learn how to use the TkInter module.  So far I've got a couple 
versions of 'hello world' working.

I'd like to simulate user input to TkInter applications from another Python 
script, by inserting events in the Tcl event queue.  Tcl/Tk has a couple 
functions for this (Tk_QueueWindowEvent and Tcl_QueueEvent).  Is there a Python 
interface for either of those?  I can't find any...

My second choice would be to use Tcl_CreateEventSource, but I don't see a 
Python interface for that, either.

I'd rather not work through the actual GUI interface if I can avoid it.  

Thanks
- Dan K.___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] TypeError in base class __init__ after reload

2008-01-23 Thread Daniel Knierim
Hello Pythonistas,

Running the script 'instantiate_and_reload.py' gives me the error 
TypeError: unbound method __init__() must be called with ParentClass 
instance as first argument (got ChildClass instance instead)

on the last call to ChildClass(), at line 23. The earlier calls don't trigger 
the error.

-- Begin file instantiate_and_reload.py:
from parentclass import ParentClass
from childclass import ChildClass
import parentclass, childclass


p = parentclass.ParentClass()
c = childclass.ChildClass()
p = ParentClass()
c = ChildClass()

reload(parentclass)

p = parentclass.ParentClass()
c = childclass.ChildClass()
p = ParentClass()
c = ChildClass()

reload(childclass)

p = parentclass.ParentClass()
c = childclass.ChildClass()
p = ParentClass()
c = ChildClass()

-- End of file instantiate_and_reload.py

-- Begin file parentclass.py:
class ParentClass(): #same result with new-style classes (subclassing object)
def __init__(self):
pass


if __name__ == '__main__':
p = ParentClass()

-- End of file parentclass.py

-- Begin file childclass.py:
from parentclass import ParentClass
import parentclass


class ChildClass(ParentClass):
def __init__(self):
ParentClass.__init__(self)


if __name__ == '__main__':
p = ParentClass()
c = ChildClass()

reload(parentclass)

p = ParentClass()
c = ChildClass()

-- End of file childclass.py

-- Beginning of captured command-line session:
D:\Programs\Python\Sandbox\SubclassInitChain>python childclass.py

D:\Programs\Python\Sandbox\SubclassInitChain>python parentclass.py

D:\Programs\Python\Sandbox\SubclassInitChain>python instantiate_and_reload.py
Traceback (most recent call last):
  File "instantiate_and_reload.py", line 23, in 
c = ChildClass()
  File "D:\Programs\Python\Sandbox\SubclassInitChain\childclass.py", line 7, in 
__init__
ParentClass.__init__(self)
TypeError: unbound method __init__() must be called with ParentClass instance 
as first argument (got ChildClass instance instead)

D:\Programs\Python\Sandbox\SubclassInitChain>python -V
Python 2.5.1

-- end of captured command-line session

I can't understand why the last call to ChildClass() triggers the error, when 
the earlier calls don't.

Can somebody explain to me what's going on?  or what I'm doing wrong?

Thanks
- Dan Knierim
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor