本文整理汇总了Python中gi.repository.Gtk.Switch方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.Switch方法的具体用法?Python Gtk.Switch怎么用?Python Gtk.Switch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.Switch方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setup_auto_hide
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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)
示例2: draw_status_elements
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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
示例3: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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)
示例4: get_widget
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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
示例5: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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()
示例6: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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)
示例7: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
def __init__(self, display_name, key, callback):
super().__init__(
display_name=display_name,
key=key,
callback=callback,
value_widget=Gtk.Switch()
)
示例8: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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)
示例9: add_switch
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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)
示例10: get_object_data
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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
示例11: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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()
示例12: __init__
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import Switch [as 别名]
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)