Trying to run this little piece of code on Ubuntu 14.04
import matplotlib
matplotlib.use('TkAgg')
import pylab as PL
import random as RD
import scipy as SP
RD.seed()
populationSize = 100
noiseLevel = 1
def init():
global time, agents
time = 0
agents = []
for i in xrange(populationSize):
newAgent = [RD.gauss(0, 1), RD.gauss(0, 1)]
agents.append(newAgent)
def draw():
PL.cla()
x = [ag[0] for ag in agents]
y = [ag[1] for ag in agents]
PL.plot(x, y, 'bo')
PL.axis('scaled')
PL.axis([-100, 100, -100, 100])
PL.title('t = ' + str(time))
def step():
global time, agents
time += 1
for ag in agents:
ag[0] += RD.gauss(0, noiseLevel)
ag[1] += RD.gauss(0, noiseLevel)
import pycxsimulator
pycxsimulator.GUI().start(func=[init,draw,step])
but got the following error message:
Traceback (most recent call last):
File "/home/joaomeirelles/Documents/USP/TESE/exemplos/pycx-0.31/abm-randomwalk.py", line 49, in <module>
pycxsimulator.GUI().start(func=[init,draw,step])
File "/home/joaomeirelles/Documents/USP/TESE/exemplos/pycx-0.31/pycxsimulator.py", line 48, in __init__
self.initGUI()
File "/home/joaomeirelles/Documents/USP/TESE/exemplos/pycx-0.31/pycxsimulator.py", line 77, in initGUI
self.status.grid(row=1,column=0,padx=2,pady=2,sticky='nswe')
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1985, in grid_configure
+ self._options(cnf, kw))
_tkinter.TclError: cannot use geometry manager grid inside . which already has slaves managed by pack
[Finished in 0.4s with exit code 1]
does anyone know what could it be? I'v tried to use different versions of Tcl/Tk (8.5 and 8.6) and to update MGLTools, but none of them have worked.
thanks JM
The error message is telling you exactly what the problem is:
That means that somewhere in your code you're calling
.pack(...)
on a widget that is a child of the root window ("slaves managed by pack"), and later you're calling.grid(...)
on another widget that is also a child of the root window ("cannot use geometry manager grid...").Within any given container window (frame, root window, toplevel), all of the direct children can only be managed by grid OR pack, but not both.