def __init__(self, prompt): wx.Dialog.__init__(self, None, style = wx.DEFAULT_DIALOG_STYLE & ~wx.CLOSE_BOX) panel = wx.Panel(self) fgs = wx.FlexGridSizer(cols = 2, vgap = 5, hgap = 5) self.inputs = [] for i in range(max_activities): fgs.Add(wrapped_text(panel, 'Activity {}'.format(i + 1)), border = 10, flag = wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL) self.inputs.append(wx.TextCtrl(panel, size = (300, -1))) fgs.Add(self.inputs[-1]) panel.SetSizer(fgs) pwrap = 500 prompt = long_wrapped_text(self, prompt, wrap = pwrap) self.inputs[0].SetFocus() box(self, wx.VERTICAL, (prompt, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 10), panel, wx.Size(0, 10), (okay(self), 0, wx.ALIGN_CENTER_HORIZONTAL)).Fit(self)
def __init__(self, prompt): wx.Dialog.__init__(self, None, style=wx.DEFAULT_DIALOG_STYLE & ~wx.CLOSE_BOX) panel = wx.Panel(self) fgs = wx.FlexGridSizer(cols=2, vgap=5, hgap=5) self.inputs = [] for i in range(max_activities): fgs.Add(wrapped_text(panel, 'Activity {}'.format(i + 1)), border=10, flag=wx.LEFT | wx.RIGHT | wx.ALIGN_CENTER_VERTICAL) self.inputs.append(wx.TextCtrl(panel, size=(300, -1))) fgs.Add(self.inputs[-1]) panel.SetSizer(fgs) pwrap = 500 prompt = long_wrapped_text(self, prompt, wrap=pwrap) self.inputs[0].SetFocus() box(self, wx.VERTICAL, (prompt, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.ALL, 10), panel, wx.Size(0, 10), (okay(self), 0, wx.ALIGN_CENTER_HORIZONTAL)).Fit(self)
def __init__(self, parent = None, title = '', activities = None, help_text = ''): wx.Dialog.__init__(self, parent, -1, title, wx.DefaultPosition, style = wx.DEFAULT_DIALOG_STYLE & ~wx.CLOSE_BOX) panel = wx.Panel(self) self.activities = [ dict(name = x, fields = map( lambda _: choice(panel, -1, choices = self.choices), range(checkin_range))) for x in activities] rowlabel_cols = 3 # Day of the week, day of the month, month extra_cols = 2 # Wakeup times and notes fgs = wx.FlexGridSizer( cols = rowlabel_cols + len(self.activities) + extra_cols, vgap = 5, hgap = 5) # Add horizontal spaces to make all the response # columns the same width. # for _ in range(rowlabel_cols): fgs.Add(wx.Size(0, 0)) # fgs.AddMany(len(self.activities) * [wx.Size(100, 0)]) # fgs.Add(wx.Size(0, 0)) # Add the column headers. for _ in range(rowlabel_cols): fgs.Add(wx.Size(0, 0)) for act in self.activities: fgs.Add(short_wrapped_text(panel, act['name'], exact = True), 0, wx.ALIGN_CENTER) fgs.Add(short_wrapped_text(panel, 'Wake-up time'), 0, wx.ALIGN_BOTTOM) fgs.Add(short_wrapped_text(panel, 'Notes'), 0, wx.ALIGN_BOTTOM) # Add the rows for each day. self.dates = [] self.notes = [] self.wakeups = [] for row in range(checkin_range): # Date column d = dateplus(date.today(), row + 1) self.dates.append(d) fgs.Add(wrapped_text(panel, d.strftime("%a")), flag = wx.LEFT, border = 5) fgs.Add(wrapped_text(panel, str(d.day)), flag = wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT, border = 7) fgs.Add(wrapped_text(panel, d.strftime("%b"))) # Activity columns for act in self.activities: fgs.Add(act['fields'][row], 0, wx.ALIGN_CENTER) # Wakeup-time column timepan = wx.Panel(panel) self.wakeups.append(dict( h = choice(timepan, choices = ['---'] + map(str, range(1, 13))), m = choice(timepan, choices = ['%02d' % n for n in range(60)]), ampm = choice(timepan, choices = ['AM', 'PM']))) fgs.Add(timepan) box(timepan, wx.HORIZONTAL, self.wakeups[-1]['h'], self.wakeups[-1]['m'], self.wakeups[-1]['ampm']) # Notes column self.notes.append(wx.TextCtrl(panel, size = (300, 25))) fgs.Add(self.notes[-1]) # Add some trailing vertical space. fgs.Add(wx.Size(0, 5)) panel.SetSizer(fgs) hbutton = wx.Button(self, wx.ID_HELP) self.help_text = help_text hbutton.Bind(wx.EVT_BUTTON, self.help) box(self, wx.VERTICAL, hbutton, panel, (okay(self), 0, wx.ALIGN_CENTER_HORIZONTAL)).Fit(self)
def __init__(self, parent=None, title='', activities=None, help_text=''): wx.Dialog.__init__(self, parent, -1, title, wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE & ~wx.CLOSE_BOX) panel = wx.Panel(self) self.activities = [ dict(name=x, fields=map(lambda _: choice(panel, -1, choices=self.choices), range(checkin_range))) for x in activities ] rowlabel_cols = 3 # Day of the week, day of the month, month extra_cols = 2 # Wakeup times and notes fgs = wx.FlexGridSizer(cols=rowlabel_cols + len(self.activities) + extra_cols, vgap=5, hgap=5) # Add horizontal spaces to make all the response # columns the same width. # for _ in range(rowlabel_cols): fgs.Add(wx.Size(0, 0)) # fgs.AddMany(len(self.activities) * [wx.Size(100, 0)]) # fgs.Add(wx.Size(0, 0)) # Add the column headers. for _ in range(rowlabel_cols): fgs.Add(wx.Size(0, 0)) for act in self.activities: fgs.Add(short_wrapped_text(panel, act['name'], exact=True), 0, wx.ALIGN_CENTER) fgs.Add(short_wrapped_text(panel, 'Wake-up time'), 0, wx.ALIGN_BOTTOM) fgs.Add(short_wrapped_text(panel, 'Notes'), 0, wx.ALIGN_BOTTOM) # Add the rows for each day. self.dates = [] self.notes = [] self.wakeups = [] for row in range(checkin_range): # Date column d = dateplus(date.today(), row + 1) self.dates.append(d) fgs.Add(wrapped_text(panel, d.strftime("%a")), flag=wx.LEFT, border=5) fgs.Add(wrapped_text(panel, str(d.day)), flag=wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT, border=7) fgs.Add(wrapped_text(panel, d.strftime("%b"))) # Activity columns for act in self.activities: fgs.Add(act['fields'][row], 0, wx.ALIGN_CENTER) # Wakeup-time column timepan = wx.Panel(panel) self.wakeups.append( dict(h=choice(timepan, choices=['---'] + map(str, range(1, 13))), m=choice(timepan, choices=['%02d' % n for n in range(60)]), ampm=choice(timepan, choices=['AM', 'PM']))) fgs.Add(timepan) box(timepan, wx.HORIZONTAL, self.wakeups[-1]['h'], self.wakeups[-1]['m'], self.wakeups[-1]['ampm']) # Notes column self.notes.append(wx.TextCtrl(panel, size=(300, 25))) fgs.Add(self.notes[-1]) # Add some trailing vertical space. fgs.Add(wx.Size(0, 5)) panel.SetSizer(fgs) hbutton = wx.Button(self, wx.ID_HELP) self.help_text = help_text hbutton.Bind(wx.EVT_BUTTON, self.help) box(self, wx.VERTICAL, hbutton, panel, (okay(self), 0, wx.ALIGN_CENTER_HORIZONTAL)).Fit(self)