BoxSizer issue: Not expanding to fit contents of StaticText - python

I'm creating a StaticText element with multiple child StaticText elements that aren't quite sizing correctly. I'm sure it's a BoxSizer issue, but maybe not? Here's a screenshot of what's happening: http://cloud.smallparade.com/CMxC
That should read:
Wilco
One Sunday Morning (Song
For Jane Smiley's Boyfriend)
The Whole Love (Deluxe Edition)
As you can likely deduce, the second and third lines (Album) are one StaticText element that's wrapping but not expanding to fit its contents.
Here is the code that creates this element:
def PlayLabel(self, artist, track, album):
header_font = wx.Font(26, wx.SWISS, wx.NORMAL, wx.BOLD, False, "Helvetica")
album_font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD, False, "Helvetica")
# label container
block = wx.StaticText(self.Sidebar, -1, '')
block.sizer = wx.BoxSizer(wx.VERTICAL)
block.SetBackgroundColour('WHITE')
label_artist = wx.StaticText(block, -1, artist)
label_artist.SetForegroundColour('BLACK')
label_artist.SetFont(header_font)
label_track = wx.StaticText(block, -1, track)
label_track.SetForegroundColour('BLACK')
label_track.SetFont(header_font)
label_album = wx.StaticText(block, -1, album)
label_album.SetForegroundColour('BLACK')
label_album.SetFont(album_font)
block.sizer.AddMany([
(label_artist, 1, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5),
(label_track, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5),
(label_album, 1, wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, 5)
])
block.SetSizerAndFit(block.sizer)
self.Sidebar.sizer.Add(block, 0, wx.EXPAND|wx.ALIGN_LEFT|wx.BOTTOM, 5)
self.Sidebar.sizer.Layout()
self.Layout()
return block
Any idea what's going on?
EDIT:
Complete code: http://pastie.org/2976327

I've never seen anyone create a sizer like that. Normally you do this:
mySizer = wx.BoxSizer(wx.VERTICAL)
Then you add each element. I suspect that since you're doing it in a weird way, you're getting weird results. Don't use the StaticText's sizer method for this. They are not container objects. Instead, do this:
block = wx.BoxSizer(wx.VERTICAL)
And then add the other widgets as you did before. And telling the sizer to set itself won't work right either: "block.SetSizerAndFit(block.sizer)". You need to call the parent widget's SetSizer() method, which is probably the Sidebar here:
self.Sidebar.SetSizer(block)
or maybe you can just add it the way you had it here:
self.Sidebar.sizer.Add(block, 0, wx.EXPAND|wx.ALIGN_LEFT|wx.BOTTOM, 5)
EDIT
Here's a simple code example:
import wx
########################################################################
class MyFrame(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, None, title="Test")
self.panel = wx.Panel(self)
self.mainSizer = wx.BoxSizer(wx.VERTICAL)
samples = [("Red", "Breathe Into Me", "End of Silence"),
("eleventyseven", "Lonely", "Sugarfist"),
("Lecrae", "Go Hard", "Rebel")]
for sample in samples:
artist, track, album = sample
self.PlayLabel(artist, track, album)
self.panel.SetSizer(self.mainSizer)
panelSizer = wx.BoxSizer()
panelSizer.Add(self.panel, 1, wx.EXPAND)
self.SetSizer(panelSizer)
self.Fit()
def PlayLabel(self, artist, track, album):
header_font = wx.Font(26, wx.SWISS, wx.NORMAL, wx.BOLD, False, "Helvetica")
album_font = wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD, False, "Helvetica")
block = self.panel
# sizer
sizer = self.mainSizer
# artist
label_artist = wx.StaticText(block, -1, artist)
label_artist.SetForegroundColour('BLACK')
label_artist.SetFont(header_font)
# track
label_track = wx.StaticText(block, -1, track)
label_track.SetForegroundColour('BLACK')
label_track.SetFont(header_font)
# album
label_album = wx.StaticText(block, -1, album)
label_album.SetForegroundColour('BLACK')
label_album.SetFont(album_font)
sizer.AddMany([
(label_artist, 1, wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, 5),
(label_track, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5),
(label_album, 1, wx.EXPAND|wx.LEFT|wx.RIGHT, 5)
])
if __name__ == "__main__":
app = wx.App(False)
frame = MyFrame()
frame.Show()
app.MainLoop()
I personally don't like Fit() much, but in this case, it works for me.

