def __init__(self, values): super(DropdownInput, self).__init__() self._combo = KanoComboBox(items=values) KanoComboBox.apply_styling_to_screen() self._combo.connect("selected", self._emit_value_changed) # Propagate the dropdown widget popup signal self._combo.connect("popup", self._emit_popup) self.add(self._combo)
def _create_birthday_widget(self, day=None, month=None, year=None): KanoComboBox.apply_styling_to_screen() current_year = datetime.datetime.now().year years = [str(i) for i in range(current_year, 1900, -1)] self._year_dropdown = self._create_dropdown(years, "Year") self._year_dropdown.connect("changed", self._update_day_dropdown) months = [] for i in range(1, 13): months.append(calendar.month_name[i]) self._month_dropdown = self._create_dropdown(months, "Month", width=60) self._month_dropdown.connect("changed", self._update_day_dropdown) # When the month gets changed, the day gets changed. # At start, shows days 1-31 days = [str(i) for i in range(1, 32)] self._day_dropdown = self._create_dropdown(days, "Day") self._day_dropdown.connect("changed", self.validate) hbox = Gtk.Box() hbox.pack_start(self._year_dropdown, False, False, 10) hbox.pack_start(self._month_dropdown, False, False, 10) hbox.pack_start(self._day_dropdown, False, False, 10) hbox.set_margin_left(20) hbox.set_margin_right(10) # validation label_box = Gtk.Box() label_box.set_margin_left(30) birthday_label = Gtk.Label(_("Birthday")) birthday_label.get_style_context().add_class("get_data_label") label_box.pack_start(birthday_label, False, False, 0) self._birthday_status = Gtk.Label() self._birthday_status.get_style_context().add_class("validation_label") label_box.pack_start(self._birthday_status, False, False, 0) # Container for the validation and title labels self.pack_start(label_box, False, False, 0) # Container for the dropdowns self.pack_start(hbox, False, False, 0)
def _create_birthday_widget(self, day=None, month=None, year=None): KanoComboBox.apply_styling_to_screen() current_year = datetime.datetime.now().year years = [str(i) for i in range(current_year, 1900, -1)] self._year_dropdown = self._create_dropdown(years, _("Year")) self._year_dropdown.connect('changed', self._update_day_dropdown) months = [] for i in range(1, 13): months.append(calendar.month_name[i]) self._month_dropdown = self._create_dropdown(months, _("Month"), width=60) self._month_dropdown.connect('changed', self._update_day_dropdown) # When the month gets changed, the day gets changed. # At start, shows days 1-31 days = [str(i) for i in range(1, 32)] self._day_dropdown = self._create_dropdown(days, _("Day")) self._day_dropdown.connect('changed', self.validate) hbox = Gtk.Box() hbox.pack_start(self._year_dropdown, False, False, 10) hbox.pack_start(self._month_dropdown, False, False, 10) hbox.pack_start(self._day_dropdown, False, False, 10) hbox.set_margin_left(20) hbox.set_margin_right(10) # validation label_box = Gtk.Box() label_box.set_margin_left(30) birthday_label = Gtk.Label(_("Birthday")) birthday_label.get_style_context().add_class('get_data_label') label_box.pack_start(birthday_label, False, False, 0) self._birthday_status = Gtk.Label() self._birthday_status.get_style_context().add_class('validation_label') label_box.pack_start(self._birthday_status, False, False, 0) # Container for the validation and title labels self.pack_start(label_box, False, False, 0) # Container for the dropdowns self.pack_start(hbox, False, False, 0)
def __init__(self, screen_number=None, screen_name=None, socket_id=0, onescreen=False): # Check for internet, if screen is 12 means no internet if screen_number == 12 or screen_name == 'no-internet': common.has_internet = False else: common.has_internet = is_internet() # Set combobox styling to the screen # Is done here so we don't attach the styling multiple times when # switching screens apply_styling_to_screen(self.CSS_PATH) apply_common_to_screen() KanoComboBox.apply_styling_to_screen() ScrolledWindow.apply_styling_to_screen(wide=True) # Set window base_class.__init__(self, _("Settings"), self.width, self.height, socket_id) self.set_decorated(True) self.top_bar = TopBar(_("Settings")) self.top_bar.set_close_callback(self.close_window) self.prev_handler = None self.set_icon_name('kano-settings') if self._base_name == "Window": self.set_titlebar(self.top_bar) self._onescreen = onescreen self.connect('delete-event', Gtk.main_quit) # In case we are called from kano-world-launcher, terminate splash os.system('kano-stop-splash') # Init to Home Screen HomeScreen(self, screen_number=screen_number, screen_name=screen_name)
def __init__(self, screen_number=None, screen_name=None, socket_id=0, onescreen=False): # Check for internet, if screen is 12 means no internet if screen_number == 12 or screen_name == 'no-internet': common.has_internet = False else: common.has_internet = is_internet() # Set combobox styling to the screen # Is done here so we don't attach the styling multiple times when # switching screens apply_styling_to_screen(self.CSS_PATH) apply_common_to_screen() KanoComboBox.apply_styling_to_screen() ScrolledWindow.apply_styling_to_screen(wide=True) # Set window base_class.__init__(self, _("Settings"), self.width, self.height, socket_id) self.set_decorated(True) self.top_bar = TopBar(_("Settings")) self.top_bar.set_close_callback(self.close_window) self.prev_handler = None self.set_icon_name('kano-settings') if self._base_name == "Window": self.set_titlebar(self.top_bar) self._onescreen = onescreen self.connect('delete-event', Gtk.main_quit) # In case we are called from kano-world-launcher, terminate splash os.system('kano-stop-splash') # Init to Home Screen HomeScreen(self, screen_number=screen_number, screen_name=screen_name)