Help With Button Layout
Norman Davis
normandavis at bigfoot.com
Tue Dec 10 00:30:54 EST 2002
More information about the Python-list mailing list
Tue Dec 10 00:30:54 EST 2002
- Previous message (by thread): Help With Button Layout
- Next message (by thread): Help With Button Layout
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Kenneth, kennethg at pd.jaring.my (Kenneth Gomez) wrote in message news:<3df3dfaa.7860877 at news.jaring.my>... > I am creating a simple GUI. However, I am having problems getting my > buttons to lay side by side. Do you know why my first two buttons are > spaced out so far. To get a better look at what's happenning, add borders to your canvases like this: def createCanvas(self): """ Main drawing canvas """ self.mainCanvas = Canvas(self, relief=RAISED, borderwidth = 2) self.mainCanvas.grid(row=2, column = 2, columnspan=5,sticky=W+E+S+N) """ Canvas to hold icons """ self.iconCanvas = Canvas(self, relief=RAISED, borderwidth = 2) self.iconCanvas.grid(row=2, column=0, columnspan = 2,sticky=W+E+N+S) In a grid, columns (and rows) become as big as necessary to contain the largest item. The spanning makes this rule a little more complex, but what you should see with the borders now is that iconCanvas causes columns 0 and 1 to be stretched out above it. Also, the menu bar stretches out column 0, so the Mesh button in column 1 is pushed over (though I didn't expected it to be pushed that far). The five other buttons fit snugly together above mainCanvas. I'm guessing you would like the rows to be more independent. The grid layout manager is good for many things, but I think what you need for this application is to use the "pack" layout manager. Vertically stack frames representing rows: one frame for the menu bar, one frame for the buttons, one frame for the canvases, and one frame for the entry field. If you'd like to stay with the grid for now, you could move the buttons over into their own columns further to the right. Maybe there's a way to arrange them there that looks nice. > Also, how do I get my menu, buttons and all to start at the top, left > hand corner, instead of the center of the canvas? > If you do stay with grid, try removing the line self.master.geometry("800x600") and see if you like that. If you go with pack, you might want to keep that line if you want a fixed initial window size. pack should give you enough control to put everything where you want it. (note: it looks like you've got an extra call to self.grid() at the bottom of the definition of createButtons.) Norm.
- Previous message (by thread): Help With Button Layout
- Next message (by thread): Help With Button Layout
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list