~toolpart/+junk/pythoncard

« back to all changes in this revision

Viewing changes to samples/worldclock/worldclock.py

  • Committer: Bazaar Package Importer
  • Author(s): Sandro Tosi
  • Date: 2010-03-04 23:55:10 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100304235510-3v6lbhzwrgm0pcca
Tags: 0.8.2-1
* QA upload.
* New upstream release
* debian/control
  - set maintainer to QA group
  - set Homepage field, removing the URL from packages description
  - bump versioned b-d-i on python-support, to properly support Python module
  - replace b-d on python-all-dev with python-all, since building only
    arch:all packages
  - replace Source-Version substvar with source:Version
  - add ${misc:Depends} to binary packages Depends
* debian/watch
  - updated to use the SourceForge redirector; thanks to Raphael Geissert for
    the report and to Dario Minnucci for the patch; Closes: #449904
* debian/{pythoncard-doc, python-pythoncard}.install
  - use wildcards instead of site-packages to fix build with python 2.6;
    thanks to Ilya Barygin for the report and patch; Closes: #572332
* debian/pythoncard-doc.doc-base
  - set section to Programmin/Python
* debian/pythoncard-tools.menu
  - set menu main section to Applications
* debian/pythoncard-tools.postinst
  - removed, needed only to update the menu, but it's now created by debhelper

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
KEA notes to myself
5
5
 
6
6
Created: 2001-07-22
7
 
__version__ = "$Revision: 1.27 $"
8
 
__date__ = "$Date: 2004/08/30 14:50:08 $"
 
7
__version__ = "$Revision: 1.28 $"
 
8
__date__ = "$Date: 2005/09/18 03:59:22 $"
9
9
__author__ = "Kevin Altis <altis@semi-retired.com>"
10
10
 
11
11
I'm using an ImageButton rather than an image because I want to catch
25
25
from cStringIO import StringIO
26
26
 
27
27
from PythonCard import graphic, log, model, timer
28
 
#from PythonCard.log import Log
29
28
 
30
29
import xearth
31
30
 
33
32
 
34
33
    def on_initialize(self, event):
35
34
        self.url = ''
36
 
 
37
 
        # Enable logging
38
 
        ###self.log = Log.getInstance()
39
 
        # self.log.enable()
40
 
        # Normally we enable only ERROR and WARNING messages
41
 
        ###self.log.enableLevels( [ Log.ERROR, Log.WARNING, Log.DEBUG, Log.INFO ] )
42
 
 
43
35
        # KEA 2002-05-27
44
36
        # switched to timer events
45
37
        self.clockTimer = timer.Timer(self.components.staticTextClock, -1)
50
42
        self.updateDateAndTime()
51
43
        self.updateImage()
52
44
 
53
 
 
54
45
    def on_staticTextClock_timer(self, event):
55
46
        self.updateDateAndTime()
56
47
 
58
49
        t = time.strftime("%I:%M %p")
59
50
        if t[0] == "0":
60
51
            t = t[1:]
61
 
 
62
52
        if self.components.staticTextClock.text != t:
63
53
            self.components.staticTextClock.text = t
64
54
            d = time.strftime("%A, %B %d, %Y")
70
60
 
71
61
    def updateImage(self):        
72
62
        log.info("interval is up...")
73
 
        # try:
74
 
        #    jScript = "cscript //nologo xearth.js"
75
 
        #    file = os.popen(jScript)
76
 
        #    s = file.read()
77
 
        #    url = "http://www.time.gov/" + s
78
 
        # except:
79
 
        #    url = "http://www.time.gov/images/xearths/night.jpg"
80
 
        #    #url = "http://www.time.gov/images/xearths/11N/100N.jpg"
81
63
        url = "http://www.time.gov/" + xearth.getLatLong()
82
 
 
83
64
        if url == self.url:
84
65
            return
85
 
 
86
66
        self.url = url
87
 
        ###self.log.info( "updating image ", url )
88
67
        log.info("updating image ", url)
89
68
 
90
69
        # download image from www.time.gov
92
71
            fp = urllib.urlopen(url)
93
72
            jpg = fp.read()
94
73
            fp.close()
95
 
        except:
 
74
        except Exception, msg:
96
75
            return
97
76
 
98
77
        wImageButtonWorld = self.components.imageButtonWorld
99
78
 
100
 
        # pre wxPython 2.3.3.1 the image data
101
 
        # had to be written to disk first
102
 
        #f = open('night2.jpg', "wb")
103
 
        #f.write(jpg)
104
 
        #f.close()
105
 
 
106
 
        #newBitmap = graphic.Bitmap('night2.jpg')
107
 
        
108
79
        # with wxPython 2.3.3.1 and above it is no longer
109
80
        # necessary to write the file to disk before displaying it
110
81
        newBitmap = graphic.Bitmap()
119
90
        self.imageTimer.stop()
120
91
        event.skip()
121
92
 
122
 
 
123
93
if __name__ == '__main__':
124
94
    app = model.Application(WorldClock)
125
95
    app.MainLoop()