Python/Tkinter/tk crash [long]

Martin Franklin mfranklin1 at gatwick.westerngeco.slb.com
Thu Aug 14 11:33:17 EDT 2003


On Thursday 14 August 2003 10:10 am, Eric Brunel wrote:
> Hi all,
>
> I was creating a Tkinter widget in the style of the reversed tabs below
> Excel worksheets and I stepped in a serious problem: the code I made makes
> python crash with a seg fault, bus error or X11 BadGC error on both Solaris
> (2.6 and 2.7) and Linux (Mandrake 8.0); it doesn't crash on Windows. I
> tried to simplify the script, but I couldn't reproduce the crash with a
> simpler code. So the code below is somewhat long; sorry for that.
>
> To make it crash, just run the script and click on a tab. It usually
> crashes at the first click, but you may have to play a bit with the tabs. I
> tried to run Python through gdb to see where the crash happens, but it
> seems to be quite random. Maybe a memory corruption?
>
> There's a simple workaround, but with drawbacks: at the beginning of the
> __update method, if I do not destroy and re-create the Canvas, but simply
> empty its contents, the script works. But it keeps the commands declared
> created at the tcl level for the former bindings, so it silently eats up
> memory.
>


does it still eat up memory if you, for example, change the top of the 
__update method to:

   def __update(self):
     if not self.__tabsCanvas:  
         self.__tabsCanvas = Canvas(self, bg=self.cget('background'),
                                    height=self.__canvasHeight)
         self.__tabsCanvas.grid(row=0, column=0, sticky='nswe')
     self.__tabsCanvas.delete("all")


Martin






More information about the Python-list mailing list