pyxforms/examples/demo2.py

54 lines
747 B
Python
Raw Permalink Normal View History

2024-06-03 21:07:23 +00:00
#!/usr/bin/env python
2024-05-31 21:13:07 +00:00
2024-06-03 21:07:23 +00:00
from pyxforms import *
from pyxforms.goodies import *
2024-05-31 21:13:07 +00:00
#
# 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)
2024-06-03 21:07:23 +00:00
answer = show_question("Do you want to exit?", "")
2024-06-03 14:38:36 +00:00
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()