Search code examples
pygobject

PyGObject: How to do a Grid


Ok, I have a ScrolledWindow with inside a Viewport and a Fixed inside of that. I'm using the Builder so I'm not gonna post ALL the code if is not necessary.

I'm using a function that multiplies the given coordinates per 50, so i have a grid with 50 x 50 pixel's squares (the number of squares can variate in the config).

The real question is very simple, how I can put a background of a grid of 50 per 50 pixels? And that should be """infinite""". Preferly the lines should be of 1 px.

Note: I'm not using a grid because I need only to put Images or Icons


Solution

  • I used that. Mainport is the fixed element, and wres and hres are the number of squares

        for i in range(self.wres):
            image = gtk.Image.new_from_file("resources/Back.png")
            self.mainport.put(image, i*50, 0)
            for z in range(self.hres):
                image2 = gtk.Image.new_from_file("resources/Back.png")
                self.mainport.put(image2, i*50, z*50)