hi,
i have app in wxpython what i do is showing some value of variables from data in other panel
all is good when i showing the value from one panel but when i add other panel to show variables i get ERROR that my code :
Traceback (most recent call last):
File “C:\Users\moriAnaconda3\lib\site-packages\matplotlib\cbook_init_.py”, line 215, in process
func(*args, **kwargs)
File “D:\DATA\app6.py”, line 450, in on_press
self.GrandParent.right.bottom.bottom.top.Update(x1,y1,list_var3,lon,lat)
TypeError: Update() missing 1 required positional argument: ‘list_var4’
that my code :
class MiddlePanelTop(wx.Panel):
def init(self, parent):
super().init(parent, name=“MiddleTop”, style = wx.SUNKEN_BORDER,size = (500,200))
self.SetBackgroundColour(‘black’)
def Update(self,zoom_axes):
#Load axis values of the selected rectangle
#zoom_axes=parent.zoom_axes
#duplicate the plot from the main panel
self.figure = Figure(figsize =(5,4))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
self.figure.subplots_adjust(left=0.009,right=0.99,bottom=0.09,top=0.99)
#Apply axis of drawn rectangle to the plot
self.axes.axis(zoom_axes)
path=file_names
nc = netCDF4.Dataset(file_names)
fic1='D:/DATA/latlon_+000.0_globe.nc'
fic2='D:/DATA/landsea_+000.0.h5'
hdf=h5py.File(fic2,'r')
landsea=hdf['dataset'][:]
var = nc.variables.keys()
list_var3 = [nc.variables['VIS006'],nc.variables['VIS008'],nc.variables['IR_120'],nc.variables['IR_108'],nc.variables['IR_087'],
nc.variables['IR_134'],nc.variables['IR_039'],nc.variables['WV_073'],nc.variables['WV_062'],nc.variables['IR_097']]
print("update2")
data_list = ['VIS006','VIS008','IR_120','IR_108','IR_087','IR_134','IR_039','WV_073','WV_062','IR_097']
list_var3 = [nc.variables[f] for f in data_list]
nc1 = netCDF4.Dataset(fic1,'r')
lons = nc1.variables['lon'][:]
lats = nc1.variables['lat'][:]
self.lons = lons[:]
self.lats = lats[:]
print("Option chosen update")
global index
print("index=",index)
self.list_var3 = list_var3[index][:]
self.axes.imshow(self.list_var3,cmap=plt.cm.gist_yarg)
self.clevs=np.arange(0,3,1)
self.axes.contour(landsea,self.clevs,extend="max",colors='y')
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
self.canvas.mpl_connect('button_press_event', self.on_press)
global x1,y1
self.rect = patches.Rectangle((x1, y1), 40, 40,edgecolor='g', alpha=1, fill=None, label='Label')
self.axes.add_patch(self.rect)
self.figure.add_axes(self.axes)
'self.figure.show()'
self.axes.plot()
#add_artist(t)
def on_press(self, click):
global x1, y1
x1, y1 = click.xdata, click.ydata
list_var3 = self.list_var3[int(y1),int(x1)]
lon = self.lons[int(y1),int(x1)]
lat = self.lats[int(y1),int(x1)]
self.GrandParent.right.bottom.bottom.top.Update(x1,y1,list_var3,lon,lat)
zx1 = x1 - 20
zy1 = y1 - 20
zx2 = x1 + 20
zy2 = y1 + 20
self.rect.set_x(x1 - 20) #Move the rectangle and centre it on the X click point
self.rect.set_y(y1 - 20) #Move the rectangle and centre it on the Y click point
x1=x1-20
y1=y1-20
self.axes.plot()
self.canvas.draw()
self.zoom_axes=[zx1,zx2,zy1,zy2]
global zoom
global zoom2
zoom2=self.zoom_axes
self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)
'self.GrandParent.middle.top.Update(zoom)'
self.GrandParent.middle.bottom.Update(zoom)
self.GrandParent.right.top.Update(zoom)
self.GrandParent.right.bottom.top.right.Update(self.zoom_axes)
self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)
self.GrandParent.right.bottom.top.middle.Update(self.zoom_axes)
class MiddlePanelBottom(wx.Panel):
def init(self, parent):
super().init(parent, name=“MiddleBottom”, style = wx.SUNKEN_BORDER,size = (300,200))
self.SetBackgroundColour(‘black’)
def Update(self,zoom_axes):
#Load axis values of the selected rectangle
#zoom_axes=parent.zoom_axes
#duplicate the plot from the main panel
self.figure = Figure(figsize =(5,4))
self.canvas = FigureCanvas(self, -1, self.figure)
self.axes = self.figure.add_subplot(111)
self.figure.subplots_adjust(left=0.009,right=0.99,bottom=0.1,top=0.98)
#Apply axis of drawn rectangle to the plot
self.axes.axis(zoom_axes)
path=file_names
nc = netCDF4.Dataset(file_names)
fic1='D:/DATA/latlon_+000.0_globe.nc'
var = nc.variables.keys()
list_var4 = [nc.variables['VIS006'],nc.variables['VIS008'],nc.variables['IR_120'],nc.variables['IR_108'],nc.variables['IR_087'],
nc.variables['IR_134'],nc.variables['IR_039'],nc.variables['WV_073'],nc.variables['WV_062'],nc.variables['IR_097']]
print("update3")
data_list = ['VIS006','VIS008','IR_120','IR_108','IR_087','IR_134','IR_039','WV_073','WV_062','IR_097']
list_var4 = [nc.variables[f] for f in data_list][:]
nc1 = netCDF4.Dataset(fic1,'r')
lons = nc1.variables['lon'][:]
lats = nc1.variables['lat'][:]
self.lons = lons[:]
self.lats = lats[:]
print("Option chosen update")
global index
print("index=",index)
self.list_var4 = list_var4[index][:]
self.axes.imshow(self.list_var4,origin ='lower')
self.axes.get_xaxis().set_visible(False)
self.axes.get_yaxis().set_visible(False)
self.canvas.mpl_connect('button_press_event', self.on_press)
global x1,y1
self.rect = patches.Rectangle((x1, y1), 40, 40,edgecolor='g', alpha=1, fill=None, label='Label')
self.axes.add_patch(self.rect)
self.axes.plot()
def on_press(self, click):
global x1, y1
x1, y1 = click.xdata, click.ydata
list_var4 = self.list_var4[int(y1),int(x1)]
lon = self.lons[int(y1),int(x1)]
lat = self.lats[int(y1),int(x1)]
self.GrandParent.right.bottom.bottom.top.Update(list_var4)
zx1 = x1 - 20
zy1 = y1 - 20
zx2 = x1 + 20
zy2 = y1 + 20
self.rect.set_x(x1 - 20 ) #Move the rectangle and centre it on the X click point
self.rect.set_y(y1 - 20 ) #Move the rectangle and centre it on the Y click point
x1=x1-20
y1=y1-20
self.axes.plot()
self.canvas.draw()
self.zoom_axes=[zx1,zx2,zy1,zy2]
global zoom
global zoom2
zoom=self.zoom_axes
self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)
self.GrandParent.middle.top.Update(zoom)
'self.GrandParent.middle.bottom.Update(zoom)'
self.GrandParent.right.top.Update(zoom)
self.GrandParent.right.bottom.top.right.Update(self.zoom_axes)
self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)
self.GrandParent.right.bottom.top.middle.Update(self.zoom_axes)
class RightPanelBottomBottomTop(wx.Panel):
def init(self,parent):
super().init(parent,style = wx.SUNKEN_BORDER)
self.text_ctrl = wx.TextCtrl(self, -1, “”, style=wx.TE_MULTILINE|wx.BORDER_SUNKEN|wx.TE_READONLY|wx.TE_RICH2, size=(700,30))
self.text_ctrl.SetBackgroundColour(‘cyan’)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.text_ctrl,0)
self.SetSizer(sizer)
def Update(self,x1,y1,list_var3,lon,lat,list_var4):
update_str = "X :"+str(int(x1)) + " " +"Y :"+str(int(y1)) + " "+ "var3 :"+str(int(list_var3))+" "+"Lon : "+str(int(lon))+" "+"Lat :"+str(int(lat))+ "var4 :"+str(int(list_var4))
self.text_ctrl.SetValue(update_str)
``
how i can add the values of self,x1,y1,list_var3,lon,lat,list_var4 from the middlepanelbottom & middlepaneltop and show it in RightPanelBottomBottomTop without having this error ?
thank you
···
–
You received this message because you are subscribed to the Google Groups “wxPython-users” group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/1bf572b5-32bc-4a26-a2ec-5a75f26a0283%40googlegroups.com.