Re: Tkinter doesn't work with beta tk/tcl

Steven Reiz (sreiz@aie5.aie.nl)
Tue, 31 Jan 1995 09:35:44 GMT

>>>>> "Aaron" == Aaron Watters <aaron@funcity.njit.edu> writes:
In article <1995Jan30.182651.24820@njitgw.njit.edu> aaron@funcity.njit.edu (Aaron Watters) writes:

Aaron> Hi. I'm ashamed to admit that I just started fiddling with
Aaron> Tkinter. I discovered that the latest tk/tcl "beta" release
Aaron> doesn't work with Tkinter, thought I'd pass it on. Use tk3.6
Aaron> and tcl7.3 instead.

Aaron> Actually, everything looks great with the beta versions until
Aaron> Python gets around to exiting... then it seg. faults almost
Aaron> always. (I got it to not seg fault once by putting a tkinter

I found a simple patch for that problem, in tkintermodule.c
#ifdef 0 the body of the Tkinter_Cleanup function. The code is
apparently meant to close windows before the application exits,
but they are closed anyway, even if the code isn't executed.
I'm not sure if the patch is the perfect fix, but it seems to
work fine.

--- tkintermodule.c.orig Thu Dec 29 13:02:48 1994
+++ tkintermodule.c Thu Dec 29 13:03:05 1994
@@ -1186,8 +1186,10 @@
Tkinter_Cleanup ()
{
/* XXX rl_deprep_terminal is static, damned! */
+#if 0
while (tkMainWindowList != 0)
Tk_DestroyWindow (tkMainWindowList->win);
+#endif
}

void

I will also include a homebrew patch for Tkinter.py, which lets you exploit
the new image widget of tk4. The patch may not apply 100% cleanly because
the posting machinery on this host eats square brackets... Sorry about that.

--- /usr/local/lib/python/tkinter/Tkinter.py.orig Thu Dec 29 16:44:25 1994
+++ Tkinter.py Thu Dec 29 16:46:42 1994
@@ -641,7 +641,9 @@
else:
name = `id(self)`
self._name = name
- if master._w=='.':
+ if self.widgetName=='photo':
+ self._w=name
+ elif master._w=='.':
self._w = '.' + name
else:
self._w = master._w + '.' + name
@@ -651,9 +653,12 @@
self.master.childrenself._name = self
def __init__(self, master, widgetName, cnf={}, extra=()):
cnf = _cnfmerge(cnf)
- Widget._setup(self, master, cnf)
self.widgetName = widgetName
- apply(self.tk.call, (widgetName, self._w) + extra)
+ Widget._setup(self, master, cnf)
+ extra1=()
+ if widgetName=='photo':
+ extra1=('image', 'create')
+ apply(self.tk.call, extra1+(widgetName, self._w)+extra)
if cnf:
Widget.config(self, cnf)
def config(self, cnf=None):
@@ -792,6 +797,8 @@
return Canvas._create(self, 'arc', args)
def create_bitmap(self, *args):
return Canvas._create(self, 'bitmap', args)
+ def create_image(self, *args):
+ return Canvas._create(self, 'image', args)
def create_line(self, *args):
return Canvas._create(self, 'line', args)
def create_oval(self, *args):
@@ -875,10 +882,10 @@
self.tk.call(self._w, 'select', 'to', tagOrId, index)
def type(self, tagOrId):
return self.tk.call(self._w, 'type', tagOrId) or None
- def xview(self, index):
- self.tk.call(self._w, 'xview', index)
- def yview(self, index):
- self.tk.call(self._w, 'yview', index)
+ def xview(self, *args):
+ apply(self.tk.call, (self._w, 'xview')+args)
+ def yview(self, *args):
+ apply(self.tk.call, (self._w, 'yview')+args)

class Checkbutton(Widget):
def __init__(self, master=None, cnf={}):
@@ -944,6 +951,10 @@
def __init__(self, master=None, cnf={}):
Widget.__init__(self, master, 'label', cnf)

+class Photo(Widget):
+ def __init__(self, master=None, cnf={}):
+ Widget.__init__(self, master, 'photo', cnf)
+
class Listbox(Widget):
def __init__(self, master=None, cnf={}):
Widget.__init__(self, master, 'listbox', cnf)
@@ -1073,9 +1084,8 @@
Widget.__init__(self, master, 'scrollbar', cnf)
def get(self):
return self._getints(self.tk.call(self._w, 'get'))
- def set(self, totalUnits, windowUnits, firstUnit, lastUnit):
- self.tk.call(self._w, 'set',
- totalUnits, windowUnits, firstUnit, lastUnit)
+ def set(self, *args):
+ apply(self.tk.call, (self._w, 'set')+args)

class Text(Widget):
def __init__(self, master=None, cnf={}):

-- 
-- Steven Reiz, AI Engineering, Amsterdam, sreiz@aie.nl                     --
--                                                                          --
-- We can only see a short distance ahead, but we can see plenty there      --
-- that needs to be done.                  A.M. Turing (1950)               --