Python gi.repository.Gtk.Switch() Examples
The following are 12
code examples of gi.repository.Gtk.Switch().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
gi.repository.Gtk
, or try the search function
.
Example #1
Source File: prefs.py From volctl with GNU General Public License v2.0 | 6 votes |
def _setup_auto_hide(self): key = self._schema.get_key("auto-close") row = Gtk.ListBoxRow() row.set_tooltip_text(key.get_description()) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) row.add(hbox) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) hbox.pack_start(vbox, True, True, 10) label = Gtk.Label(key.get_summary(), xalign=0) vbox.pack_start(label, True, True, 0) switch = Gtk.Switch() switch.props.valign = Gtk.Align.CENTER self._settings.bind( "auto-close", switch, "active", Gio.SettingsBindFlags.DEFAULT ) hbox.pack_start(switch, False, True, 10) self.listbox.add(row)
Example #2
Source File: main.py From PiHole-Panel with GNU General Public License v3.0 | 6 votes |
def draw_status_elements(self): button1 = Gtk.Switch(halign=Gtk.Align.CENTER) button1.connect("notify::active", self.on_status_switch_activated) status_label = Gtk.Label(halign=Gtk.Align.END) status_label.set_markup("<b>%s</b>" % "Status:") box = Gtk.Box(spacing=3) box.pack_start(status_label, True, True, 4) box.pack_start(button1, True, True, 4) # To add space between elements empty_label_1 = Gtk.Label(label="", margin=1) self.grid.attach(empty_label_1, 2, 1, 1, 1) self.grid.attach(box, 2, 2, 1, 1) # To add space between elements empty_label_2 = Gtk.Label(label="", margin=1) self.grid.attach(empty_label_2, 2, 3, 1, 1) return status_label, button1
Example #3
Source File: settings.py From Authenticator with GNU General Public License v2.0 | 5 votes |
def __init__(self, label, sub_label, schema): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) GObject.GObject.__init__(self) self.switch = Gtk.Switch() self._schema = schema self._build_widgets(label, sub_label)
Example #4
Source File: plugins.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_widget(self, _, value): widget = Gtk.Switch() widget.set_hexpand(True) widget.set_property('halign', Gtk.Align.START) self.set_widget_value(widget, value) return widget
Example #5
Source File: soundconfig.py From Audio-Cutter with GNU General Public License v3.0 | 5 votes |
def __init__(self): Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL) self.set_border_width(18) self._start_time = TimeButton() self._end_time = TimeButton() self._fade_in = Gtk.Switch() self._fade_out = Gtk.Switch() self._setup_widgets()
Example #6
Source File: wallpapers_folder_listbox_row.py From HydraPaper with GNU General Public License v3.0 | 5 votes |
def __init__(self, folder_path, folder_active, on_switch_state_set): super().__init__() self.folder_path = folder_path self.box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) self.label = Gtk.Label() self.switch = Gtk.Switch() self.label.set_text(folder_path) self.label.set_margin_left(12) self.label.set_margin_right(6) self.label.set_halign(Gtk.Align.START) self.switch.value = folder_path self.switch.set_active(folder_active) self.switch.set_margin_left(6) self.switch.set_margin_right(12) self.switch.connect('state-set', on_switch_state_set) self.box.pack_start(self.label, True, True, 0) self.box.pack_start(self.switch, False, False, 0) self.box.set_margin_top(6) self.box.set_margin_bottom(6) self.value = folder_path self.add(self.box)
Example #7
Source File: colors_list.py From oomox with GNU General Public License v3.0 | 5 votes |
def __init__(self, display_name, key, callback): super().__init__( display_name=display_name, key=key, callback=callback, value_widget=Gtk.Switch() )
Example #8
Source File: pref_widgets.py From hazzy with GNU General Public License v2.0 | 5 votes |
def __init__(self, section, option, default_value=False): Gtk.Switch.__init__(self) self.section = section self.option = option self.default_value = default_value self.connect('state-set', self.on_state_set) self.state = prefs.get(self.section, self.option, self.default_value, bool) self.set_active(self.state)
Example #9
Source File: preferences.py From drawing with GNU General Public License v3.0 | 5 votes |
def add_switch(self, label_text, key): switch = Gtk.Switch() switch.set_active(self._settings.get_boolean(key)) switch.connect('notify::active', self.on_bool_changed, key) self.add_row(label_text, switch)
Example #10
Source File: settsmanager.py From AutomaThemely with GNU General Public License v3.0 | 5 votes |
def get_object_data(obj, *args): if isinstance(obj, Gtk.ComboBoxText): return obj.get_active_id() if obj.get_active_id() != 'none' else '' elif isinstance(obj, Gtk.Switch): return obj.get_active() elif isinstance(obj, Gtk.SpinButton): return obj.get_value_as_int() elif isinstance(obj, Gtk.Entry): text = obj.get_text() if obj.get_name() == 'float_only' and isfloat(text): return float(text) else: return text
Example #11
Source File: preferencesdialog.py From lplayer with MIT License | 4 votes |
def __init__(self, window): # Gtk.Dialog.__init__(self, '{0} | {1}'.format( comun.APPNAME, _('Preferences')), window, Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT, (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT, Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT)) self.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.set_icon_from_file(comun.ICON) frame = Gtk.Frame.new('Track options') frame.set_margin_top(5) frame.set_margin_bottom(5) frame.set_margin_left(5) frame.set_margin_right(5) self.get_content_area().add(frame) grid = Gtk.Grid() grid.set_margin_top(10) grid.set_margin_bottom(10) grid.set_margin_left(10) grid.set_margin_right(10) grid.set_column_spacing(5) grid.set_row_spacing(5) frame.add(grid) label = Gtk.Label('Must I download audio when it just added?') label.set_alignment(0, 0.5) grid.attach(label, 0, 0, 1, 1) self.download_on_added = Gtk.Switch() grid.attach(self.download_on_added, 1, 0, 1, 1) label = Gtk.Label('Must I remove audio when you listened it?') label.set_alignment(0, 0.5) grid.attach(label, 0, 1, 1, 1) self.remove_on_listened = Gtk.Switch() grid.attach(self.remove_on_listened, 1, 1, 1, 1) self.load_preferences() self.show_all()
Example #12
Source File: silatycal.py From Silaty with GNU General Public License v3.0 | 4 votes |
def __init__(self): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL, spacing=12, margin_bottom=12) # Set the Date in the Title topbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, halign=Gtk.Align.FILL, margin_right=12, margin_left=12, margin_top=12, margin_bottom=12) self.titlestack = Gtk.Stack() self.titlestack.set_transition_type(Gtk.StackTransitionType.CROSSFADE) self.titlestack.set_transition_duration(300) self.titlestack.set_halign = Gtk.Align.START now_wd = datetime.datetime.now().strftime("%A") g_day = datetime.datetime.now().strftime("%d") g_month = datetime.datetime.now().strftime("%B") g_year = datetime.datetime.now().strftime("%Y") g_date = '%s %s %s' % (g_day, _(g_month), g_year) gtitlelabel = Gtk.Label(label=(_('%s, %s') % (_(now_wd), g_date))) gtitlelabel.props.halign = Gtk.Align.START self.options = Options() calc = HijriCal(self.options.hijrical_adjustment) h_months = ['Muharram', 'Safar', 'Rabi al Awwal', 'Rabi al Akhira', 'Jumada al Ula', 'Jumada al Akhira', 'Rajab', "Sha'ban", 'Ramadan', 'Shawwal', "Dhu al Qa'da", 'Dhu al Hijja'] h_year, h_month, h_day, h_week_day = calc.today h_date = '%i %s %i' % (h_day, _(h_months[int(h_month-1)]), h_year) htitlelabel = Gtk.Label(label=(_('%s, %s') % (_(now_wd), h_date))) htitlelabel.props.halign = Gtk.Align.START self.titlestack.add_named(gtitlelabel, "Gregorian") self.titlestack.add_named(htitlelabel, "Hijri") topbox.pack_start(self.titlestack , False, False, 0) # Set up the Hijri/Gregorian Switch hijrilabel = Gtk.Label(_('Hijri:'), halign=Gtk.Align.START) self.hijri = Gtk.Switch(halign=Gtk.Align.END) self.hijri.set_active(False) self.hijri.connect('button-press-event', self.on_entered_hijri) hijrilabel.set_halign(Gtk.Align.START) box= Gtk.Box(halign=Gtk.Align.END, spacing=6) box.pack_start(hijrilabel, False, True, 0) box.pack_start(self.hijri, False, False, 0) topbox.pack_end(box, False, False, 0) # Set up the date switcher self.cal = Cal(self) #bottombox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, halign=Gtk.Align.FILL, margin=24) #opmaya = Gtk.Button(label="Open Maya") #datesettings = Gtk.Button(label="Date and Time settings") #bottombox.pack_start(opmaya, False, False, 0) #bottombox.pack_end(datesettings, False, False, 0) self.pack_start(topbox, False, True, 0) self.pack_start(self.cal, False, False, 0) #self.pack_start(bottombox, False, True, 0)