jeanc
jeanc

Reputation: 4833

pygtk.HBox not redrawing after add

I have a program written in Python, using PyGTK+Glade. I use Glade to create the Layout, and internally, I create some other elements, including a list of labels. I have a VBox of size 3, each of these 3 elements containing an EventBox which contains an HBox.

Each HBox will contain a dinamically changing set of Labels. The problem is that after Adding elemens to the HBox, it doesn't show anything or doesn't get redraw.

As I said, there are some events/functions that change the HBoxes, however, something like this even doesn't work:

def __init__(self):

    self.builder = gtk.Builder()
    self.builder.add_from_file("maininterface.glade")

    self.window = self.builder.get_object("mainWindow")

    self.fila1 = self.builder.get_object("hbox1")
    self.fila2 = self.builder.get_object("hbox2")
    self.fila3 = self.builder.get_object("hbox3")

    self.window.show_all()
    lab0 = gtk.Label("XXXXXX")
    self.fila1.add(lab0) #this label is not shown

    #if I uncomment the next line, it works:
    #self.window.show_all()

Obviously, I am missing something, I don't know what. I could make all the adds before show_all() but that just works for initialization, the program will remove/add elements on the fly.

PD: I used pack_end() instead of add() but the result is the same.

Upvotes: 0

Views: 208

Answers (1)

anthony
anthony

Reputation: 41098

You will need to call gtk.Widget.show() on each label that you add to the HBox. Alternatively, you can call gtk.Widget.show_all() on the HBox after adding one or more labels.

Upvotes: 3

Related Questions