Related

wxPython -- BoxSizers not placing things correctly

I can't figure out what I'm doing wrong. I just made the jump from Tkinter to wxPython and I'm trying to figure out BoxSizers. I'd look this question up, but I don't even know what to look up. This panel is filling the space of a Frame, it's supposed to show a line of text with a progressbar underneath it and that's all supposed to take up the bottom 1/5 of the panel or so, centered horizontally (eventually I'm going to add a background image behind it). But what happens is I only see the text and only about 40% down from the top, aligned to the left edge of the window. Here's the code:
class KhPanel(wx.Panel):
def __init__(self, parent, configSet, selectWindow):
wx.Panel.__init__(self, parent=parent)
self.frame = parent
self.configSet = configSet
whichWindow = getattr(self, selectWindow)
whichWindow()
def configWindow(self):
gaugeWidth = (1/5)*self.configSet["width"]
gaugeHeight = (1/10)*self.configSet["height"]
gaugeMax = 100
topBuffer = (8/10)*self.configSet["height"]
itemSep = (1/16)*self.configSet["height"]
vSizer = wx.BoxSizer(wx.VERTICAL)
textSizer = wx.BoxSizer(wx.HORIZONTAL)
progressSizer = wx.BoxSizer(wx.HORIZONTAL)
configText = wx.StaticText(self, label="STUFF", style=wx.ALIGN_CENTER)
configProgressBar = wx.Gauge(self, range=gaugeMax, size=(gaugeWidth, gaugeHeight))
textSizer.Add(configText, 1, wx.ALIGN_CENTER, 0)
progressSizer.Add(configProgressBar, 1, wx.ALIGN_CENTER, 1)
vSizer.Add(textSizer, 1, wx.TOP, topBuffer)
vSizer.Add(progressSizer, 1, wx.TOP, itemSep)
self.SetSizer(vSizer)
vSizer.Fit(self)
return
If you need the info, configSet.width and height are the width and height of the parent window (currently 340 x 270). And selectWindow, in this case, is "configWindow"
Running this code, the gaugeWidth and gaugeHeight are both getting set to zero, which is why the progressbar is not showing. This is due to the fact that you are doing integer math here, so 1 divided by 5 is 0. Same with 1/10. Just change those lines to:
gaugeWidth = (1/5.0)*self.configSet["width"]
gaugeHeight = (1/10.0)*self.configSet["height"]
Then the gauge will appear. Here's some fully runnable code, slightly modified from your unrunnable original:
import wx
class KhPanel(wx.Panel):
def __init__(self, parent, configSet):
wx.Panel.__init__(self, parent=parent)
self.frame = parent
self.configSet = configSet
self.configWindow()
def configWindow(self):
gaugeWidth = (1/5.0)*self.configSet["width"]
gaugeHeight = (1/10.0)*self.configSet["height"]
gaugeMax = 100
topBuffer = (8/10)*self.configSet["height"]
itemSep = (1/16)*self.configSet["height"]
vSizer = wx.BoxSizer(wx.VERTICAL)
textSizer = wx.BoxSizer(wx.HORIZONTAL)
progressSizer = wx.BoxSizer(wx.HORIZONTAL)
configText = wx.StaticText(self, label="STUFF", style=wx.ALIGN_CENTER)
configProgressBar = wx.Gauge(self, range=gaugeMax, size=(gaugeWidth, gaugeHeight))
textSizer.Add(configText, 1, wx.ALIGN_CENTER, 0)
progressSizer.Add(configProgressBar, 1, wx.ALIGN_CENTER, 1)
vSizer.Add(textSizer, 1, wx.TOP, topBuffer)
vSizer.Add(progressSizer, 1, wx.TOP, itemSep)
self.SetSizer(vSizer)
vSizer.Fit(self)
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title="Test")
config = {'width':340, 'height':270}
panel = KhPanel(self, config)
self.Show()
if __name__ == "__main__":
app = wx.App()
frame = MyFrame()
app.MainLoop()
Incorporating Mike Driscoll's correction above, I changed the way I spaced it and it works out to be less work. I took out the horizontal sizers as I discovered they weren't needed unless I was going to space two things on the same row and I added stretch spacers instead of enormous borders. Here's the new code and it looks exactly how I wanted it:
def configWindow(self):
gaugeWidth = (4/5.0)*self.configSet["width"]
gaugeHeight = (1/10.0)*self.configSet["height"]
gaugeMax = 100
vSizer = wx.BoxSizer(wx.VERTICAL)
configText = wx.StaticText(self, label="STUFF")
configProgressBar = wx.Gauge(self, range=gaugeMax, size=(gaugeWidth, gaugeHeight))
vSizer.AddStretchSpacer(7)
vSizer.Add(configText, 1, wx.ALIGN_CENTER, 0)
vSizer.Add(configProgressBar, 1, wx.ALIGN_CENTER, 0)
vSizer.AddStretchSpacer(1)
self.SetSizer(vSizer)
return

