当前位置: 首页>>代码示例>>Python>>正文


Python Gtk.Switch方法代码示例

本文整理汇总了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) 
开发者ID:buzz,项目名称:volctl,代码行数:22,代码来源:prefs.py

示例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 
开发者ID:daleosm,项目名称:PiHole-Panel,代码行数:23,代码来源:main.py

示例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) 
开发者ID:bilelmoussaoui,项目名称:Authenticator,代码行数:8,代码来源:settings.py

示例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 
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:8,代码来源:plugins.py

示例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() 
开发者ID:bilelmoussaoui,项目名称:Audio-Cutter,代码行数:10,代码来源:soundconfig.py

示例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) 
开发者ID:GabMus,项目名称:HydraPaper,代码行数:31,代码来源:wallpapers_folder_listbox_row.py

示例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()
        ) 
开发者ID:themix-project,项目名称:oomox,代码行数:9,代码来源:colors_list.py

示例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) 
开发者ID:KurtJacobson,项目名称:hazzy,代码行数:13,代码来源:pref_widgets.py

示例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) 
开发者ID:maoschanz,项目名称:drawing,代码行数:7,代码来源:preferences.py

示例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 
开发者ID:C2N14,项目名称:AutomaThemely,代码行数:15,代码来源:settsmanager.py

示例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() 
开发者ID:atareao,项目名称:lplayer,代码行数:47,代码来源:preferencesdialog.py

示例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) 
开发者ID:Jessewb786,项目名称:Silaty,代码行数:59,代码来源:silatycal.py


注:本文中的gi.repository.Gtk.Switch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。