Created
November 3, 2017 14:43
-
-
Save driscollis/3f729894ff0b757e66af90e5af907971 to your computer and use it in GitHub Desktop.
7x24 grid of radio boxes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import wx | |
| import wx.lib.scrolledpanel as scrolled | |
| class MainPanel(scrolled.ScrolledPanel): | |
| def __init__(self, parent): | |
| scrolled.ScrolledPanel.__init__(self, parent) | |
| main_sizer = wx.BoxSizer(wx.VERTICAL) | |
| choices = ['Yes', 'No'] | |
| days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] | |
| hour_sizer = wx.BoxSizer(wx.HORIZONTAL) | |
| hour_sizer.Add((50, -1)) | |
| for hour in range(1, 25): | |
| label = wx.StaticText(self, label='{}'.format(hour), size=(65, -1), | |
| style=wx.ALIGN_CENTRE_HORIZONTAL) | |
| hour_sizer.Add(label, 0, wx.RIGHT, 20) | |
| main_sizer.Add(hour_sizer) | |
| for row in range(7): | |
| row_sizer = wx.BoxSizer(wx.HORIZONTAL) | |
| row_sizer.Add(wx.StaticText(self, label=days[row]), 0, | |
| wx.ALL|wx.CENTER, 5) | |
| for col in range(24): | |
| name_of_radiobox = "row_{row}_col_{col}".format( | |
| row=row, col=col) | |
| radio_box = wx.RadioBox(self, choices=choices, | |
| majorDimension=1, | |
| style=wx.RA_SPECIFY_COLS, | |
| name=name_of_radiobox) | |
| row_sizer.Add(radio_box, 0, wx.ALL, 5) | |
| main_sizer.Add(row_sizer) | |
| self.SetSizer(main_sizer) | |
| self.SetupScrolling() | |
| class MainFrame(wx.Frame): | |
| def __init__(self): | |
| wx.Frame.__init__(self, None, title='Radioboxes', size=(800, 400)) | |
| panel = MainPanel(self) | |
| self.Show() | |
| if __name__ == '__main__': | |
| app = wx.App() | |
| frame = MainFrame() | |
| app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment