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