| 1 | # |
| 2 | # "$Id: grid_buttons.py 28 2003-07-16 20:00:27Z andreasheld $" |
| 3 | # |
| 4 | # Wizard test program for pyFLTK the Python bindings |
| 5 | # for the Fast Light Tool Kit (FLTK). |
| 6 | # |
| 7 | # FLTK copyright 1998-1999 by Bill Spitzak and others. |
| 8 | # pyFLTK copyright 2003 by Andreas Held and others. |
| 9 | # |
| 10 | # This library is free software you can redistribute it and/or |
| 11 | # modify it under the terms of the GNU Library General Public |
| 12 | # License, version 2.0 as published by the Free Software Foundation. |
| 13 | # |
| 14 | # This library is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | # Library General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU Library General Public |
| 20 | # License along with this library if not, write to the Free Software |
| 21 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 22 | # USA. |
| 23 | # |
| 24 | # Please report all bugs and problems to "[email protected]". |
| 25 | # |
| 26 | |
| 27 | |
| 28 | from fltk import * |
| 29 | |
| 30 | |
| 31 | if __name__=='__main__': |
| 32 | win = Fl_Double_Window(460, 200, "Fl_Grid Row with 5 Buttons") |
| 33 | grid = Fl_Grid(0, 0, win.w(), 50) |
| 34 | grid.layout(1, 7, 10, 10) |
| 35 | |
| 36 | # create the buttons |
| 37 | |
| 38 | b0 = Fl_Button(0, 0, 80, 30, "New") |
| 39 | b1 = Fl_Button(0, 0, 80, 30, "Options") |
| 40 | b3 = Fl_Button(0, 0, 80, 30, "About") |
| 41 | b4 = Fl_Button(0, 0, 80, 30, "Help") |
| 42 | b6 = Fl_Button(0, 0, 80, 30, "Quit") |
| 43 | |
| 44 | grid.end() |
| 45 | |
| 46 | # assign buttons to grid positions |
| 47 | |
| 48 | grid.widget(b0, 0, 0) |
| 49 | grid.widget(b1, 0, 1) |
| 50 | grid.col_gap(1, 0) |
| 51 | grid.widget(b3, 0, 3) |
| 52 | grid.widget(b4, 0, 4) |
| 53 | grid.col_gap(4, 0) |
| 54 | grid.widget(b6, 0, 6) |
| 55 | |
| 56 | # set column weights for resizing (only empty columns resize) |
| 57 | |
| 58 | weight = [ 0, 0, 50, 0, 0, 50, 0 ]; |
| 59 | grid.col_weight(weight); |
| 60 | |
| 61 | grid.end() |
| 62 | grid.show_grid(1) # enable to display grid helper lines |
| 63 | |
| 64 | # add content ... |
| 65 | |
| 66 | g1 = Fl_Group(0, 50, win.w(), win.h() - 50) |
| 67 | # add more widgets ... |
| 68 | |
| 69 | win.end() |
| 70 | win.resizable(g1) |
| 71 | win.size_range(win.w(), 100) |
| 72 | |
| 73 | |
| 74 | win.show() |
| 75 | Fl.run() |