| 1 | # Standard dialog test program for the Python port of |
| 2 | # the Fast Light Tool Kit (pyFLTK). |
| 3 | # |
| 4 | # Demonstrates how to use readqueue to see if a button has been |
| 5 | # pushed, and to see if a window has been closed, thus avoiding |
| 6 | # the need to define callbacks. |
| 7 | # |
| 8 | # This also demonstrates how to trap attempts by the user to |
| 9 | # close the last window by overriding Fl::exit |
| 10 | # |
| 11 | # FLTk is Copyright 1998-2003 by Bill Spitzak and others. |
| 12 | # pyFLTK copyright 2003 by Andreas Held and others. |
| 13 | # |
| 14 | # This library is free software; you can redistribute it and/or |
| 15 | # modify it under the terms of the GNU Library General Public |
| 16 | # License, version 2.0 as published by the Free Software Foundation. |
| 17 | # |
| 18 | # This library is distributed in the hope that it will be useful, |
| 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | # Library General Public License for more details. |
| 22 | # |
| 23 | # You should have received a copy of the GNU Library General Public |
| 24 | # License along with this library; if not, write to the Free Software |
| 25 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 26 | # USA. |
| 27 | # |
| 28 | # Please report all bugs and problems to "[email protected]". |
| 29 | # |
| 30 | |
| 31 | |
| 32 | from fltk import * |
| 33 | import sys |
| 34 | |
| 35 | buffer = None |
| 36 | |
| 37 | def rename_me(o): |
| 38 | global buffer |
| 39 | buffer = o.label() |
| 40 | input = fl_input("Input:", buffer) |
| 41 | if input != None: |
| 42 | buffer = input |
| 43 | o.label(buffer) |
| 44 | o.redraw() |
| 45 | |
| 46 | def window_callback(ptr): |
| 47 | #status = fl_ask("Are you sure you want to quit?") |
| 48 | status = fl_choice("Are you sure you want to quit?", "No", "Yes", None) |
| 49 | if status == 1: |
| 50 | return sys.exit(0) |
| 51 | |
| 52 | |
| 53 | # main function |
| 54 | buffer = "test text" |
| 55 | |
| 56 | window = Fl_Window(200, 55) |
| 57 | |
| 58 | #b = Fl_Return_Button(20, 10, 160, 35, buffer) |
| 59 | b = Fl_Return_Button(20, 10, 160, 35, "test text") |
| 60 | b.callback(rename_me) |
| 61 | window.add(b) |
| 62 | window.resizable(b) |
| 63 | |
| 64 | window.callback(window_callback) |
| 65 | |
| 66 | window.show(len(sys.argv), sys.argv) |
| 67 | |
| 68 | |
| 69 | |
| 70 | Fl.run() |