def _create_dropdown(self, item_list, default_text=None, width=-1): if default_text: dropdown = KanoComboBox(default_text=default_text, max_display_items=7) else: dropdown = KanoComboBox(max_display_items=7) dropdown.set_size_request(width, -1) for i in item_list: dropdown.append(i) return dropdown
def _create_language_combo(self): language_combo = KanoComboBox(max_display_items=7) language_combo.connect('changed', self._on_language_changed) language_combo.set_items(SUPPORTED_LOCALES.list_languages()) return language_combo
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 __init__(self, video, main=None): super(AddToPlaylistPopup, self).__init__(main) self.video = video self._combo = KanoComboBox(max_display_items=7) self._combo.connect('changed', self._enable_add) self.grid.attach(self._combo, 0, 1, 1, 1) self._add_button = Button('ADD') self._add_button.get_style_context().add_class('green') self._add_button.set_sensitive(False) self._add_button.connect('clicked', self._add, self._combo) self.grid.attach(self._add_button, 1, 1, 1, 1) button = Button('CREATE NEW') button.get_style_context().add_class('orange_linktext') button.connect('clicked', self._new) self.grid.attach(button, 0, 2, 1, 1) self.refresh()
def __init__(self, win): # Show the Display brand and model self.model = get_edid_name() info_message = _("\nScreen Model: {}".format(self.model)) # And the current display resolution try: current_resolution = get_status()['resolution'] info_message += _("\nCurrent Resolution: {}").format(_(current_resolution)) except: pass Template.__init__( self, _("Display"), info_message, _("APPLY CHANGES") ) self.win = win self.win.set_main_widget(self) self.win.top_bar.enable_prev() self.win.change_prev_callback(self.win.go_to_home) self.kano_button.connect('button-release-event', self.apply_changes) self.kano_button.connect('key-release-event', self.apply_changes) horizontal_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=40) horizontal_container.set_valign(Gtk.Align.CENTER) # HDMI mode combo box self.mode_combo = KanoComboBox(max_display_items=7) self.mode_combo.connect('changed', self.on_mode_changed) # Fill list of modes modes = list_supported_modes() self.mode_combo.append('auto') mode_string = '{hdmi_group}:{hdmi_mode} {width}x{height} {refresh_rate}Hz {aspect_ratio}' if modes: for mode in modes: self.mode_combo.append(mode_string.format( hdmi_group=mode['group'], hdmi_mode=mode['mode'], width=mode['width'], height=mode['height'], refresh_rate=mode['rate'], aspect_ratio=mode['aspect_ratio'] )) horizontal_container.pack_start(self.mode_combo, False, False, 0) self.mode_combo.props.valign = Gtk.Align.CENTER # Select the current setting in the dropdown list saved_group, saved_mode = read_hdmi_mode() active_item = find_matching_mode(modes, saved_group, saved_mode) self.mode_combo.set_selected_item_index(active_item) self.init_item = active_item self.mode_index = active_item # Overscan button overscan_button = OrangeButton(_("Overscan")) horizontal_container.pack_end(overscan_button, False, False, 0) overscan_button.connect('button-release-event', self.go_to_overscan) self.box.pack_start(horizontal_container, False, False, 0) # Create Flip 180 checkbox flip_button = Gtk.CheckButton(_("Flip Screen")) flip_button.set_can_focus(False) flip_button.props.valign = Gtk.Align.CENTER flip_button.set_active(get_screen_value('display_rotate') == 2) flip_button.connect('clicked', self.flip) self.box.pack_start(flip_button, False, False, 0) self.kano_button.set_sensitive(False) # Add apply changes button under the main settings content self.win.show_all()
def _create_region_combo(self): region_combo = KanoComboBox(max_display_items=7) region_combo.connect('changed', self._on_region_changed) return region_combo
def __init__(self, win): Template.__init__( self, _("Keyboard"), _("Where do you live? So I can set your keyboard."), _("APPLY CHANGES") ) self.win = win self.win.set_main_widget(self) self.read_config() kano_keyboard = detect_kano_keyboard() self.win.top_bar.enable_prev() if kano_keyboard: self.win.change_prev_callback(self.go_to_kano_screen) else: self.win.change_prev_callback(self.win.go_to_home) self.kano_button.connect('button-release-event', self.apply_changes) # Make sure continue button is enabled self.kano_button.set_sensitive(False) # Create Continents Combo box self.continents_combo = KanoComboBox(max_display_items=7) for c in self.continents: self.continents_combo.append(c) self.continents_combo.connect('changed', self.on_continent_changed) # Create Countries Combo box self.countries_combo = KanoComboBox(max_display_items=7) self.countries_combo.connect('changed', self.on_country_changed) self.countries_combo.props.valign = Gtk.Align.CENTER # Create Advance mode checkbox advance_button = Gtk.CheckButton(_("Advanced options")) advance_button.set_can_focus(False) advance_button.props.valign = Gtk.Align.CENTER advance_button.connect('clicked', self.on_advance_mode) advance_button.set_active(False) # Create Variants Combo box self.variants_combo = KanoComboBox(max_display_items=7) self.variants_combo.connect('changed', self.on_variants_changed) self.variants_combo.props.valign = Gtk.Align.CENTER # Set up default values in dropdown lists self.set_defaults('continent') self.fill_countries_combo(self.continents_combo.get_selected_item_text()) self.set_defaults('country') self.on_country_changed(self.countries_combo) self.set_defaults('variant') # Ceate various dropdown boxes so we can resize the dropdown lists appropriately # We create two boxes side by side, and then stack the country dropdow lists in one, and one by itself in the other # dropdown_box_countries dropdown_box_keys # | | | # |-------continents-------| Advance option | # | | | # | | | # |-------countries -------|--------variants--------| # | | | dropdown_box_countries = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20) dropdown_box_countries.set_size_request(230, 30) dropdown_box_countries.props.valign = Gtk.Align.CENTER dropdown_box_keys = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=20) dropdown_box_keys.set_size_request(230, 30) dropdown_box_countries.pack_start(self.continents_combo, False, False, 0) dropdown_box_countries.pack_start(self.countries_combo, False, False, 0) dropdown_box_keys.pack_start(advance_button, False, False, 0) dropdown_box_keys.pack_start(self.variants_combo, False, False, 0) dropdown_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=20) dropdown_container.pack_start(dropdown_box_countries, False, False, 0) dropdown_container.pack_start(dropdown_box_keys, False, False, 0) self.box.pack_start(dropdown_container, False, False, 0) # show all elements except the advanced mode self.refresh_window()