VTK window does not populate wx.Panel

I am building an application with wxPython and VTK. On the left side of the screen there is a configuration panel (wx.Panel) and a VTK window on the right, also based on wx.Panel. The panels are placed in the wxFrame box and are proportional to the size defined in the wxFormBuilder application, which is then used to generate the XRC file.

enter image description here

I had a very specific problem with some Windows 7 machines that do not change the correct proportion of part of the VTK window. See the white frame around the VTK window in the screenshot above. I am trying to make this VTK window fixed at 1280x720 - and that is - but there is a problem with the size of some element that cuts the bottom and right of the window. This error is missing when running on Ubuntu 10.04, XP, or some builds of Windows 7 (I'm not sure what is unique to those who work and those that have not yet been created).

When I experience this error, I can interact with white portions of the screen - clicks are correctly processed through interaction with VTK, so it sorts still part of my VTK scene.

The application configuration is as shown below, where the right pane of VTK is graphics_panel . The panel is installed with wxEXPAND and no other flags, and all elements in my application will not be automatically installed (there is no minimum, maximum or specified size by default). The one exception is bSizer1 (the main wxFrame sizer), which has minimal width and height (I'm not sure if this is the right way, but everything seems to be okay).

panel setup

I generate XRC from wxFormBuilder and then use it in my application, where my VTK scene is configured as follows:

 class MyScene(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent, style=wx.NO_BORDER) #'parent' is main_frame (wx.Frame instance) self._parent = parent self.renderer = vtk.vtkRenderer() # I create and add my VTK actors here (SNIPPED) self._set_lighting() self.widget = VTKWidget(self,-1) #VTKWidget is a wxVTKRenderWindowInteractor self.widget.GetRenderWindow().AddRenderer(self.renderer) self.widget.Enable(1) self.widget.SetDoubleBuffered(True) self.Bind(wx.EVT_SIZE, self.on_size) 

I'm trying to fix which element has a size that uses the on_size function for MyScene , but none of the below fixes my problem. Values ​​reported by both properly functioning and erroneous systems are expected.

 def on_size(self, evt): print "---- MyScene on_size ----" print "Widget size:", self.widget.GetSize() #wxVTKRenderWindowInteractor print "Client size:", self.GetClientSize() #wxPanel.GetClientSize print "Parent size:", self._parent.GetSize() #wxFrame print "Renderer size:", self.renderer.GetSize() #vtkRenderer self.renderer.Clear() self.widget.SetSize((1280, 720)) renWin = self.widget.get_render_window() renWin.SetSize(1280, 720) self._parent.Layout() self.renderer.Clear() renWin.SetSize(1280, 720) 

In a properly functioning system, the output is:

 ---- MyScene on_size ---- Widget size: (1280, 720) Client size: (1296, 720) Parent size: (1296, 720) Renderer size: (1280, 720) 

In a "bad" Windows 7 system, as in the screenshot in this question, the output is similar:

 ---- MyScene on_size ---- Widget size: (1280, 720) Client size: (1234, 728) Parent size: (1234, 728) Renderer size: (1280, 720) 

Thus, I do not know which element has the wrong size. The VTK rendering size is correct, since taking a VTK screenshot to a file results in a 1280x720 output showing the full scene without white cropping, and as mentioned above, I can interact with the VTK scene using white “cropped” parts of the screen.

Is this VTK or WX element incorrect? Can someone give me any tips to fix this problem? What other elements should I look at sizes? How can I hard adjust my graphic panel to 1280x720 and allow the very size of my configuration panel?

The problem occurs when using Python 2.7.5, VTK 5.10.1, and wxpython 2.8, but only on some Windows 7 machines.

+7
python wxpython wxwidgets vtk
source share
1 answer

Like you, I am developing an application using vtk and wxpython, this cocktail is once amazing! I think your problem comes from a lack of sizer. the snapshot below works on both linux and windows (including 7):

 class Plotter3d(wx.Panel): def __init__(self, parent, *args, **kwargs): wx.Panel.__init__(self, parent, *args, **kwargs) self.build_panel() def build_panel(self): self.viewer = wx.Panel(self) self.iren = wxVTKRenderWindowInteractor(self.viewer, -1, size=(500,500), flag=wx.EXPAND) self.iren.SetPosition((0,0)) self.iren.Enable(1) # create renderer self.renderer = vtk.vtkRenderer() self.iren.GetRenderWindow().AddRenderer(self.renderer) Sizer = wx.BoxSizer(wx.VERTICAL) Sizer.Add(self.iren, 1, wx.EXPAND, 0) self.viewer.SetSizer(Sizer) Sizer.Fit(self.viewer) self.viewer.Layout() 

hope this helps you

+1
source share

All Articles