ERROR when showing values from 2 panels in one panel using wxpython4

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.

– 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 .
To view this discussion on the web visit .

···

Tiera Eyek wrote:

      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’

  I'm sorry for being blunt, but your design is totally broken.  No

human being could possibly understand what’s going on in a
statement like that, or like this:

` self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)

   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)

    `

  This object should have NO IDEA what the architecture of its

parent is, much less its grandparent and its children. Seriously,
I would fire a programmer that tried something like this in a
commercial project. What would happen, God forbid, if you had to
add another panel? How would you possibly know how to modify the
code?

  What you need here is some kind of a "publish/subscribe", or at

least a “model/view” pattern. You need to have one object that
stores your state information, then the individual panels get a
copy of that object. Functions like on_press can update the
global state (the “model”), and then the model can trigger a
callback into all the view panels. The panels can go see if the
information they need has changed. What you’re doing here is just
unmaintainable.

  As it is, there's no way we can diagnose this, because we don't

know what that’s calling. Apparently, the “Update” call is
somehow triggering a callback to a routine somewhere in matplotlib
that needs at least one more argument.

-- Tim Roberts, Providenza & Boekelheide, Inc.

wxpython-users+unsubscribe@googlegroups.com
https://groups.google.com/d/msgid/wxpython-users/29c8bde0-c10b-ad5d-88cf-e8bb3b12df10%40probo.com
timr@probo.com

this is just part of code is not al code of app but i find solution thank you .

Le mer. 31 juil. 2019 à 02:50, Tim Roberts timr@probo.com a écrit :

···

Tiera Eyek wrote:

      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’

  I'm sorry for being blunt, but your design is totally broken.  No

human being could possibly understand what’s going on in a
statement like that, or like this:

` self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)

   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)

    `
  This object should have NO IDEA what the architecture of its

parent is, much less its grandparent and its children. Seriously,
I would fire a programmer that tried something like this in a
commercial project. What would happen, God forbid, if you had to
add another panel? How would you possibly know how to modify the
code?

  What you need here is some kind of a "publish/subscribe", or at

least a “model/view” pattern. You need to have one object that
stores your state information, then the individual panels get a
copy of that object. Functions like on_press can update the
global state (the “model”), and then the model can trigger a
callback into all the view panels. The panels can go see if the
information they need has changed. What you’re doing here is just
unmaintainable.

  As it is, there's no way we can diagnose this, because we don't

know what that’s calling. Apparently, the “Update” call is
somehow triggering a callback to a routine somewhere in matplotlib
that needs at least one more argument.

-- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

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/29c8bde0-c10b-ad5d-88cf-e8bb3b12df10%40probo.com.

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/CANrq3PY2VN7WoU2g0mxoAPavo7BEfkQ%3DZRX_1Z5dFL1jp%3DTv%2Bw%40mail.gmail.com.

hi,

i find solution that is good now thank you

Le mer. 31 juil. 2019 à 02:50, Tim Roberts timr@probo.com a écrit :

···

Tiera Eyek wrote:

      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’

  I'm sorry for being blunt, but your design is totally broken.  No

human being could possibly understand what’s going on in a
statement like that, or like this:

` self.GrandParent.right.bottom.top.left.Update(self.zoom_axes)

   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)

    `
  This object should have NO IDEA what the architecture of its

parent is, much less its grandparent and its children. Seriously,
I would fire a programmer that tried something like this in a
commercial project. What would happen, God forbid, if you had to
add another panel? How would you possibly know how to modify the
code?

  What you need here is some kind of a "publish/subscribe", or at

least a “model/view” pattern. You need to have one object that
stores your state information, then the individual panels get a
copy of that object. Functions like on_press can update the
global state (the “model”), and then the model can trigger a
callback into all the view panels. The panels can go see if the
information they need has changed. What you’re doing here is just
unmaintainable.

  As it is, there's no way we can diagnose this, because we don't

know what that’s calling. Apparently, the “Update” call is
somehow triggering a callback to a routine somewhere in matplotlib
that needs at least one more argument.

-- Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

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/29c8bde0-c10b-ad5d-88cf-e8bb3b12df10%40probo.com.

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/CAOUZSpF0hrxr2cxG1Urq80%2B6%2BTNZ13Ob1N6onDoe06__sNNQww%40mail.gmail.com.