I'm creating an application with wxPython and VTK. There is a configuration panel (wx.Panel) on the left of screen and a VTK window on the right, also based on a wx.Panel. The panels are placed in the wxFrame's boxsizer and sized using proportional sizing as defined in the wxFormBuilder application, which is then used to generate an XRC file.
I am having a very specific problem with some Windows 7 machines consistently not sizing the VTK portion of the window correctly - See the white border around the VTK window in the screenshot above. I am attempting to make this VTK window a fixed 1280x720 - and it is - but there is a sizing issue with some element which is chopping of the bottom and right of the window. This bug is not present when run on Ubuntu 10.04, XP, or some builds of Windows 7 (I'm not sure what is unique about those that work and those that don't yet).
When experiencing this bug, I can interact with the white portions of the screen - clicks are correctly handled through the VTK interactor, so it's sort-of still part of my VTK scene.
The application setup is as below, where the right-hand VTK pane is the graphics_panel
. The panel is set with wxEXPAND
and no other flags, and all elements in my app are set to size automatically (no min, max or default size set). The only exception to this is bSizer1 (the main wxFrame sizer) which has a minimum width and height set (I'm not sure if this is the right way to go, but it seems to work okay).
I generate XRC from wxFormBuilder and then use this in my application, where have my VTK scene set up as below:
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 have been trying to troubleshoot what element is sized what using the on_size
function for MyScene
, but nothing below fixes my issue. The values reported on both correctly functioning and erroneous systems are as 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)
On a correctly functioning system, the output is:
---- MyScene on_size ----
Widget size: (1280, 720)
Client size: (1296, 720)
Parent size: (1296, 720)
Renderer size: (1280, 720)
On 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)
So in summary, I don't know which element is being sized incorrectly. The VTK renderer size is correct, as taking a VTK screenshot to file produces a 1280x720 output showing the full scene with no white clipping, and as said above I can interact with the VTK scene using the white 'clipped' portions of the screen.
Is this a VTK or WX element not being sized correctly? Can anyone give me any tips on how to troubleshoot this problem further? Which other elements should I be looking at the sizes of? How should I be hard-sizing my graphics panel to 1280x720 and letting my config panel size itself appropriately?
The issue occurs when using Python 2.7.5, VTK 5.10.1 and wxpython 2.8, but only on some Windows 7 machines.