Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from gi.repository import Gtk
- def fix_cb(widget, prop, check, bar):
- bar.props.visible = check.get_active()
- def check_cb(check, bar):
- check.props.label = "Must be %svisible now" % ("" if check.get_active() else "in")
- bar.set_visible(check.get_active())
- def new_box(fixed):
- box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 15)
- bar = Gtk.InfoBar()
- bar.get_content_area().add(Gtk.Label("Information"))
- check = Gtk.CheckButton("InfoBar state")
- check.connect("toggled", check_cb, bar)
- check.set_active(True)
- if fixed:
- check.set_label("InfoBar state (fixed)")
- revealer = bar.get_children()[0]
- revealer.connect_after("notify::child-revealed", fix_cb, check, bar)
- box.add(check)
- box.add(bar)
- return box
- def main():
- window = Gtk.Window()
- box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 25)
- box.add(Gtk.Label("Do double-click on checkbox when it's active"))
- box.add(Gtk.Label("Current:"))
- box.add(new_box(False))
- box.add(Gtk.Label("With fix:"))
- box.add(new_box(True))
- window.add(box)
- window.show_all()
- window.connect("destroy", Gtk.main_quit)
- Gtk.main()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement