[Tkinter-discuss] problem with pylab/tkinter?

Russell E. Owen rowen at uw.edu
Mon Oct 25 21:02:25 CEST 2010


I don't think you should mix pylab with matplotlib object API 
programming (or even the Tkinter event loop), though it may be safe if 
you are just displaying a plot in a standalone window. It takes a bit 
more work, but the object API lets you mix matplotlib plots freely with 
other Tkinter elements. maplotlib comes with good examples for using the 
object API with Tkinter.

If you decide it is safe to use pylab (instead of matplotlib's object 
API) then at least import pylab using:

import pylab

instead of

from pylab import *

to avoid namespace pollution. Using "from <foo> import *" is almost 
never a good idea and pylab is an especially large package. "from pylab 
import *" can be handy for creating graphs on the fly, but it was never 
intended for coding into scripts.

-- Russell

In article 
<AANLkTinHgq29PmGj6dF2CSuL5LYce_D5i7_edzNMsASU at mail.gmail.com>,
 Alex Ter-Sarkissov <sigma.z.1980 at gmail.com> wrote:

> hi, the problem might be bit silly...
> 
> I'm desiging a GUI with Tkinter. Everythin worked (just couple buttons and
> entries). Then I decided I need to import pylab:
> 
> from pylab import *
> 
> as a result, I'm getting an error message
> 
> TypeError: __init__() got an unexpected keyword argument 'text'
> 
> which refers to the command line in def __init__(self)
> 
> self.start_but=Button(root,text='Generate starting population')
> 
> Like I said earlier, if I do not import pylab/matplotlib, no error messages
> are received.
> 
> cheers,
> 
> Alex
> ---------------------------------------------------------------------
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss



More information about the Tkinter-discuss mailing list