from gi.repository import Gtk

g = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=5)
g.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED)

b1 = Gtk.Button("FIRST")
b1.get_style_context().set_junction_sides(Gtk.JunctionSides.BOTTOM)
g.add(b1)

b2 = Gtk.Button("SECOND")
b2.get_style_context().set_junction_sides(Gtk.JunctionSides.TOP)
g.add(b2)

w = Gtk.Window()
w.add(g)
w.connect("delete-event", Gtk.main_quit)
w.show_all()

Gtk.main()
