Enrico Tuvera Jr
Enrico Tuvera Jr

Reputation: 2817

wxPython program showing nothing but grey screen

I've got a small wxPython program (Python version 2.7, wxPython 2.8) up and running, but it doesn't display anything but a gray screen and a small portion of one of the buttons in the upper left corner.

I had the same problem the other day and I found that it was because I had run self.SetSizer() instead of self.panel.SetSizer(). But now it's happening even though I've made sure to avoid making that mistake this time. What am I missing here?

http://bpaste.net/show/Vq02tHA85pPi3Fm6aUtI/ <--code here

Upvotes: 1

Views: 270

Answers (2)

Mike Driscoll
Mike Driscoll

Reputation: 33111

The problem is a parenting issue. You need to make all the widgets children of the panel. The panel should be the ONLY child of the frame. In your case, you made the panel AND the mediaCtrl widget children of the frame. If you change your media control instantiation to the following, it should work:

self.media_control = wx.media.MediaCtrl(self.apanel,
    style=wx.SIMPLE_BORDER,
    szBackend=wx.media.MEDIABACKEND_DIRECTSHOW)

Note that the MediaCtrl is invisible. You'll probably have to add it to the sizer to make it work completely correctly.

Upvotes: 1

user2849038
user2849038

Reputation: 33

try set absolute:

self.apanel = wx.Panel(self, -1, size=(640, 480))

or use function GetBestSize()

self.apanel = wx.Panel(self, -1, size=self.GetBestSize())

I run successfully in py27

Upvotes: 0

Related Questions