Avoiding empty spaces on the sides of the panels in wxPython

I am working with wxPython v3.0 and python v2.7 on Windows 8 OS.
The code is provided below.
Problem: If you scroll the vertical scroll bar completely to the bottom and scroll the horizontal scroll bar completely to the right side, then you shall notice empty spaces at the bottom of the panels and at the right side of the panels as shown in the image below. How to avoid this? Is this the default behavior or am I doing something wrong? It would be great if someone can test this on his/her system and confirm if this is a normal behavior?
Code:
import wx
import wx.lib.scrolledpanel
class GUI(wx.Frame):
def __init__(self, parent, id, title):
screenWidth = 700
screenHeight = 400
screenSize = (screenWidth, screenHeight)
wx.Frame.__init__(self, None, id, title, size=screenSize)
myFont = wx.Font(15, wx.MODERN, wx.NORMAL, wx.BOLD)
mainSizer = wx.BoxSizer(wx.VERTICAL)
panelsSizer = wx.BoxSizer(wx.HORIZONTAL)
sizer1 = wx.BoxSizer(wx.VERTICAL)
sizer2 = wx.BoxSizer(wx.VERTICAL)
mainPanel = wx.lib.scrolledpanel.ScrolledPanel(self, -1,style=wx.SIMPLE_BORDER)
mainPanel.SetupScrolling()
panel1 = wx.lib.scrolledpanel.ScrolledPanel(mainPanel, -1, style=wx.SIMPLE_BORDER)
panel1.SetupScrolling(scroll_y=False)
panel2 = wx.lib.scrolledpanel.ScrolledPanel(mainPanel, -1, style=wx.SIMPLE_BORDER)
panel1.SetBackgroundColour('#cccFFF')
panel2.SetBackgroundColour('#FFFaaa')
panelsSizer.Add(panel1, 1, wx.ALL|wx.EXPAND)
panelsSizer.Add(panel2, 2, wx.ALL|wx.EXPAND)
mainPanel.SetSizer(panelsSizer)
k = 0
#Populating the panel-1 with panels to show scroll bars
for i in range(1,20):
lPanels = 'lPanel'+str(k)
lPanels = wx.Panel(panel1)
label0 = str(k+1)+ '. '+'Panel-1 #############################'
text0 = wx.StaticText(lPanels, -1, label0)
text0.SetFont(myFont)
sizer1.Add(lPanels, 0, wx.ALL|wx.EXPAND, 5)
sizer1.Add(wx.StaticLine(panel1), 0, wx.ALL|wx.EXPAND, 0)
k += 1
k = 0
#Populating the panel-2 with panels to show the scroll bars
for i in range(1,20):
sPanel ='sPanel' +str(k)
sPanel = wx.Panel(panel2)
label = str(k)+ '. Panel-2#############################'
text = wx.StaticText(sPanel, -1, label)
text.SetFont(myFont)
sizer2.Add(sPanel, 0, wx.ALL|wx.EXPAND, 5)
sizer2.Add(wx.StaticLine(panel2), 0, wx.ALL|wx.EXPAND, 0)
k += 1
panel1.SetSizer(sizer1)
panel2.SetSizer(sizer2)
mainSizer.Add(mainPanel, 15, wx.EXPAND|wx.ALL)
self.SetSizer(mainSizer)
if __name__=='__main__':
app = wx.App()
frame = GUI(parent=None, id=-1, title="Test")
frame.Show()
app.MainLoop()
Thank you for your time!
It is normal. wx.ScrolledWindow rounds the virtual size up to the next multiple of the scroll rate, so you end up with between 0 and scroll rate extra pixels.

