pyxforms/examples/demo5.py

66 lines
988 B
Python
Executable File

#!/usr/local/bin/python
from pyxforms 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(6, 640, 480)
#
# Show it
win.Show()
#
# Create a browser and a Button
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")
#
# Put them inside win
win.Add(brow)
win.Add(but1)
win.Add(but2)
#
# The exit function
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
#
# And the interesting function
def browse_file(self):
# Asks for a file, and puts it in the browser
filename = show_fselector("", "", "", "")
brow.Load(filename)
but1.cb = browse_file
#
# Start the event loop
# It will run until you press the button and say yes
runforms()