Never done this mailing list thing before,
hope this is the right way to do it…
I am having trouble getting started
with wxPython, I have been reading tutorials and playing with demos and
still find myself unable to do basic things.
I found I was able to take one demo
and change the widgets on it to start approximating a calculator interface,
however as soon as I tried to add code (not even my own, the buttons were
from a different tutorial), it started placing all my elements in the upper
right corner (stacked). I was hoping someone could enlighten me as to what
I am doing wrong with these sizers.
The code is:
import wx
class MyForm(wx.Frame):
def init(self):
wx.Frame.__init__(self,
None, wx.ID_ANY, ‘My Form’)
# Add a panel so
it looks the correct on all platforms
self.panel = wx.Panel(self,
wx.ID_ANY)
font = wx.Font(12,
wx.SWISS, wx.NORMAL, wx.BOLD)
display = wx.TextCtrl(self.panel,
wx.ID_ANY, ‘0’, style=wx.TE_READONLY | wx.TE_RIGHT)
display.SetFont(font)
# Create the sizers
topSizer
= wx.BoxSizer(wx.VERTICAL)
ButtonSizer
= wx.GridSizer(4,4,3,3)
# This is the code
that I added; it is from a different demo
ButtonSizer.AddMany(
[ (wx.Button(self, -1, ‘Cls’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘Bck’), 0, wx.EXPAND),
(wx.StaticText(self, -1, ‘’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘Close’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘7’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘8’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘9’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘/’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘4’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘5’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘6’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘*’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘1’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘2’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘3’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘-’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘0’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘.’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘=’), 0, wx.EXPAND),
(wx.Button(self, -1, ‘+’), 0, wx.EXPAND) ])
# Add sub-sizers
to topSizer
topSizer.Add(display,
0, wx.EXPAND|wx.ALL)
topSizer.Add(ButtonSizer,
0, wx.ALL|wx.EXPAND, 5)
self.panel.SetSizer(topSizer)
# SetSizeHints(minW,
minH, maxW, maxH)
self.SetSizeHints(250,200,700,300)
topSizer.Fit(self)
Run the program
if name == ‘main’:
app = wx.PySimpleApp()
frame = MyForm().Show()
app.MainLoop()
It should put the display at the top
filling the sizer (worked before I added the other code) and the buttons
down below it (resizeable). I am working under windows, so I am trying
to put everything in a panel so it looks good.
Thank you all for your help.
-Brian