Advertisement
Guest User

710888

a guest
May 6th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. from gi.repository import Gtk
  2.  
  3.  
  4. def fix_cb(widget, prop, check, bar):
  5.     bar.props.visible = check.get_active()
  6.  
  7. def check_cb(check, bar):
  8.     check.props.label = "Must be %svisible now" % ("" if check.get_active() else "in")
  9.     bar.set_visible(check.get_active())
  10.  
  11. def new_box(fixed):
  12.     box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 15)
  13.     bar = Gtk.InfoBar()
  14.     bar.get_content_area().add(Gtk.Label("Information"))
  15.     check = Gtk.CheckButton("InfoBar state")
  16.     check.connect("toggled", check_cb, bar)
  17.     check.set_active(True)
  18.  
  19.     if fixed:
  20.         check.set_label("InfoBar state (fixed)")
  21.         revealer = bar.get_children()[0]
  22.         revealer.connect_after("notify::child-revealed", fix_cb, check, bar)
  23.  
  24.     box.add(check)
  25.     box.add(bar)
  26.     return box
  27.  
  28. def main():
  29.     window = Gtk.Window()
  30.     box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 25)
  31.     box.add(Gtk.Label("Do double-click on checkbox when it's active"))
  32.     box.add(Gtk.Label("Current:"))
  33.     box.add(new_box(False))
  34.     box.add(Gtk.Label("With fix:"))
  35.     box.add(new_box(True))
  36.     window.add(box)
  37.     window.show_all()
  38.     window.connect("destroy", Gtk.main_quit)
  39.     Gtk.main()
  40.  
  41.  
  42. if __name__ == "__main__":
  43.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement