python - Why should I make multiple wx.Panel's? -


following this tutorial on wxpython, i've noticed in find/replace dialog example there panels doesn't seem they're doing anything. in fact, seem mess more layout (though mistake made somewhere) example, tutorial has code:

panel = wx.panel(self, -1)  panel1 = wx.panel(panel, -1) grid1 = wx.gridsizer(2, 2) grid1.add(wx.statictext(panel1, -1, 'find: ', (5, 5)), 0,  wx.align_center_vertical) grid1.add(wx.combobox(panel1, -1, size=(120, -1))) grid1.add(wx.statictext(panel1, -1, 'replace with: ', (5, 5)), 0, wx.align_center_vertical) grid1.add(wx.combobox(panel1, -1, size=(120, -1)))  panel1.setsizer(grid1) vbox.add(panel1, 0, wx.bottom | wx.top, 9) 

why different from:

panel = wx.panel(self, -1)  grid1 = wx.gridsizer(2, 2) grid1.add(wx.statictext(panel, -1, 'find: ', (5, 5)), 0,  wx.align_center_vertical) grid1.add(wx.combobox(panel, -1, size=(120, -1))) grid1.add(wx.statictext(panel, -1, 'replace with: ', (5, 5)), 0, wx.align_center_vertical) grid1.add(wx.combobox(panel, -1, size=(120, -1)))  vbox.add(grid1, 0, wx.bottom | wx.top, 9) 

note i'm not creating panel, adding grid1 directly vbox.

i'm not sure. i've re-written example less code, although it's bit hard follow. may e-mail suggestions her.

import wx  class findreplace(wx.dialog):     def __init__(self, parent, id, title):         wx.dialog.__init__(self, parent, id, title, size=(255, 365))          vbox_top = wx.boxsizer(wx.vertical)         vbox = wx.boxsizer(wx.vertical)          grid1 = wx.gridsizer(2, 2)         grid1.add(wx.statictext(self, -1, 'find: ', (5, 5)), 0,  wx.align_center_vertical)         grid1.add(wx.combobox(self, -1, size=(120, -1)))         grid1.add(wx.statictext(self, -1, 'replace with: ', (5, 5)), 0, wx.align_center_vertical)         grid1.add(wx.combobox(self, -1, size=(120, -1)))           hbox2 = wx.boxsizer(wx.horizontal)         sizer21 = wx.staticboxsizer(wx.staticbox(self, -1, 'direction'), orient=wx.vertical)         sizer21.add(wx.radiobutton(self, -1, 'forward', style=wx.rb_group))         sizer21.add(wx.radiobutton(self, -1, 'backward'))         hbox2.add(sizer21, 1, wx.right, 5)          sizer22 = wx.staticboxsizer(wx.staticbox(self, -1, 'scope'), orient=wx.vertical)         # must define wx.rb_group style, otherwise 4 radiobuttons mutually exclusive         sizer22.add(wx.radiobutton(self, -1, 'all', style=wx.rb_group))         sizer22.add(wx.radiobutton(self, -1, 'selected lines'))         hbox2.add(sizer22, 1)           sizer3 = wx.staticboxsizer(wx.staticbox(self, -1, 'options'), orient=wx.vertical)         vbox3 = wx.boxsizer(wx.vertical)         grid = wx.gridsizer(3, 2, 0, 5)         grid.add(wx.checkbox(self, -1, 'case sensitive'))         grid.add(wx.checkbox(self, -1, 'wrap search'))         grid.add(wx.checkbox(self, -1, 'whole word'))         grid.add(wx.checkbox(self, -1, 'incremental'))         vbox3.add(grid)         vbox3.add(wx.checkbox(self, -1, 'regular expressions'))         sizer3.add(vbox3, 0, wx.top, 4)           sizer4 = wx.gridsizer(2, 2, 2, 2)         sizer4.add(wx.button(self, -1, 'find', size=(120, -1)))         sizer4.add(wx.button(self, -1, 'replace/find', size=(120, -1)))         sizer4.add(wx.button(self, -1, 'replace', size=(120, -1)))         sizer4.add(wx.button(self, -1, 'replace all', size=(120, -1)))          sizer5 = wx.boxsizer(wx.horizontal)         sizer5.add((191, -1), 1, wx.expand | wx.align_right)         sizer5.add(wx.button(self, -1, 'close', size=(50, -1)))           vbox.add(grid1, 0, wx.bottom | wx.top, 9)                 vbox.add(hbox2, 0, wx.bottom, 9)                 vbox.add(sizer3, 0, wx.bottom, 15)                 vbox.add(sizer4, 0, wx.bottom, 9)                 vbox.add(sizer5, 1, wx.bottom, 9)         vbox_top.add(vbox, 1, wx.left, 5)          self.setsizer(vbox_top)         self.centre()   app = wx.app(false) d = findreplace(none, -1, 'find/replace') d.showmodal() d.destroy() app.mainloop() 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -