How do you draw this layout with wxpython?

Tim timb at tbitc.com
Mon Oct 17 09:24:45 CEST 2005


Young H. Rhiu wrote:
> See: http://hilug.org/img/app_layout.GIF
> 
> I'm implementing an album-like application with wxpython but I'm new to
> wxPython though I know how to program with python. The problem is that
> it's not easy for me to deal with drawing layout stuff with wxpython.
> What layout I'm thinking of looks like the gif image above.
> 
> The application is about saving some comments for each pictures on the
> filesystem. There are two windows. The above one is a window for
> loading some images and the below one is a TextCtrl for writing
> comments and if img1, for instance, is clicked, the first notebook(?)
> folder should be active.
> 
> Below is the program I tried but I don't know how to attach a notebook
> window under the image window.
> Any help is greatly appreciated.
> 
> Thanks in Advance, Rhiu
> 
> My Code:
> from wxPython.wx import *
> 
> class smallAppFrame(wxFrame):
>     def __init__(self, parent, id, title):
>         wxFrame.__init__(self, parent = None, id = -1,
>                          title = "MySmallApp", pos = wxPoint(200, 200),
>                          size = wxSize(460, 200), style =
> wxDEFAULT_FRAME_STYLE)
> 
>         self.bitmap01 = wxStaticBitmap(self, -1,
> wxEmptyBitmap(100,100))
>         self.bitmap02 = wxStaticBitmap(self, -1,
> wxEmptyBitmap(100,100))
>         self.bitmap03 = wxStaticBitmap(self, -1,
> wxEmptyBitmap(100,100))
>         self.bitmap04 = wxStaticBitmap(self, -1,
> wxEmptyBitmap(100,100))
> 
>         box = wxBoxSizer(wxHORIZONTAL)
> 
>         box.Add((10,10))
>         box.Add(self.bitmap01, 0, wxALIGN_CENTER)
>         box.Add((10,10))
>         box.Add(self.bitmap02, 0, wxALIGN_CENTER)
>         box.Add((10,10))
>         box.Add(self.bitmap03, 0, wxALIGN_CENTER)
>         box.Add((10,10))
>         box.Add(self.bitmap04, 0, wxALIGN_CENTER)
>         box.Add((10,10))
> 
>         self.SetAutoLayout(True)
>         self.SetSizer(box)
> 
> class MySmallApp(wxApp):
>     def OnInit(self):
>         frame = smallAppFrame(None, -1, "MySmallApp")
>         frame.Show(true)
>         self.SetTopWindow(frame)
>         return true
> 
> app = MySmallApp(0)
> app.MainLoop()
> 
Hi
Take a LONG look at Boa Constructor. Boa is young, imperfect, and a 
little emotional at times.

BUT after spending a few hours with it - I think I could create your 
screen layout in a matter of minutes.

Really is worth the steep learning curve and the frustration.
timb




More information about the Python-list mailing list