WxPython dynamically added sizers mis-behaving

I'm trying to set-up a display to show the gamertag and avatar of users added to a text file, it most of the way there but I can't get them to position properly.
A quick mock-up of what I want: here.
Here is what I currently have on start: here
EDIT: I've switched from using a BoxSizer to using a GridSizer and that seems to have fixed the position issue, they no longer overlap, the shifting problem is still present however.
The sizer containing the users shouldn't be overlapping with the input sizer at the top, I don't know what is causing this.
And what happens when it updates to check for new users: here
Might not be that easy to see but in the second image the lowest user is shifted down, it gets further and further down as the program runs, each time it is moved down by it's own height.
The relevant code areas:
Creating the starting sizers
self.main_sizer = wx.BoxSizer(wx.VERTICAL)
self.widget_sizer = wx.BoxSizer(wx.VERTICAL)
#Holds input for gamertags and addition
self.input_sizer = wx.BoxSizer(wx.HORIZONTAL)
#Content to be added immediately.
self.gamer_tag_textbox = wx.TextCtrl(self, -1)
self.gamer_tag_textbox.SetFocus()
self.add_gamer_tag = wx.Button(self, -1, 'Add Friend')
#Contains the displayed content
self.user_sizer = wx.BoxSizer(wx.VERTICAL)
#Add objects to sizers
self.input_sizer.Add(self.gamer_tag_textbox, 0)
self.input_sizer.Add(self.add_gamer_tag, 0)
#Set up the sizers
self.widget_sizer.Add(self.input_sizer, 0)
self.widget_sizer.Add(self.user_sizer, 0)
self.main_sizer.Add(self.widget_sizer, 0)
self.SetSizer(self.main_sizer)
Adding sizers created for each user to the main user_sizer.
def display_user_content(self, details):
self.user_sizer.Clear(True)
#This is different to the original code, it originally used boxsizers in the for each loop.
self.single_user_sizer = wx.GridSizer(cols=2)
for each in details:
#Create sizer to contain user information
#Get username
username = each[0]
#Get location of image file
location = each[-1]
#Create static text to contain username
stat = wx.StaticText(self, -1, 'username')
#Load image from location and convert to bitmap.
png = wx.Image(location, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
#Create bitmap
avatar = wx.StaticBitmap(self, -1, png)
#Add to sizer
self.single_user_sizer.Add(avatar, 1)
self.single_user_sizer.Add(stat, 1)
#Add each users sizer to main user sizer
self.user_sizer.Add(self.single_user_sizer, 1)
#Add main user sizer to widget sizer
self.widget_sizer.Add(self.user_sizer, 0)
self.frame.Fit()
Full code (minus classes): here
Maybe this is similar to what you would like to achieve?
import wx
NUMBER = 3
class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.panel = wx.Panel(self)
self.windowSizer = wx.BoxSizer()
self.windowSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND)
self.sizer = wx.GridBagSizer(vgap=5, hgap=5)
self.text = wx.TextCtrl(self.panel, size=(0, 0))
self.button = wx.Button(self.panel)
self.sizer.Add(self.text, (0, 0), flag=wx.EXPAND)
self.sizer.Add(self.button, (0, 1))
self.icons = []
self.stats = []
for i in range(NUMBER):
icon = wx.Panel(self.panel, size=(50, 50))
icon.SetBackgroundColour(wx.RED)
stat = wx.Panel(self.panel, size=(200, -1))
stat.SetBackgroundColour(wx.BLUE)
self.sizer.Add(icon, (i+1, 0))
self.sizer.Add(stat, (i+1, 1), flag=wx.EXPAND)
self.icons.append(icon)
self.stats.append(stat)
self.sizer.AddGrowableCol(1)
self.border = wx.BoxSizer()
self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)
self.panel.SetSizerAndFit(self.border)
self.SetSizerAndFit(self.windowSizer)
self.Show()
app = wx.App(False)
win1 = MainWindow(None)
app.MainLoop()
Or maybe more like this?
import wx
NUMBER = 3
class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.panel = wx.Panel(self)
self.windowSizer = wx.BoxSizer()
self.windowSizer.Add(self.panel, 1, wx.ALL | wx.EXPAND)
self.sizer = wx.GridBagSizer(vgap=5, hgap=5)
self.toolbar_sizer = wx.BoxSizer()
self.text = wx.TextCtrl(self.panel)
self.button = wx.Button(self.panel)
self.toolbar_sizer.Add(self.text, 0, flag=wx.CENTER)
self.toolbar_sizer.Add(self.button, 0)
self.sizer.Add(self.toolbar_sizer, (0, 0), span=(1, 2), flag=wx.EXPAND)
self.icons = []
self.stats = []
for i in range(NUMBER):
icon = wx.Panel(self.panel, size=(50, 50))
icon.SetBackgroundColour(wx.RED)
stat = wx.Panel(self.panel, size=(200, -1))
stat.SetBackgroundColour(wx.BLUE)
self.sizer.Add(icon, (i+1, 0))
self.sizer.Add(stat, (i+1, 1), flag=wx.EXPAND)
self.icons.append(icon)
self.stats.append(stat)
self.sizer.AddGrowableCol(1)
self.border = wx.BoxSizer()
self.border.Add(self.sizer, 1, wx.ALL | wx.EXPAND, 5)
self.panel.SetSizerAndFit(self.border)
self.SetSizerAndFit(self.windowSizer)
self.Show()
app = wx.App(False)
win = MainWindow(None)
app.MainLoop()
At the end of the display_user_content function I was adding the user_sizer to the widget_sizer each time, this was unnecessary and was causing a doubling of the number of results, I have removed that line and my code now works.
The fixed code:
def display_user_content(self, details):
self.user_sizer.Clear(True)
self.single_user_sizer = wx.GridSizer(cols=2, hgap=5, vgap=5)
for each in details:
#Get username
self.username_sizer = wx.BoxSizer(wx.HORIZONTAL)
username = each[0]
#Get location of image file
location = each[-1]
#Create static text to contain username
stat = wx.StaticText(self, -1, 'username')
#Load image from location and convert to bitmap.
png = wx.Image(location, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
#Create bitmap
avatar = wx.StaticBitmap(self, -1, png)
#Add to sizer
self.single_user_sizer.Add(avatar, 0)
self.username_sizer.Add(stat, 0)
self.single_user_sizer.Add(self.username_sizer, 0)
#Add each users sizer to main user sizer
self.user_sizer.Add(self.single_user_sizer, 0)
#Add main user sizer to widget sizer
#self.widget_sizer.Add(self.user_sizer, 0)
self.Fit()

growable wxpython listctrl columns

I'm trying to create a table, using a wxlistctrl, where the columns will grow along with it's parent. I want it to function like a gridbagsizer with growable columns. I also don't want the user to be able to adjust the width by clicking and dragging the vertical rules. Is this possible with the listctrl or am i going to have to make my own control?
Here is an example of what I have now
import wx
class MyForm(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "List Control Tutorial")
panel = wx.Panel(self, wx.ID_ANY)
self.index = 0
self.list_ctrl = wx.ListCtrl(panel, size=(-1,100),
style=wx.LC_REPORT
|wx.BORDER_SUNKEN
)
self.list_ctrl.InsertColumn(0, 'Subject')
self.list_ctrl.InsertColumn(1, 'Due')
self.list_ctrl.InsertColumn(2, 'Location', width=125)
btn = wx.Button(panel, label="Add Line")
btn.Bind(wx.EVT_BUTTON, self.add_line)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.list_ctrl, 0, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
def add_line(self, event):
line = "Line %s" % self.index
self.list_ctrl.InsertStringItem(self.index, line)
self.list_ctrl.SetStringItem(self.index, 1, "01/19/2010")
self.list_ctrl.SetStringItem(self.index, 2, "USA")
self.index += 1
if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
frame.Show()
app.MainLoop()
See the ListCtrlAutoWidthMixin class in the wx.lib.mixins.listctrl module.
I'm not sure if this is what you want, but you can try this;
sizer.Add(self.list_ctrl, 1, wx.ALL | wx.GROW, 5)
Sadly you can't disable column-width resizing. At least not in the default library; http://wxpython.org/Phoenix/docs/html/ListCtrl.html.
I also don't want the user to be able to adjust the width by clicking and dragging the vertical rules.
This at least is possible:
self.list_ctrl.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.OnColumnResizeStart)
# ...
def OnColumnResizeStart(self, event):
# Veto if on auto mode:
if self.autoColWidths: event.Veto()
else: event.Skip()

