So far the move to wxPython has been going fairly smoothly. However, it's crucial that I be able to display items in the center of the screen (images, buttons, and radioboxes). I read about wx.ALIGN_CENTER_VERTICAL and wx.ALIGN_CENTER_HORIZONTAL, but the vertical option just doesn't seem to be working for me.
Below I've modified vegaseat's code for the radiobox. As it is, it doesn't align vertically but will align horizontally if I put that in instead.
Any help?
import wx
class MyFrame(wx.Frame):
def __init__(self, parent=None):
wx.Frame.__init__(self, parent, wx.ID_ANY, size=(500, 360))
# match to the number of radiobuttons
self.mychoices = ['image1', 'image2', 'image3', 'image4']
# create a box with 4 radio buttons, no labels here
label_choices = [' ', ' ', ' ', ' ']
self.radiobox = wx.RadioBox(self, wx.ID_ANY,
" click on a button ",
choices=label_choices, style=wx.VERTICAL)
# bind mouse click to an action
self.radiobox.Bind(wx.EVT_RADIOBOX, self.onAction)
# show present selection
self.onAction(None)
self.verticalDisplay = wx.BoxSizer(wx.VERTICAL)
self.verticalDisplay.Add(self.radiobox, 0, wx.ALIGN_CENTER_VERTICAL)
self.SetSizer(self.verticalDisplay)
def onAction(self, event):
"""show the selected choice"""
index = self.radiobox.GetSelection()
s = "Selected " + self.mychoices[index]
# show the result in the frame title
self.SetTitle(s)
app = wx.App(0)
MyFrame().Show()
app.MainLoop()