Error at delete all child of Gtk.Paned (Gtk4&Python)

If I delete all child of Gtk.Paned, an error occurs:
Error finding last focus widget of GtkPaned

self.paned.set_end_child(None)
self.paned.set_start_child(None)

Hi,

Well, an empty paned doesn’t make so much sense, probably it’s an unexpected corner case…

Either set something neutral like an empty Gtk.Label as one of the children, or just hide the whole panel with self.paned.set_visible(False) if you don’t need to show anything.

1 Like

Can you make a minimal, self-contained test case?

1 Like
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk, Gio
import sys



class MainWindow(Gtk.ApplicationWindow):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        paned_M = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL)
        paned_M.set_wide_handle(True)
        paned_R = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
        paned_R.set_wide_handle(True)
        paned_L = Gtk.Paned.new(Gtk.Orientation.VERTICAL)
        paned_L.set_wide_handle(True)
        btn1 = Gtk.Button.new_from_icon_name("window-close-symbolic")
        btn1.connect('clicked', lambda *a: paned_R.set_start_child(None))
        btn2 = Gtk.Button.new_from_icon_name("window-close-symbolic")
        btn2.connect('clicked', lambda *a: paned_R.set_end_child(None))
        paned_R.set_start_child(btn1)
        paned_R.set_end_child(btn2)
        btn3 = Gtk.Button.new_from_icon_name("window-close-symbolic")
        btn3.connect('clicked', lambda *a: paned_L.set_start_child(None))
        btn4 = Gtk.Button.new_from_icon_name("window-close-symbolic")
        btn4.connect('clicked', lambda *a: paned_L.set_end_child(None))
        paned_L.set_start_child(btn3)
        paned_L.set_end_child(btn4)
        paned_M.set_start_child(paned_R)
        paned_M.set_end_child(paned_L)
        self.set_child(paned_M)

class MyApp(Gtk.Application):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
    

    def do_activate(self):
        win = MainWindow(application=self)
        win.present()

app = MyApp(application_id=None,flags= Gio.ApplicationFlags.FLAGS_NONE)
app.run(sys.argv)

The error did not occur in the small example. It seems that the problem is in my program

Maybe something like this might help me

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.