wxPython - Redrawing Error when replacing wxFrame's Panel

I'm creating a small wxPython utility for the first time, and I'm stuck on a problem.
I would like to add components to an already created frame. To do this, I am destroying the frame's old panel, and creating a new panel with all new components.
1: Is there a better way of dynamically adding content to a panel?
2: Why, in the following example, do I get a a strange redraw error in which in the panel is drawn only in the top left hand corner, and when resized, the panel is drawn correctly?
(WinXP, Python 2.5, latest wxPython)
Thank you for the help!
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, 'TimeTablr')
#Variables
self.iCalFiles = ['Empty', 'Empty', 'Empty']
self.panel = wx.Panel(self, -1)
self.layoutElements()
def layoutElements(self):
self.panel.Destroy()
self.panel = wx.Panel(self, -1)
#Buttons
self.getFilesButton = wx.Button(self.panel, 1, 'Get Files')
self.calculateButton = wx.Button(self.panel, 2, 'Calculate')
self.quitButton = wx.Button(self.panel, 3, 'Quit Application')
#Binds
self.Bind(wx.EVT_BUTTON, self.Quit, id=3)
self.Bind(wx.EVT_BUTTON, self.getFiles, id=1)
#Layout Managers
vbox = wx.BoxSizer(wx.VERTICAL)
#Panel Contents
self.ctrlsToDescribe = []
self.fileNames = []
for iCalFile in self.iCalFiles:
self.ctrlsToDescribe.append(wx.TextCtrl(self.panel, -1))
self.fileNames.append(wx.StaticText(self.panel, -1, iCalFile))
#Add Components to Layout Managers
for i in range(0, len(self.ctrlsToDescribe)):
hboxtemp = wx.BoxSizer(wx.HORIZONTAL)
hboxtemp.AddStretchSpacer()
hboxtemp.Add(self.fileNames[i], 1, wx.EXPAND)
hboxtemp.AddStretchSpacer()
hboxtemp.Add(self.ctrlsToDescribe[i], 2, wx.EXPAND)
hboxtemp.AddStretchSpacer()
vbox.Add(hboxtemp)
finalHBox = wx.BoxSizer(wx.HORIZONTAL)
finalHBox.Add(self.getFilesButton)
finalHBox.Add(self.calculateButton)
finalHBox.Add(self.quitButton)
vbox.Add(finalHBox)
self.panel.SetSizer(vbox)
self.Show()
def Quit(self, event):
self.Destroy()
def getFiles(self, event):
self.iCalFiles = ['Example1','Example1','Example1','Example1','Example1','Example1']
self.layoutElements()
self.Update()
app = wx.App()
MainFrame()
app.MainLoop()
del app
1) I beleive the Sizer will let you insert elements into the existing ordering of them. That would probably be a bit faster.
2) I don't see the behavior you're describing on OSX, but at a guess, try calling self.Layout() before self.Show() in layoutElements?
I had a similar problem where the panel would be squished into the upper-right corner. I solved it by calling panel.Fit().
In your example, you should call self.panel.Fit() after self.panel.SetSizer(vbox)

Categories