On Feb 25, 7:15 pm, Matthew Edwards <[email protected]> wrote:
> Are you just talking about menus and dialogs and things, or are you
> going to have controls scattered throughout the window instead of in
> particular groups? Could you use a panel for a dialog and only use
> sizers to lay out the controls for that dialog?
I intend to have controls actually on top of the game display.
Found a working method!
class TestPanel(wx.Panel):
def __init__(self, parent, id=-1):
wx.Panel.__init__(self, parent, id)
self.SetAutoLayout(True)
gamePanel = TestCanvas(self)
lc = wx.LayoutConstraints()
lc.left.SameAs(self, wx.Left, 0)
lc.right.SameAs(self, wx.Right, 0)
lc.top.SameAs(self, wx.Top, 0)
lc.bottom.SameAs(self, wx.Bottom, 0)
gamePanel.SetConstraints(lc)
ulPanel = wx.Window(self, -1)
ulText = wx.StaticText(ulPanel, -1, "Upper Left")
width, height = ulText.GetSize()
lc = wx.LayoutConstraints()
lc.top.SameAs(self, wx.Top, 10)
lc.left.SameAs(self, wx.Left, 10)
lc.width.Absolute(width)
lc.height.Absolute(height)
ulPanel.SetConstraints(lc)
lrPanel = wx.Window(self, -1)
lrText = wx.StaticText(lrPanel, -1, "Lower Right")
width, height = lrText.GetSize()
lc = wx.LayoutConstraints()
lc.bottom.SameAs(self, wx.Bottom, 10)
lc.right.SameAs(self, wx.Right, 10)
lc.width.Absolute(width)
lc.height.Absolute(height)
lrPanel.SetConstraints(lc)
As far as I can tell, LayoutConstraints won't poll their children to
find out the best size, so you have to give them enough information
that they can determine all 4 sides - hence, the code above that
checks the width of the text so that they can be positioned at the
extreme corners. This code gives them a 10 pixel margin.
Excellent! Now to re-factor my code. o_o
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---