Hello list !
I have been coding in python for the past 3 months, i have had some experience with Tkinter, and i decided to switch to wxPython because my project needed a more powerfull GUI toolkit.
I am stuck with a big problem concerning the sizers, which are fairly different from the layout managing in Tkinter. I am able to organize widgets in a simple frame, but i cannot get my example to work.
All i want is to be able to organize widgets on each of my notebook tabs (each tab being a class, herited from a wx.Panel). Here i show only one tab, which i made simple, with a static text, a text field and two panels, which should be organized this way:
···
################
#statTxt txtField #
#lPanel rPanel #
################
I am trying to use BoxSizer, i know a could use the GridSizer, but i still think i should be able to do what i want with this one.
Anyway, here is my code, i would happily read any suggestions.
Cheers,
#############
import wx
class mainWindow(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self,parent,wx.ID_ANY, title=‘Application!’, size=(800,600), pos=(200,100), style=wx.DEFAULT_FRAME_STYLE)
self.Maximize()
panel=wx.Panel(self, wx.ID_ANY)
notebook=wx.Notebook(panel)
#calling the classes defined here, to create the pages
self.analyse=analyse(notebook)
#adding them to the notebook
notebook.AddPage(self.analyse, "Analyse", select=True)
sizer=wx.BoxSizer()
sizer.Add(notebook, 1, wx.EXPAND)
panel.SetSizer(sizer)
self.Show(True)
class analyse(wx.Panel):
def init(self, parent):
wx.Panel.init(self, parent)
#mainbox that contains all
self.mainBox=wx.BoxSizer(wx.VERTICAL | wx.EXPAND)
self.topBox=wx.BoxSizer(wx.HORIZONTAL | wx.EXPAND)
self.bottomBox=wx.BoxSizer(wx.HORIZONTAL | wx.EXPAND)
###
# Create the top box
###
selLigTxt = wx.StaticText(self, wx.ID_ANY, 'Select')
selLigFld = wx.TextCtrl(self, wx.ID_ANY)
self.topBox.Add(selLigTxt, 0, wx.ID_ANY | wx.ALL, 5)
self.topBox.Add(selLigFld, 1, wx.ID_ANY | wx.ALL, 5)
###
# Create the bottom box
###
rightPanel=wx.Panel(self, wx.ID_ANY, style=wx.SUNKEN_BORDER)
leftPanel=wx.Panel(self, wx.ID_ANY, style=wx.SUNKEN_BORDER)
self.bottomBox.Add(leftPanel, 0, wx.ID_ANY | wx.EXPAND, 5)
self.bottomBox.Add(rightPanel, 0, wx.ID_ANY | wx.EXPAND, 5)
#Add boxes to the mainBox
self.mainBox.Add(self.topBox, 0, wx.ALL, 5)
self.mainBox.Add(self.bottomBox, 0, wx.ALL, 5)
#initialize mainSizer
self.SetSizer(self.mainBox)
app=wx.PySimpleApp()
frame=mainWindow(None,-1,“GUI”)
app.MainLoop()
#################