Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import gi
- gi.require_version("Gtk", "3.0")
- from gi.repository import Gtk
- def on_click(button):
- #Toggle
- if popover.get_visible():
- popover.hide()
- else:
- popover.show_all()
- #Creating the window
- window = Gtk.Window(title="Popover")
- window.connect("destroy", lambda w: Gtk.main_quit())
- #Creating and placing a button
- box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)
- button = Gtk.Button.new_from_icon_name("open-menu-symbolic", 1)
- button.connect("clicked", on_click)
- box.add(button)
- window.add(box)
- #Creating a popover
- popover = Gtk.PopoverMenu.new()
- popover.set_relative_to(button)
- pbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL)
- popover.add(pbox)
- one = Gtk.ModelButton.new()
- one.set_label("Button One")
- pbox.pack_start(one, False, False, 0)
- two = Gtk.ModelButton.new()
- two.set_label("Button Two")
- pbox.pack_start(two, False, False, 0)
- three = Gtk.ModelButton.new()
- three.set_label("Button Three")
- pbox.pack_start(three, False, False, 0)
- window.set_size_request(200, 200)
- window.show_all()
- Gtk.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement