Hi!
I have a problem using the layour constraints. I created a wxWindow, then i inserted a wxButton. After that, i want to create a wxStaticText that is NOT overlapping with the wxButton. But i cant get it working.
Here is the code that should (as far as i understand) proce a static_text and button that are not overlapping. I would aprettiate if anyone could show me whats wrong in my understanding of LayoutConstraints so i can fix it.
# create expand button
b = wxButton(self.panelA, 1010, "")
lc = wxLayoutConstraints()
lc.top.SameAs(self.panelA, wxTop)
lc.bottom.SameAs(self.panelA, wxBottom)
lc.left.SameAs(self.panelA, wxLeft)
lc.width.Absolute(15)
b.SetConstraints(lc)
# create frame title
lc = wxLayoutConstraints()
lc.top.SameAs(self.panelA, wxTop)
#lc.bottom.SameAs(self.panelA, wxBottom)
lc.left.SameAs(b, wxRight)
lc.right.SameAs(self.panelA, wxRight)
#lc.width.Absolute(15)
l = wxStaticText(self.panelA, -1, "class name")
l.SetConstraints(lc)
(See attached file for complete source)
Another problem i had is that i could not get a wxWindow/wxPanel to show if i put it inside a wxBoxSizer. How should i solve this?
Thanks a lot!
Lucio
------------------------------------------------------------------------
from wxPython.wx import *
import os
from wxPython.html import *
import wxPython.lib.wxpTag
from wxPython.wx import *
from wxPython.lib.layoutf import Layoutf
ID_ABOUT = wxNewId()
ID_EXIT = wxNewId()
ID_Timer = wxNewId()
class xml_edit_panel(wxPanel):
def __init__(self, parent, frame, log):
wxPanel.__init__(self, parent, -1)
self.SetBackgroundColour(wxWHITE)
self.SetAutoLayout(true)
self.panelA = wxWindow(self, -1, wxPyDefaultPosition, wxPyDefaultSize, wxSIMPLE_BORDER)
self.panelA.SetBackgroundColour(wxBLUE) self.panelA.SetConstraints(Layoutf('t=t#1;l=l#1;b=b#1;r=r#1',(self,)))
# create expand button
b = wxButton(self.panelA, 1010, "")
lc = wxLayoutConstraints()
lc.top.SameAs(self.panelA, wxTop)
lc.bottom.SameAs(self.panelA, wxBottom)
lc.left.SameAs(self.panelA, wxLeft)
lc.width.Absolute(15)
b.SetConstraints(lc)
# create frame title
lc = wxLayoutConstraints()
lc.top.SameAs(self.panelA, wxTop)
#lc.bottom.SameAs(self.panelA, wxBottom)
lc.left.SameAs(b, wxRight)
lc.right.SameAs(self.panelA, wxRight)
#lc.width.Absolute(15)
l = wxStaticText(self.panelA, -1, "class name")
l.SetConstraints(lc)
class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(200, 150))
self.CreateStatusBar()
self.SetStatusText("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)
self.edit_panel = xml_edit_panel(self,self, 1)
EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)
def OnAbout(self, event):
dlg = wxMessageDialog(self, "This sample program shows off\n"
"frames, menus, statusbars, and this\n"
"message dialog.",
"About Me", wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def TimeToQuit(self, event):
self.Close(true)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
app = MyApp(0)
app.MainLoop()
------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org