Once again, I'm stuck on a wx.python issue with regards to the floatcanvas. So... I have a script that erases and redraws an image in the canvas, based on changes made to two slider widgets (sldMFI, sldIDT). Before it redraws, I'm trying to define the current zoomed view as the new bounding box, so that after the redraw it doesn't go back to the full zoom view. Basically, I'm trying to stay zoomed in on whatever I was looking at. I don't know if the problem is how I'm trying to set up the bounding box, or how I initially set up my canvas. So far nothing has worked. I'm not sure how to get the current extents of the zoom window to define a specific bounding box either. I've included part of my _init_ code and the funtion calling the redraw. Any suggestions would be greatly appreciated. Thanks.
-Roger

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
                
        #Adding the SplitterWindow
        self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE|wx.SP_3D, size = (1400,800))
     
        self.dc = wx.MemoryDC()

        # add the left Panel
        self.panel1 = wx.Panel(self.splitter) 
         
        self.sldMFI = wx.Slider(..........)
        self.sldIDT = wx.Slider(...........) 
       
        cursorINIT.close()
        connINIT.commit()
        connINIT.close()

        self.Bind(wx.EVT_SCROLL_THUMBRELEASE, self.on_select, self.sldMFI)  
        self.Bind(wx.EVT_SCROLL_THUMBRELEASE, self.on_select, self.sldIDT)     

        self.panel1.SetBackgroundColour(wx.WHITE)     
        # add the Canvas
        
        self.panel2 = NavCanvas.NavCanvas(self.splitter,wx.ID_ANY ,(500,300),
                                     ProjectionFun = None,
                                     Debug = 0,
                                     BackgroundColor = "LIGHT GRAY",
                                     )
        self.Canvas = self.panel2.Canvas
                
        FloatCanvas.EVT_MOTION(self.Canvas, self.OnMove )
def on_select(self, event):        
        
        self.MFImin = -(self.sldMFI.GetValue())  
        self.IDTmin = -(self.sldIDT.GetValue())
        self.FilePath = self.fbb.GetValue()
      
        self.dc.ResetBoundingBox() #<<-- Attempting to set the current zoomed view as the BoundingBox....
        self.Canvas.ClearAll()      
               
        self.doGenReMapping(FFileName,self.IDTmin, self.MFImin)
        wx.CallAfter(self.Canvas.ZoomToBB)

Figured it out.

My mistake was that I was trying to redefine the bounding box. The fix was actually much simpler. Instead of trying to Zoom to the BB after the clear, I just use Zoom with a scale of 1.

def on_select(self, event): 
        self.MFImin = -(self.sldMFI.GetValue())  
        self.IDTmin = -(self.sldIDT.GetValue())   
        self.FilePath = self.fbb.GetValue()     
      
        self.Canvas.ClearAll()          
      
        self.doGenReMapping(FFileName,self.IDTmin, self.MFImin)          
        self.Canvas.Zoom(1))
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.