pyxforms/examples/demo5.py

66 lines
987 B
Python
Raw Normal View History

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(6, 640, 480)
2024-05-31 21:13:07 +00:00
#
# Show it
win.Show()
#
# Create a browser and a Button
2024-06-03 14:38:36 +00:00
brow = Browser(0, 10, 10, 620, 440, "Read Me")
but1 = Button(0, 10, 450, 100, 25, "Push Me")
but2 = Button(0, 120, 450, 100, 25, "Exit")
2024-05-31 21:13:07 +00:00
#
# Put them inside win
2024-06-03 14:38:36 +00:00
win.Add(brow)
win.Add(but1)
win.Add(but2)
2024-05-31 21:13:07 +00:00
#
# The exit function
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()
but2.cb = funct
2024-05-31 21:13:07 +00:00
#
# And the interesting function
2024-06-03 14:38:36 +00:00
2024-05-31 21:13:07 +00:00
def browse_file(self):
2024-06-03 14:38:36 +00:00
# Asks for a file, and puts it in the browser
filename = show_fselector("", "", "", "")
brow.Load(filename)
2024-05-31 21:13:07 +00:00
2024-06-03 14:38:36 +00:00
but1.cb = browse_file
2024-05-31 21:13:07 +00:00
#
# Start the event loop
# It will run until you press the button and say yes
runforms()