Question

i've a problem on showing and hiding a Gtk.TextView. The UI is drawed by Glade, here below the code:

self.__Indirizzi_IP_TextView = builder.get_object('Indirizzi_IP_TextView')
self.__Indirizzi_IP_Window = builder.get_object('Indirizzi_IP_Window')

self.__Indirizzi_IP_Window.connect("delete-event", lambda widget, args=(): widget.hide())

Here below the signal handler for the clicked-event of the right Gtk.Button

def Visualizza_indirizzi_IP_Button_clicked(self, widget, args=()):

        textbuffer = self.__Indirizzi_IP_TextView.get_buffer()
        textbuffer.set_text((' ').join(self.__configurazione['Indirizzi_IP']))
        self.__Indirizzi_IP_Window.show()

Every time i try to show it:

  • the first time it works correctly, the window appears with the data
  • then i close it, and if i try to re-open i got a blank window

I don't know what to do, because this code comes from the official tutorial

Was it helpful?

Solution

My guess: You use widget.hide() as the delete-event handler, but that does not stop other handlers from running as hide() does not return True. As a result the window gets deleted. Try writing your own handler that calls hide() and returns True.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top