Memory Leek, critique me. Thanks!!!
Peter Otten
__peter__ at web.de
Fri Aug 29 14:58:18 EDT 2008
Kevin McKinley wrote:
> # I posted a few days ago about a memory leak that I think i'm having
> # with my first Tkinter program. I've had trouble pinpointing what is
> # wrong so i thought i would submit the code and see if anyone would like
> # to critique it.
Don't create new widgets every time you switch the tab. Instead hide/show
the relevant page. You may be able to reuse the idlelib.tabpage.TabPageSet
class for that.
> # I have one more problem that i can't figure out either. There are a
> # bunch of Entry widgets that require number values.
> # My problem is if someone inputs a letter or space the program will
> # have error that makes part of the Program nonfunctional.
You can wrap access to the DoubleVars with try...except, e. g.:
try:
value = self.COG1.get()
except ValueError:
# show an error message
else:
# continue calculation
Peter
More information about the Python-list
mailing list