Aaron Marks
Aaron Marks

Reputation: 385

wxPython application completely invisible in OSX

I have a Python application which uses wxPython for a GUI. It runs fine on a Windows XP machine, but I need to work on it on my Mac.

On OSX, running main.py works, and it brings up a window called "Python" (and keeps the process running in the terminal). But, where in XP the Python window has the GUI, the OSX version is totally invisible. Nothing shows at all (but the application is definitely open. Hitting enter in the "invisible window" causes the expected response in the terminal)

What might I need to add / modify to make anything actually show up on OSX? The window init code all seems OS-agnostic, except for the specified font ('MS Shell Dig 2').

Upvotes: 0

Views: 201

Answers (1)

user606547
user606547

Reputation:

Do you have a wx.Panel as the main child of your frame? Create a single panel in your main frame and add the rest of your controls to that panel instead of the frame itself. I recall having some problems similar to yours which were solved in this way.

Something quick to show the idea:

import wx

class MainWindow(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        self.panel = wx.Panel(self)
        # Add other controls to the main panel, not the frame
        self.text = wx.TextCtrl(self.panel) 
        self.Show()

app = wx.App(False)
win = MainWindow(None)
app.MainLoop()

Upvotes: 1

Related Questions