Portál AbcLinuxu, 6. listopadu 2025 16:32
Řešení dotazu:
from gi.repository import Gtk
w = Gtk.Window(type=Gtk.WindowType.POPUP)
x = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
x.adding = True
w.add(x)
def add_button(self, x):
c = x.get_children()
n = len(c)
if x.adding:
b = Gtk.Button.new_with_label('Label %u' % (n + 1))
b.connect('clicked', add_button, x)
b.show()
x.add(b)
if n == 5:
x.adding = False
else:
c[-1].destroy()
if n == 1:
Gtk.main_quit()
else:
r = w.size_request()
w.resize(r.width, r.height)
add_button(None, x)
w.show_all()
Gtk.main()
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.