pyxforms/examples/demo2.py

54 lines
742 B
Python
Executable File

#!/usr/local/bin/python
from Pyxform import *
from goodies import *
#
# Init the library (sucks but works)
#
xfinit("Something", "1", sys.argv[0])
#
# Create a "Window" - A form in XForms parlance
win = Form()
#
# Show it
win.Show()
#
# Create a button
a_button = Button(0, 10, 10, 100, 30, "Press Me")
#
# Put it inside win
win.Add(a_button)
#
# Define a function, that will be executed when the button is pressed
def funct(self):
# It shows a message and exits (or not)
answer = show_question("Do you want", "to exit?", "")
if answer == 1:
sys.exit()
#
# And bind the function to the button
a_button.cb = funct
#
# Start the event loop
# It will run until you press the button and say yes
runforms()