Hmm, on WinXP fixing that doesn't fix the problem. I had to do that and also
comment out the bits about self.trans_panel, which I couldn't see what
its purpose
was. Then it works nicely. Code below:
# Minimal example for testing notebook behaviour.
import wx
import wx.grid as gridlib
import wx.lib.inspection
class AboutDialog(wx.Dialog):
class TranslatorsTable(gridlib.Grid):
def __init__(self, parent):
gridlib.Grid.__init__(self, parent, -1)
self.moveTo = None
self.CreateGrid(1, 3) # (rows, cols)
self.EnableEditing(False)
self.SetRowLabelSize(0)
self.SetColLabelValue(0, "Language")
self.SetColLabelValue(1, "Translator")
self.SetColLabelValue(2, "Website")
self.SetColLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_BOTTOM)
class AboutNotebook(wx.Notebook):
def __init__(self, parent, id):
wx.Notebook.__init__(self, parent, id, style = wx.BK_DEFAULT)
self.about_panel = wx.Panel(self, -1)
self.about_main_sizer = wx.BoxSizer(wx.VERTICAL)
self.about_text = wx.StaticText(self.about_panel, -1,
"Copyright 2007-2008 Wayne Koorts:\n" \
"http://www.wkoorts.com\n\n",
(-1, -1))
self.about_main_sizer.AddSpacer(30)
self.about_main_sizer.Add(self.about_text, 0,
wx.ALIGN_CENTER|wx.ALL, 15)
self.about_panel.SetSizerAndFit(self.about_main_sizer)
self.AddPage(self.about_panel, "About")
## self.trans_panel = wx.Panel(self, -1)
## self.trans_main_sizer = wx.BoxSizer(wx.VERTICAL)
self.trans_grid = parent.TranslatorsTable(self)
## self.trans_main_sizer.Add(self.trans_grid, 0,
wx.ALIGN_CENTER|wx.ALL, 15)
···
On Sat, Feb 21, 2009 at 11:24 PM, Wayne Koorts <wayne@wkoorts.com> wrote:
Running v2.8.9.1 Unicode on Win XP. Minimal running sample of the
problem attached. I've created a custom dialog class with a notebook
containing two tabs. One contains a static text widget and the other a
grid. When the dialog is launched it displays an odd black area around
the text widget on the first tab, and hides the tabs. The black area
seems to be an outline of the grid widget which is on the second tab.
What am I doing wrong? Is it something to do with the way I am using
the panels?
Looks fine on my mac but the problem is likely that your static text is a
child of the notebook and not the about_panel that is added to the
notebook..
Ah, that was indeed the problem! Thanks Cody.
##
## self.trans_panel.SetSizerAndFit(self.trans_main_sizer)
self.AddPage(self.trans_grid, "Translators")
def __init__(self, parent, ID, title, size = wx.DefaultSize, pos =
wx.DefaultPosition,
style = wx.DEFAULT_DIALOG_STYLE):
pre = wx.PreDialog()
pre.SetExtraStyle(wx.DIALOG_EX_CONTEXTHELP)
pre.Create(parent, ID, title, pos, size, style)
self.PostCreate(pre)
self.main_sizer = wx.BoxSizer(wx.VERTICAL)
self.about_notebook = self.AboutNotebook(self, -1)
self.main_sizer.Add(self.about_notebook, 0, wx.ALIGN_CENTER|wx.ALL, 5)
self.button_sizer = wx.StdDialogButtonSizer()
self.ok_button = wx.Button(self, wx.ID_OK)
self.ok_button.SetLabel("OK")
self.ok_button.SetDefault()
self.button_sizer.AddButton(self.ok_button)
self.button_sizer.Realize()
self.main_sizer.Add(self.button_sizer, 0, wx.ALIGN_CENTER|wx.ALL, 5)
self.SetSizer(self.main_sizer)
self.main_sizer.Fit(self)
class MainWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, style = wx.CAPTION |
wx.SYSTEM_MENU | wx.MINIMIZE_BOX | wx.CLOSE_BOX)
self.main_panel = wx.Panel(self, -1)
self.about_button = wx.Button(self.main_panel, -1, "Open
dialog", (50, 50))
self.Bind(wx.EVT_BUTTON, self.onAbout, self.about_button)
self.border_sizer = wx.BoxSizer()
self.border_sizer.Add(self.about_button)
self.main_panel.SetSizerAndFit(self.border_sizer)
self.Fit()
self.Centre()
self.Show(True)
def onAbout(self, e):
about_dlg = AboutDialog(self, -1, "Test dialog", style =
wx.DEFAULT_DIALOG_STYLE)
about_dlg.CenterOnScreen()
about_dlg.ShowModal()
about_dlg.Destroy()
def main():
app = wx.PySimpleApp()
mainView = MainWindow(None, wx.ID_ANY, "Minimal wx app")
#wx.lib.inspection.InspectionTool().Show()
app.MainLoop()
if __name__ == "__main__":
main()