Gtk.CheckButton


Gtk.CheckButton — Create widgets with a discrete toggle button

Object Hierarchy:

    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ╰── Gtk.Container
                ╰── Gtk.Bin
                    ╰── Gtk.Button
                        ╰── Gtk.ToggleButton
                            ╰── Gtk.CheckButton
                                ╰── Gtk.RadioButton

See also:

Gtk.CheckMenuItem, Gtk.Button, Gtk.ToggleButton, Gtk.RadioButton


Functions:

Description:

A Gtk.CheckButton places a discrete Gtk.ToggleButton next to a widget, (usually a Gtk.Label). See the section on Gtk.ToggleButton widgets for more information about toggle/check buttons.

The important signal ( Gtk.ToggleButton::toggled ) is also inherited from Gtk.ToggleButton.


Function Details:

new()

new () -> Gtk.Widget

Creates a new Gtk.CheckButton.

  • Returns: a Gtk.Widget.

new_with_label()

new_with_label (label:str) -> Gtk.Widget

Creates a new Gtk.CheckButton with a Gtk.Label to the right of it.

  • Returns: a Gtk.Widget.

new_with_mnemonic()

new_with_mnemonic (label:str) -> Gtk.Widget

Creates a new Gtk.CheckButton containing a label. The labelwill be created using `Gtk.Label:new_with_mnemonic(), so underscoresinlabel` indicate the mnemonic for the check button.

  • Returns: a new Gtk.CheckButton

Example:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class CheckButton(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self)
        self.set_title("CheckButton")
        self.connect("destroy", Gtk.main_quit)

        checkbutton = Gtk.CheckButton(label="CheckButton")
        checkbutton.connect("toggled", self.on_check_button_toggled)
        self.add(checkbutton)

    def on_check_button_toggled(self, checkbutton):
        if checkbutton.get_active():
            print("CheckButton toggled on!")
        else:
            print("CheckButton toggled off!")

window = CheckButton()
window.show_all()

Gtk.main()

results matching ""

    No results matching ""