def foreground(self): """Activate the application.""" self.del_alarm_btn = widgets.Button(170, 204, 70, 35, 'DEL') self.hours_wid = widgets.Spinner(50, 30, 0, 23, 2) self.min_wid = widgets.Spinner(130, 30, 0, 59, 2) self.day_btns = (widgets.ToggleButton(10, 145, 40, 35, 'Mo'), widgets.ToggleButton(55, 145, 40, 35, 'Tu'), widgets.ToggleButton(100, 145, 40, 35, 'We'), widgets.ToggleButton(145, 145, 40, 35, 'Th'), widgets.ToggleButton(190, 145, 40, 35, 'Fr'), widgets.ToggleButton(10, 185, 40, 35, 'Sa'), widgets.ToggleButton(55, 185, 40, 35, 'Su')) self.alarm_checks = (widgets.Checkbox(200, 57), widgets.Checkbox(200, 102), widgets.Checkbox(200, 147), widgets.Checkbox(200, 192)) self._deactivate_pending_alarms() self._draw() wasp.system.request_event(wasp.EventMask.TOUCH | wasp.EventMask.SWIPE_LEFTRIGHT | wasp.EventMask.BUTTON) wasp.system.request_tick(1000)
def __init__(self): """Initialize the application.""" self.active = widgets.Checkbox(104, 200) self.hours = widgets.Spinner(50, 60, 0, 23, 2) self.minutes = widgets.Spinner(130, 60, 0, 59, 2) self.hours.value = 7 self.ringing = False
def __init__(self): """Initialize the application.""" self.active = widgets.Checkbox(104, 194) self.ringing = False self.hours = 0 self.minutes = 0 self._set_current_alarm()
def drawWidgets(self): # First create column headers pad = (1, 1) for j in range(self.noColumns): # widgetFrame = TK.Frame(self.tableFrame,width=self.columns[j]['width'], # height=DEFAULTCELLHEIGHT) # widgetFrame.pack_propagate(0) # Stops child widgets of label_frame from resizing it cell = widgets.Label(self.tableFrame) cell.configure(bg=self.columns[j]['bg'], fg=self.columns[j]['fg'], relief=TK.RAISED) #cell.config(width=self.columns[j]['width']) cell.grid(row=0, column=j, sticky='ew') #cell.pack(expand=TK.YES, fill=TK.BOTH) cell.setText(self.columns[j]['text']) cell.tableRow = -1 cell.tableColumn = j cell.bind("<Button-1>", self._click) pad = (1, 1) if j == 0: pad = (2, 1) if j == self.noColumns - 1: pad = (1, 2) #widgetFrame.grid(row=0, column=j, padx=pad, pady=(2,1)) # Second create cell widgets for i in range(self.visibleRows): widgetRow = [] for j in range(self.noColumns): widgetName = self.columns[j].get('widget', 'Label') # Default to label # widgetFrame = TK.Frame(self.tableFrame,width=self.columns[j]['width'], # height=DEFAULTCELLHEIGHT) #, # widgetFrame.pack_propagate(0) # Stops child widgets of label_frame from resizing it if widgetName == 'Textbox': cellWidget = widgets.Textbox(self.tableFrame) #cellWidget.config(width=columns[j]['width') cellWidget.bind('<Return>', self._dataChanged) cellWidget.bind('<Escape>', self._cancelChange) cellWidget.bind("<FocusOut>", self._dataChanged) #cellWidget.bind("<Leave>", self._click) # Must decide if this is sensible behaviour elif widgetName == 'Button': cellWidget = widgets.Button( self.tableFrame) #, command=self._dataChanged) cellWidget.bind('<ButtonRelease>', self._dataChanged) # cellWidget.config(command=self.dataChanged) elif widgetName == 'Checkbox': cellWidget = widgets.Checkbox(self.tableFrame) elif widgetName == 'Combobox': cellWidget = widgets.Combobox(self.tableFrame) cellWidget.bind("<<ComboboxSelected>>", self._dataChanged) else: cellWidget = widgets.Label(self.tableFrame) cellWidget.config(relief=TK.RAISED) cellWidget.config(width=self.columns[j]['width']) cellWidget.widgetType = widgetName #cellWidget.pack(expand=TK.YES, fill=TK.BOTH) align = self.columns[j].get('align', '') if align: cellWidget.configure(anchor=ANCHOR[align]) cellWidget.grid(row=i + 1, column=j, stick='ew') cellWidget.setText('') cellWidget.tableRow = i cellWidget.tableColumn = j cellWidget.dataCoords = [ ] # The row/column in the data matrix - set when table populated cellWidget.bind("<Button-1>", self._click) widgetRow.append(cellWidget) pad = (1, 1) ypad = (1, 1) if j == 0: pad = (2, 1) if j == self.noColumns - 1: pad = (1, 2) if i == self.visibleRows - 1: ypad = (1, 2) #widgetFrame.grid(row=i+1, column=j, padx=pad, pady=ypad) self.widgets.append(widgetRow) if self.data: if len(self.data) > self.visibleRows: self.scroll = True col = len(self.columns) x = len(self.data) - self.visibleRows self.addVerticalScroll(x) #self.vertical_scroll = TK.Scale(self.tableFrame, orient=TK.VERTICAL, from_=0, to=x, command=self.v_scroll, showvalue=0) #self.vertical_scroll.grid(row=1,column=col, rowspan=self.visibleRows, sticky=TK.N+TK.S) elif self.scroll: col = len(self.columns) x = 0 self.addVerticalScroll(x) #self.vertical_scroll = TK.Scale(self.tableFrame, orient=TK.VERTICAL, from_=0, to=x, command=self.v_scroll, showvalue=0) #self.vertical_scroll.grid(row=1,column=col, rowspan=self.visibleRows, sticky=TK.N+TK.S) # Get parent frame width and height - x and y coordinates can also be accessed self.tableFrame.update( ) # Required to get frame width and height at this time self.width = self.tableFrame.winfo_width() self.height = self.tableFrame.winfo_height()