Apr-03-2021, 04:49 PM
I'm trying place a wx.PaintDC object inside a cell for the GridBagSizer.
I don't understand why it doesn't show.
I can use a Boxsizer and it will show the title. I can place text inside and it will show. Just not with the PaintDC.
Any help would be great.
I don't understand why it doesn't show.
I can use a Boxsizer and it will show the title. I can place text inside and it will show. Just not with the PaintDC.
Any help would be great.
#! /usr/bin/env python3 # Do the imports import wx class Header(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) self.Bind(wx.EVT_PAINT, self.OnPaint) def OnPaint(self, event): font = wx.Font(25, wx.ROMAN, wx.ITALIC, wx.BOLD) self.SetBackgroundColour('white') dc = wx.PaintDC(self) dc.SetFont(font) dc.DrawText('wxPython Yahtzee', 250, 10) self.SetForegroundColour('orange') class MainWindow(wx.Frame): def __init__(self, parent, id): wx.Frame.__init__(self, parent, -1, 'Yahtzee', size=(800, 600)) sizer = wx.GridBagSizer(vgap=2, hgap=2) header = Header(self, wx.ID_ANY) sizer.Add(header, pos=(0,0), flag=wx.EXPAND, span=(1, 1)) self.SetSizerAndFit(sizer) def main(): app = wx.App(False) window = MainWindow(None, wx.ID_ANY) window.Show() app.MainLoop()