panels showing up
Nathan smith <[email protected]> Mon, 22 Feb 2021 01:22:50 +0000
| Newsgroups | gmane.comp.python.wxpython |
|---|---|
| Message-ID | <[email protected]> |
Hi folks,
I know I've mentioned this here before and the general agreement seems
to be "It's weird."
I wanted to ask first off, is there any problem with creating a panel
from within the __init__ of the frame?
Like so:
class Mywin(wx.Frame):
def __init__(self, parent, title):
super(Mywin, self).__init__(parent, title = title,size = (850,850),
style=wx.DEFAULT_FRAME_STYLE)
self.SetName("Accessible Calculator.")
panel = wx.Panel(self, wx.Window.NewControlId(), style= wx.WANTS_CHARS)
panel.Bind(wx.EVT_KEY_DOWN, self.press)
self.panel=panel
I'm pretty sure it should work fine, but I just wanted to check. It
doesn't traceback or anything but the panel is not showing up when I run
my showpanel code so I was wondering if there was something backstage
going on crazily there?
Regarding said show panel code, i have it reading as thus:
def showpanel(self, panel):
panel.Show()
panel.Fit()
# panel.Layout()
# panel.Update()
self.Show()
self.Fit()
self.Layout()
# self.Update()
# self.Refresh()
self.Center()
The frame does show with the title, but the panel is not showing up,
despite the fact this code works in other programs.
This would suggest there's something wrong with my sizer's?
I have a sample of this shown below:
vbox2 = wx.BoxSizer(wx.HORIZONTAL)
vbox = wx.BoxSizer(wx.VERTICAL)
font = wx.Font(12, wx.MODERN, wx.NORMAL, wx.NORMAL)
self.sum = wx.TextCtrl(panel, style=wx.TE_READONLY)
self.sum.SetFont(font)
self.sum.Bind(wx.EVT_KEY_DOWN, self.press)
vbox2.Add(self.sum, 1, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL,5)
# some more widgets being added here to vbox
vbox2.Add(vbox, 0, wx.EXPAND|wx.ALL, 3)
vbox2.Add(self.history, 0, wx.EXPAND|wx.ALL, 3) # self.history is a
texctrl that should show up to the right.
panel.SetSizer(vbox2)
self.showpanel(panel)
I appreciate any help you can offer and realise it's probably something
really simple not getting through my thick skull.
V Best,
Nathan
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wxpython-users/fe874c07-b9a6-7b19-e970-2651e43d8f2f%40gmail.com.