def __init__(self): ui.Scene.__init__(self) label_height = ui.theme.current.label_height scrollbar_size = ui.SCROLLBAR_SIZE frame = ui.Rect(MARGIN, MARGIN, 200, label_height) self.name_textfield = ui.TextField(frame, placeholder='Your name') self.name_textfield.centerx = self.frame.centerx self.add_child(self.name_textfield) gridview = ui.GridView(ui.Rect(0, 0, 500, 500)) self.scroll_gridview = ui.ScrollView(ui.Rect( MARGIN, self.name_textfield.frame.bottom + MARGIN, 200 - scrollbar_size, 250), gridview) self.add_child(self.scroll_gridview) items = ['Apples', 'Bananas', 'Grapes', 'Cheese', 'Goats', 'Beer'] labels = [ui.Label(ui.Rect( 0, 0, LIST_WIDTH, label_height), item, halign=ui.LEFT) for item in items] list_view = ui.ListView(ui.Rect(0, 0, LIST_WIDTH, 400), labels) list_view.on_selected.connect(self.item_selected) list_view.on_deselected.connect(self.item_deselected) self.scroll_list = ui.ScrollView(ui.Rect( MARGIN, self.scroll_gridview.frame.bottom + MARGIN, LIST_WIDTH, 80), list_view) self.add_child(self.scroll_list) self.greet_button = ui.Button(ui.Rect( self.name_textfield.frame.right + SMALL_MARGIN, self.name_textfield.frame.top, 0, 0), 'Submit') self.greet_button.on_clicked.connect(self.greet) self.add_child(self.greet_button) self.image_view = ui.view_for_image_named('logo') self.image_view.frame.right = self.frame.right - MARGIN self.image_view.frame.top = MARGIN self.add_child(self.image_view) self.checkbox = ui.Checkbox(ui.Rect( self.scroll_gridview.frame.right + MARGIN, self.scroll_gridview.frame.top, 200, label_height), 'I eat food') self.add_child(self.checkbox) self.checkbox1 = ui.Checkbox(ui.Rect( self.checkbox.frame.left, self.checkbox.frame.bottom + SMALL_MARGIN, 200, label_height), 'I drink water') self.add_child(self.checkbox1) self.checkbox2 = ui.Checkbox(ui.Rect( self.checkbox.frame.left, self.checkbox1.frame.bottom + SMALL_MARGIN, 200, label_height), 'I exercise regularly') self.add_child(self.checkbox2) info_image = ui.get_image('info') self.info_button = ui.ImageButton(ui.Rect( self.checkbox2.frame.left, self.checkbox2.frame.bottom + MARGIN, 0, 0), info_image) self.info_button.on_clicked.connect(self.show_alert) self.add_child(self.info_button) notify_image = ui.get_image('star') self.notify_button = ui.ImageButton(ui.Rect( self.info_button.frame.right + MARGIN, self.info_button.frame.top, 0, 0), notify_image) self.notify_button.on_clicked.connect(self.show_notification) self.add_child(self.notify_button) self.task_button = ui.Button(ui.Rect( self.info_button.frame.left, self.info_button.frame.bottom + MARGIN, 0, 0), 'Consume!') self.task_button.on_clicked.connect(self.run_fake_task) self.add_child(self.task_button) self.running_task = False self.progress_view = ui.ProgressView(ui.Rect( self.frame.right - MARGIN - 180, self.task_button.frame.centery - scrollbar_size // 2, 180, scrollbar_size)) self.add_child(self.progress_view) self.progress_view.hidden = True labels2 = [ui.Label( ui.Rect(0, 0, LIST_WIDTH, label_height), 'Item %d' % (i + 1)) for i in range(10)] for l in labels2: l.halign = ui.LEFT self.select_view = ui.SelectView(ui.Rect( self.task_button.frame.left, self.task_button.frame.bottom + MARGIN, LIST_WIDTH, label_height), labels2) self.select_view.on_selection_changed.connect(self.selection_changed) self.add_child(self.select_view) self.hslider = ui.SliderView(ui.Rect( self.select_view.frame.left, self.select_view.frame.bottom + MARGIN*2, 100, scrollbar_size), ui.HORIZONTAL, 0, 100) self.hslider.on_value_changed.connect(self.value_changed) self.add_child(self.hslider) self.vslider = ui.SliderView(ui.Rect( self.hslider.frame.right + SMALL_MARGIN, self.hslider.frame.centery, scrollbar_size, 100), ui.VERTICAL, 0, 100) self.vslider.on_value_changed.connect(self.value_changed) self.add_child(self.vslider) self.slider_value = ui.Label(ui.Rect( self.hslider.frame.centerx - 25, self.hslider.frame.bottom + MARGIN, 50, label_height), '') self.add_child(self.slider_value) self.spinner = ui.SpinnerView(ui.Rect( self.frame.right - MARGIN - ui.SpinnerView.size, self.frame.bottom - MARGIN - ui.SpinnerView.size, 0, 0)) self.add_child(self.spinner)
def __init__(self): ui.Scene.__init__(self) self.sceneId = 1 # label1Size = 32 # label2Size = 16 # ui.theme.current.set('Label', 'normal', 'background_color', (100, 255, 255)) # useful for seeing labels better ui.theme.current.set('Label', 'normal', 'padding', (0, 0)) label_height = ui.theme.current.label_height # frame = ui.Rect(MARGIN, MARGIN, 100, label_height) labels2 = [ ui.Label(ui.Rect(0, 0, 100, label_height), 'Item %d' % (i + 1)) for i in range(10) ] for l in labels2: l.halign = ui.LEFT self.select_view = ui.SelectView( ui.Rect(SMALL_MARGIN, SMALL_MARGIN, 180, label_height), labels2) # self.select_view.on_selection_changed.connect(self.selection_changed) self.add_child(self.select_view) #CURRENT DRYBULB self.lblCurBigLabel = ui.Label(ui.Rect(0, label_height + 2 * SMALL_MARGIN, 320, 90), "100 " + DEGREE_SIGN + "F", halign=ui.label.RIGHT) self.add_child(self.lblCurBigLabel) # HIGH PREDICTION self.lblHighDbLbl = ui.Label(ui.Rect( SMALL_MARGIN, self.lblCurBigLabel.frame.bottom + SMALL_MARGIN, 40, label_height), "High: ", halign=ui.label.LEFT) self.add_child(self.lblHighDbLbl) self.lblHighDb = ui.Label(ui.Rect(40 + SMALL_MARGIN, self.lblHighDbLbl.frame.top, 50, label_height), "100 " + DEGREE_SIGN + "F", halign=ui.label.LEFT) self.add_child(self.lblHighDb) # LOW PREDICTION self.lblLowDbLbl = ui.Label(ui.Rect( SMALL_MARGIN, self.lblHighDbLbl.frame.bottom + SMALL_MARGIN, 40, label_height), "Low: ", halign=ui.label.LEFT) self.add_child(self.lblLowDbLbl) self.lblLowDb = ui.Label(ui.Rect(40 + SMALL_MARGIN, self.lblLowDbLbl.frame.top, 50, label_height), "100 " + DEGREE_SIGN + "F", halign=ui.label.LEFT) self.add_child(self.lblLowDb) # dispImg = ui.get_image('/home/pi/JDrive/Utility_Meter_Tracking/Server_Polling/wthrStat/resources/partlycloudy.gif') dispImg = pygame.image.load('resources/partlycloudy.png') self.wthrImg = ui.ImageView( ui.Rect(self.lblHighDb.frame.right + SMALL_MARGIN, self.lblCurBigLabel.frame.bottom + SMALL_MARGIN, 50, 50), dispImg) self.add_child(self.wthrImg) # self.name_textfield = ui.TextField(frame, placeholder='Your name') # self.name_textfield.centerx = self.frame.centerx # self.add_child(self.name_textfield) # gridview = ui.GridView(ui.Rect(0, 0, 500, 500)) # self.scroll_gridview = ui.ScrollView(ui.Rect( # MARGIN, self.name_textfield.frame.bottom + MARGIN, # 200 - scrollbar_size, 250), gridview) # self.add_child(self.scroll_gridview) # # items = ['Apples', 'Bananas', 'Grapes', 'Cheese', 'Goats', 'Beer'] # labels = [ui.Label(ui.Rect(0, 0, LIST_WIDTH, label_height), item, halign=ui.LEFT) for item in items] # list_view = ui.ListView(ui.Rect(0, 0, LIST_WIDTH, 400), labels) # list_view.on_selected.connect(self.item_selected) # list_view.on_deselected.connect(self.item_deselected) # self.scroll_list = ui.ScrollView(ui.Rect( # MARGIN, self.scroll_gridview.frame.bottom + MARGIN, # LIST_WIDTH, 80), list_view) # self.add_child(self.scroll_list) # self.greet_button = ui.Button( ui.Rect(self.lblHighDb.frame.right + SMALL_MARGIN, self.wthrImg.frame.bottom + SMALL_MARGIN, 0, 0), 'blank') self.greet_button.on_clicked.connect(self.greet) self.add_child(self.greet_button)