def draw(self, new_input, input_list): x, y, col_sp, row_sp, x_list, y_list = grid_function(self.cols, self.rows) self.cursor_x += input_list[0] if self.cursor_x < 0: self.cursor_x = 0 if self.cursor_x > 5: self.cursor_x = 5 if new_input: if input_list[2] == 1: # tests if the c button is pressed self.relay_state_list[self.cursor_x] = self.rc.toggle(self.cursor_x) self.canvas.clear() with self.canvas: Color(.4, .4, .4) Rectangle(pos=(x_list[self.cursor_x] + 10, y_list[0] + 25), size=(col_sp - 20, row_sp - 50)) # Triangle(points=()) add triangles left and right of the cursor for i in range(0, 6): if self.relay_state_list[i] == 'ON': Color(.2, .9, .2) Line(points=(x_list[i] + col_sp/2, y_list[2], x_list[i] + col_sp/2, y_list[5]), width=3) Ellipse(pos=(x_list[i] + col_sp / 2 - 25, y_list[5] - 25), size=(50, 50)) else: Color(.9, .2, .2) Line(points=(x_list[i] + col_sp/2, y_list[2], x_list[i] + col_sp/2, y_list[5]), width=3) Ellipse(pos=(x_list[i] + col_sp / 2 - 25, y_list[2] - 25), size=(50, 50)) Color(1, 1, 1) # RESET COlOR, in case this is the last time the draw function is called
def setup(self): x, y, col_sp, row_sp, x_list, y_list = grid_function( self.cols, self.rows) with self.canvas.before: Rectangle(pos=(0, 0), source='images/BG_1.png', size=(x, y)) Color(0, 0, 0) Line(points=(col_sp / 50, y_list[0], x - col_sp / 50, y_list[0], x - col_sp / 50, y_list[5] + row_sp / 2, col_sp / 50, y_list[5] + row_sp / 2, col_sp / 50, y_list[0], x - col_sp / 50), width=1) Line(points=(col_sp / 50, y_list[2] - row_sp / 2, x - col_sp / 50, y_list[2] - row_sp / 2)) Line(points=(3 * col_sp, y_list[2] - row_sp / 2, 3 * col_sp, 0)) Color(.9, .2, .2) Line(points=(x_list[1], y_list[3] + row_sp / 4, x_list[3], y_list[3] + row_sp / 4), width=1.5) Ellipse(pos=(x_list[1] - 5, y_list[3] + row_sp / 4 - 5), size=(10, 10)) Ellipse(pos=(x_list[3] - 5, y_list[3] + row_sp / 4 - 5), size=(10, 10)) Color(.2, .2, .9) Line(points=(x_list[1], y_list[3] - row_sp / 2, x_list[3], y_list[3] - row_sp / 2), width=1.5) Ellipse(pos=(x_list[1] - 5, y_list[3] - row_sp / 2 - 5), size=(10, 10)) Ellipse(pos=(x_list[3] - 5, y_list[3] - row_sp / 2 - 5), size=(10, 10)) Color(1, 1, 1)
def setup(self): x, y, col_sp, row_sp, x_list, y_list = grid_function(self.cols, self.rows) with self.canvas.before: Rectangle(pos=(0, 0), source='images/BG_1.png', size=(x, y)) # Rectangle(pos=(0, 0), source='images/BG_1.png', size=(x - col_sp/25, y_list[5] - row_sp/2)) self.add_widget(Label(text='Relay Controller', pos=(-x/2 + col_sp/2, y/2 - row_sp/4))) Color(0,0,0) Line(points=(col_sp/50, y_list[1], x - col_sp/50, y_list[1], x - col_sp/50, y_list[5] + row_sp/2, col_sp/50, y_list[5] + row_sp/2, col_sp/50, y_list[1], x - col_sp/50), width=1) Line(points=(col_sp/50, y_list[2] - row_sp/2, x - col_sp/50, y_list[2] - row_sp/2)) for i in range(0, 6): Color(.4,.4,.4) self.add_widget(Label(text=self.label_list[i], pos=(x_list[i] - x/2 + col_sp/2, y_list[1] - y/2 + 25)))
def bg_draw(self): cols = 10 rows = 10 x, y, col_sp, row_sp, x_list, y_list = grid_function(cols, rows) with self.canvas: for i in range(1, cols): for j in range(1, rows): Ellipse(pos=(x_list[i] + math.sin(self.bg_count + i * math.pi / 4) * col_sp / 16, y_list[j] + math.sin(self.bg_count + i * math.pi / 4) * row_sp / 16), size=(2, 2)) self.bg_count += math.pi / 256
def draw(self): cols = 10 rows = 10 x, y, col_sp, row_sp, x_list, y_list = grid_function(cols, rows) self.canvas.clear() self.row_labels = [] with self.canvas: Rectangle(pos=(Window.size[0] / 2 - self.lbt.texture_size[0] / 2, Window.size[1] / 2 - self.lbt.texture_size[1] / 2), texture=self.lbt.texture, size=list(self.lbt.texture_size)) for i in range(1, cols): for j in range(1, rows): Ellipse(pos=( x_list[i] + math.sin(self.bg_count + i * math.pi / 4) * col_sp / 8, y_list[j] + math.sin(self.bg_count + i * math.pi / 4) * row_sp / 8), size=(2, 2)) self.bg_count += math.pi / 32
def static_draw(self, p): label_list = ['Relay', 'Weather', 'NA', 'NA', 'NA'] x, y, col_sp, row_sp, x_list, y_list = grid_function( 7, 7) # pass requested collums and rows self.lb.text = label_list[p] self.canvas.clear() with self.canvas: self.bg_draw() Rectangle( pos=(x_list[3] + col_sp / 2 - self.lb.texture.size[0] / 2, y_list[4] - 1.25 * col_sp), texture=self.lb.texture, size=list(self.lb.texture.size)) Rectangle(pos=(x_list[3], y_list[4] - col_sp), source='images/' + label_list[p] + '1.png', size=(col_sp, col_sp)) for i in range(0, p): Rectangle(pos=(x_list[3] - .75 * col_sp - .75 * (p - i) * col_sp, y_list[4] - col_sp), source='images/' + label_list[i] + '.png', size=(.6 * col_sp, .6 * col_sp)) for i in range(p + 1, self.total_icons): Rectangle(pos=(x_list[3] + .75 * col_sp + .75 * (i - p) * col_sp, y_list[4] - col_sp), source='images/' + label_list[i] + '.png', size=(.6 * col_sp, .6 * col_sp)) for i in range(0, 5): if i == p: Line(close=True, ellipse=(Window.size[0] / 2 + 20 * i - 48, 10, 16, 16)) if i != p: Ellipse(pos=(Window.size[0] / 2 + 20 * i - 48, 10), size=(16, 16)) # -48,-28,-8,3,8
def static_draw(self, new_input, input_list): x, y, col_sp, row_sp, x_list, y_list = grid_function( self.cols, self.rows) '''self.add_widget(Label(text=self.high_list[0].text, pos=(-x/2, -y/2 + y_list[5] - row_sp/4), font_size='64sp')) # current temp self.add_widget(Label(text=self.high_list[0].text + ' / ' + self.low_list[0].text, pos=(-x/2 + self.size[0]/2, -y/2 + y_list[4] + row_sp/3), font_size='16sp')) # current temp''' self.canvas.clear() with self.canvas: Rectangle(pos=(col_sp / 32, y - row_sp / 3), texture=self.a.texture, size=self.a.texture.size) Rectangle(pos=(col_sp / 32, y_list[4] + 2 * row_sp / 3), texture=self.b.texture, size=self.b.texture.size) Rectangle(pos=(col_sp / 32 + self.b.texture.size[0] / 2 - self.c.texture.size[0] / 2, y_list[4] + row_sp / 2), texture=self.c.texture, size=self.c.texture.size) Rectangle(pos=(x_list[1] + col_sp / 2, y_list[4] + 7 * row_sp / 12), source='images/w_icon.png', size=(75, 75)) if self.d3.text != 'text': Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5]), texture=self.d.texture, size=self.d.texture.size) Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5] - self.d.texture.size[1]), texture=self.d1.texture, size=self.d1.texture.size) Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5] - self.d1.texture.size[1] * 2), texture=self.d2.texture, size=self.d2.texture.size) Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5] - self.d2.texture.size[1] * 3), texture=self.d3.texture, size=self.d3.texture.size) elif self.d2.text != 'text': Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5]), texture=self.d.texture, size=self.d.texture.size) Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5] - self.d.texture.size[1]), texture=self.d1.texture, size=self.d1.texture.size) Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5] - self.d1.texture.size[1] * 2), texture=self.d2.texture, size=self.d2.texture.size) elif self.d1.text != 'text': Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5]), texture=self.d.texture, size=self.d.texture.size) Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5] - self.d.texture.size[1]), texture=self.d1.texture, size=self.d1.texture.size) else: Rectangle(pos=(x_list[2] + col_sp / 2, y_list[5]), texture=self.d.texture, size=self.d.texture.size) # Precipitation, Wind, and Humity Rectangle(pos=(col_sp / 32, y_list[4]), texture=self.e.texture, size=self.e.texture.size) Rectangle(pos=(col_sp / 32, y_list[4] - self.e.texture.size[1]), texture=self.e1.texture, size=self.e1.texture.size) Rectangle(pos=(col_sp / 32, y_list[4] - self.e.texture.size[1] * 2), texture=self.e2.texture, size=self.e2.texture.size) # ASTRONOMY TITLES, Solar Title(j) nad Lunar Title(k) Rectangle(pos=(col_sp / 32, y_list[3] + row_sp / 4 - 10), texture=self.j.texture, size=self.j.texture.size) Rectangle(pos=(col_sp / 32, y_list[3] - row_sp / 2 - 10), texture=self.k.texture, size=self.k.texture.size) # End segments of solar line (x_list[1], y_list[3] + row_sp/4) and (x_list[3], y_list[3] + row_sp/4) # End segments of lunar line (x_list[1], y_list[3] - row_sp/2) and (x_list[3], y_list[3] - row_sp/2) # Sun up(f) Sun down(g) Moon up(h) Moon down(i) Rectangle(pos=(x_list[1] - self.f.texture.size[0] / 2, y_list[3]), texture=self.f.texture, size=self.f.texture.size) Rectangle(pos=(x_list[3] - self.g.texture.size[0] / 2, y_list[3]), texture=self.g.texture, size=self.g.texture.size) Rectangle(pos=(x_list[1] - self.h.texture.size[0] / 2, y_list[3] - .75 * row_sp), texture=self.h.texture, size=self.h.texture.size) Rectangle(pos=(x_list[3] - self.i.texture.size[0] / 2, y_list[3] - .75 * row_sp), texture=self.i.texture, size=self.i.texture.size) # Show current sun and moon location sun_range = abs( int(self.astro_data['sun_phase']['sunset']['hour']) + int(self.astro_data['sun_phase']['sunset']['minute']) / 60 - int(self.astro_data['sun_phase']['sunrise']['hour']) - int(self.astro_data['sun_phase']['sunrise']['minute']) / 60) moon_range = abs( int(self.astro_data['moon_phase']['moonset']['hour']) + int(self.astro_data['moon_phase']['moonset']['minute']) / 60 - int(self.astro_data['moon_phase']['moonrise']['hour']) - int(self.astro_data['moon_phase']['moonrise']['minute']) / 60) s_calc_time = abs( int(self.astro_data['moon_phase']['current_time']['hour']) + int(self.astro_data['moon_phase']['current_time']['minute']) / 60 - int(self.astro_data['sun_phase']['sunrise']['hour']) - int(self.astro_data['sun_phase']['sunrise']['minute']) / 60) m_calc_time = abs( int(self.astro_data['moon_phase']['current_time']['hour']) + int(self.astro_data['moon_phase']['current_time']['minute']) / 60 - int(self.astro_data['moon_phase']['moonrise']['hour']) - int(self.astro_data['moon_phase']['moonrise']['minute']) / 60) sun_pct = s_calc_time / sun_range moon_pct = m_calc_time / moon_range if sun_pct < 1: Color(.9, .2, .2) Line(points=(3 * col_sp * sun_pct, y_list[3] + row_sp / 4 + row_sp / 8, 3 * col_sp * sun_pct, y_list[3] + row_sp / 4 - row_sp / 8), width=1.5) if moon_pct < 1: Color(.2, .2, .9) Line(points=(3 * col_sp * moon_pct, y_list[3] - row_sp / 2 + row_sp / 8, 3 * col_sp * moon_pct, y_list[3] - row_sp / 2 - row_sp / 8), width=1.5) Color(1, 1, 1) Rectangle(pos=(x_list[4] - col_sp / 4, y_list[3] + row_sp / 4 - 10), texture=self.l.texture, size=self.l.texture.size) Rectangle(pos=(x_list[4] - col_sp / 4, y_list[3] - row_sp / 2 - 10), texture=self.m.texture, size=self.m.texture.size) for i in range(1, len(self.day_list)): Rectangle(pos=(col_sp / 32 + 1 * col_sp * (i - 1), y_list[1] + row_sp / 6), texture=self.day_list[i].texture, size=self.day_list[i].texture.size) Rectangle(pos=(col_sp / 32 + 1 * col_sp * (i - 1), y_list[1] - row_sp / 4), texture=self.high_list[i].texture, size=self.high_list[i].texture.size) Rectangle(pos=(col_sp / 32 + 1 * col_sp * (i - 1), y_list[1] - row_sp / 4 - self.low_list[i].texture.size[1]), texture=self.low_list[i].texture, size=self.low_list[i].texture.size) Rectangle(pos=(col_sp / 32 + 1 * col_sp * (i - 1), y_list[1] - row_sp / 4 - self.low_list[i].texture.size[1] * 2), texture=self.pop_list[i].texture, size=self.pop_list[i].texture.size) self.date_rect = Rectangle(pos=(x_list[3] + col_sp / 2, y_list[1] + row_sp / 6), texture=self.n.texture, size=self.n.texture.size) self.time_rect = Rectangle( pos=(self.date_rect.pos[0] + (self.n.texture.size[0] - self.o.texture.size[0]) / 2, y_list[1] - self.o.texture.size[1]), texture=self.o.texture, size=self.o.texture.size)
def setup(self): x, y, col_sp, row_sp, x_list, y_list = grid_function(1, 1) with self.canvas.before: Rectangle(pos=(0, 0), source='images/BG_1.png', size=(x, y))