/[james]/currency/!Currency/py/Update.py
ViewVC logotype

Contents of /currency/!Currency/py/Update.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 12 - (show annotations) (download) (as text)
Mon Feb 10 18:25:55 2003 UTC (21 years, 8 months ago) by james
File MIME type: text/x-python
File size: 2229 byte(s)
Initial import.

1 # !Currency.py.Update/py
2
3 import swi
4 import wimp
5 import ConvrtW
6 import Rates
7
8
9 def update():
10 global window_update
11 window_update = wimp.window('update')
12 status(wimp.lookup('status.begin'), 1, wimp.lookup('action.begin'))
13 window_update.open_centred(-1)
14 window_update.put_caret()
15 if action():
16 return
17 while 1:
18 status(wimp.lookup('status.updating'), 0, 0)
19 wimp.hourglass_on()
20 try:
21 Rates.update(wimp.lookup('url'), '<Currency$Dir>.Rates',
22 wimp.lookup('us'), wimp.lookup('dollar'))
23 except IOError, (type, error):
24 wimp.hourglass_off()
25 swi.swi(0x107, '')
26 status(wimp.lookup('status.error') % (type, error), 1, wimp.lookup('action.error'))
27 if action():
28 return
29 continue
30 break
31 ConvrtW.update()
32 wimp.hourglass_off()
33 status(wimp.lookup('status.done') % Rates.date(), 0, wimp.lookup('action.done'))
34 if action():
35 return
36 window_update.remove()
37
38
39 def action():
40 while 1:
41 event, details = wimp.poll(1)
42 if event == 6:
43 if details[0] == window_update:
44 window_update.put_caret()
45 if details[0] == window_update and details[1] == 2:
46 return 0
47 elif details[0] == window_update and details[1] == 1:
48 window_update.remove()
49 return 1
50 elif details[0] != window_update:
51 window_update.remove()
52 wimp.handle((event, details))
53 return 1
54 elif event == 8:
55 if details[0] == window_update and details[2] == 0xd:
56 return 0
57 elif details[0] == window_update and details[2] == 0x1b:
58 window_update.remove()
59 return 1
60 else:
61 wimp.handle((event, details))
62 else:
63 wimp.handle((event, details))
64
65
66 def status(status, cancel, action):
67 window_update.icon_text(0, status)
68 window_update.icon_grey(1, 1 - cancel)
69 if action == 0:
70 window_update.icon_grey(2)
71 else:
72 window_update.icon_ungrey(2)
73 window_update.icon_text(2, action)

  ViewVC Help
Powered by ViewVC 1.1.26