def show_district_selection(self): if not self.table_mode: h = 34 * len(self.district_blocks_fid) + 5 * ( len(self.district_blocks_fid) - 1) box = self.gui_touch_focus_buttons = BoxLayout( orientation='vertical', size=(dp(100), dp(h)), spacing=dp(5), pos=(self.focus_region_width, 0)) for i, val in enumerate(self.district_blocks_fid): btn = ToggleButton(text='District {}'.format(i + 1), group='focus', allow_no_selection=False) box.add_widget(btn) def update_current_fid(*largs, button=btn, value=val): if button.state == 'down': self.current_fid_id = value btn.fbind('state', update_current_fid) box.children[-1].state = 'down' self.add_widget(box)
def show_focus_region(self): focus_metrics = self.focus_metrics if not focus_metrics: return if not self.table_mode: btn = ToggleButton(text='Focus', group='focus', allow_no_selection=False) self.gui_touch_focus_buttons.add_widget(btn) def update_current_fid(*largs, button=btn): if button.state == 'down': self.current_fid_id = self.focus_block_logical_id btn.fbind('state', update_current_fid) i = 0 focus_metric_width = self.focus_metric_width focus_metric_height = self.focus_metric_height for col in range(self.n_focus_cols): for row in range(self.n_focus_rows): name = focus_metrics[i] x0 = col * focus_metric_width x1 = x0 + focus_metric_width y0 = row * focus_metric_height y1 = y0 + focus_metric_height self.add_widget(Factory.SizedLabel(text=name, pos=(x0, y0))) with self.canvas: Line(points=[x0, y0, x1, y0, x1, y1, x0, y1], width=2) i += 1 if i >= len(focus_metrics): break if i >= len(focus_metrics): break