I’ve been having layout issues cross-platform, but I think I’ve narrowed it down. It’s such a very basic looking problem, but it has been rather irritating. I’m using python 2.7.6. and it runs fine on ubuntu (wx version 2.8.12), but running it on windows xp (wx version 3.0), causes it to have layout issues, where it looks like the notebook (or just the panel itself, i’ve tried both cases) was never added to a sizer, and you can see the little block in the top left under then menu. Removing the menu by just commenting out the stuff between the comment lines will let the notebook/panel appear, but obviously there won’t be a menu bar. Anyone know the (probably obvious) answer to have both the menubar and panel/notebook appear normally in windows?
Oh, also, if anyone knows why wx.ID_EXIT doesn’t work in windows. In the line, file_item = file_menu.Append(ID_EXIT,‘Quit\tCTRL+Q’), used to be wx.ID_EXIT instead of ID_EXIT, but it didn’t work cross-platform, since the ctrl+q shortcut disappears, so I just wrote it out explicitly which worked for both systems. Definitely not important since it’s fixed, but I would like to have the shorthand back.
···
import wx
ID_EXIT = wx.NewId()
class MainFrame(wx.Frame):
def init(self):
wx.Frame.init(self, None, wx.ID_ANY,“Foo”,size=(600,400))
panel = wx.Panel(self)
##########################################
menu_bar = wx.MenuBar()
file_menu = wx.Menu()
file_item = file_menu.Append(ID_EXIT,'Quit\tCTRL+Q')
menu_bar.Append(file_menu,'File')
self.SetMenuBar(menu_bar)
self.Bind(wx.EVT_MENU,self.OnQuit,file_item)
##########################################
notebook = Notebook(panel)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(notebook, 1, wx.ALL | wx.EXPAND, 5)
panel.SetSizer(sizer)
self.Center()
def OnQuit(self,event):
self.Close()
class TabPanelOne(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent=parent, id=wx.ID_ANY)
class Notebook(wx.Notebook):
def init(self, parent):
wx.Notebook.init(self, parent, id=wx.ID_ANY, style=wx.BK_DEFAULT)
tab1 = TabPanelOne(self)
tab1.SetBackgroundColour("Gray")
self.AddPage(tab1, "Bar")
if name == “main”:
app = wx.App(False)
frame = MainFrame()
frame.Show()
app.MainLoop()