def make_footer(self): self.time = {} self.time['hour'] = ListBox() self.time['hour'].setVisibleItemCount(1) for hour in range(24): self.time['hour'].addItem('%02d' % hour) self.time['hour'].setSelectedIndex(12) self.time['minute'] = ListBox() self.time['minute'].setVisibleItemCount(1) for minute in range(0, 60, 5): self.time['minute'].addItem('%02d' % minute) self.time['minute'].setSelectedIndex(0) time_panel = HorizontalPanel() time_panel.setVerticalAlignment('center') time_panel.add(self.time['hour']) time_panel.add(Label(':')) time_panel.add(self.time['minute']) self.table.setWidget(1, 0, time_panel) weekdays_panel = HorizontalPanel() weekdays_panel.setSpacing(5) self.weekdays = {} for i in range(7): self.weekdays[i] = CheckBox(AlarmWidget.weekday_name[i]) self.weekdays[i].setChecked(i < 6) weekdays_panel.add(self.weekdays[i]) self.table.setWidget(1, 1, weekdays_panel) self.duration = ListBox() self.duration.setVisibleItemCount(1) choices = [ 1, 2, 3, 4, 5, 7, 10, 15, 20, 25, 30, 40, 50, 60 ] for seconds in choices: self.duration.addItem( '%ds' % seconds if seconds < 60 else '%dm' % (seconds / 60), seconds) self.duration.setSelectedIndex(2) self.table.setWidget(1, 2, self.duration) image = Image('icons/plus.png') image.setTitle('add'); image.addClickListener(self.plus_clicked) self.table.setWidget(1, 3, image) for col in range(4): self.table.getCellFormatter().setStyleName(1, col, 'tablecell noborder')
def add(self, time, weekdays=range(5), duration=3): row = self.table.getRowCount()-1 self.table.insertRow(row) self.table.setText(row, 0, time) weekdays_str = [] for weekday in weekdays: weekdays_str.append(AlarmWidget.weekday_name[weekday]) self.table.setText(row, 1, ', '.join(weekdays_str)) self.table.setText(row, 2, str(duration) + 's') image = Image('icons/x.png') image.setTitle('delete'); image.addClickListener(lambda x: self.x_clicked(row-1)) self.table.setWidget(row, 3, image) for col in range(3): self.table.getCellFormatter().setStyleName(row, col, 'tablecell') self.table.getCellFormatter().setStyleName(row, 3, 'tablecell noborder')