Exemple #1
0
 def on_initialize(self, event):
     print "initialize", event.target.name
     self.num_idles = 0
     self.fldTimer = timer.Timer(self.components.fld)
     self.fldTimer.start(10 * 1000)  # 10 seconds
     self.btnTimer = timer.Timer(self.components.btn)
     self.btnTimer.start(3 * 1000)  # 3 seconds
     self.components.btn.setFocus()
     # on the Mac, findFocus() is returning None
     # when the sample is started with a runtime tool
     focus = self.findFocus()
     if focus:
         print "  has focus:", focus.name
Exemple #2
0
    def on_initialize(self, event):
        self.initSizers()
        self.loadConfig()
        self.displayOfflineUsers = 0
        self.roster = {}
        self.chatWindows = {}

        self.msgQueue = Queue.Queue()
        self.rosterQueue = Queue.Queue()

        self.jabberConnection = JabberConnection(self, self.account)
        self.thread = threading.Thread(
            target=self.jabberConnection.spinMyWheels)
        self.thread.setDaemon(1)
        self.thread.start()

        self.idleTimer = timer.Timer(self.components.listRoster, -1)
        self.idleTimer.start(1000)  # 1 second

        self.doResetIdle()

        # the Available and Do Not Disturb strings
        # should probably be settable as resource strings
        # the connection module references them as menu item labels
        # when the user starts the program, just default to Available
        self.statusBar.text = "Available"
Exemple #3
0
 def on_initialize(self, event):
     self.x = 0
     self.y = 0
     self.animate = False
     self.filename = None
     # leave it black for now
     #self.components.bufOff.foregroundColor = self.color
     self.sprites = []
     self.timer = timer.Timer(self.components.btnAnimate, -1)
     self.initSizers()
     self.components.bufOff.autoRefresh = False
Exemple #4
0
 def on_initialize(self, event):
     self.clockTimer = timer.Timer(self.components.txtTime, -1)
     self.clockModel = CountdownClockModel(MAX_TIME)        
     self.delegates = ModeratorModel()
     if len(sys.argv) > 1:
         fname = sys.argv[1]
     else:
         fname = DELEGATE_FILE
     try:
         lines = open(fname).readlines()
     except IOError:
         lines = []
     for delegate in lines:
         if delegate.strip():
             self.delegates.add(delegate.strip())            
     self.update()
Exemple #5
0
    def on_initialize(self, event):
        try:
            msg = ' '.join(sys.argv[1:]) or 'No title'
            title = '{} pid={}'.format(msg, os.getpid())
            self.title = title
            self.components.titluapp.text = title

            self.flag_secunde = True
            self.myTimer = timer.Timer(self.components.textceas,
                                       -1)  # create a timer
            self.myTimer.Start(500)  # launch timer, to fire every x ms

            msg = ''
            for i in os.environ:
                N = 48
                value = os.environ[i]
                if len(value) > N:
                    value = '{}...'.format(value[:N])
                msg += '{} = {}\n'.format(i, value)
            self.components.envinfo.text = msg
        except Exception as ex:
            self.errDialog(ex)
Exemple #6
0
    def on_initialize(self, event):
        self.doctor = False
        self.walking = False
        self.sleeping = False
        self.playing = False
        self.eating = False
        self.time_cycle = 0
        self.hunger = 0
        self.happiness  = 8
        self.health = 8
        self.forceAwake = False
        self.sleepImages = ["sleep1.gif","sleep2.gif","sleep3.gif", "sleep4.gif"]  # Here are the images
        self.eatImages = ["eat1.gif", "eat2.gif"]                                  # for the different animations
        self.walkImages = ["walk1.gif", "walk2.gif", "walk3.gif", "walk4.gif"]     #
        self.playImages = ["play1.gif", "play2.gif"]                               #
        self.doctorImages = ["doc1.gif", "doc2.gif"]                               #
        self.nothingImages  = ["pet1.gif", "pet2.gif", "pet3.gif"]                 #
        
        self.imageList = self.nothingImages
        self.imageIndex = 0
        
        self.myTimer1 = timer.Timer(self.components.petwindow, -1)          # Animation timer
        self.myTimer1.Start(500) 
        # timers have to belong to a component, so we made the
        # 'tick' timer part of the HungerGuage component
        self.myTimer2 = timer.Timer(self.components.HungerGauge, -1)        
        self.myTimer2.Start(5000)                                           
        filehandle = True
        try:                                                   # open the pickle file
            file = open("savedata_vp.pkl", "r")                # if there is one
        except:
            filehandle = False
        if filehandle:
            save_list = pickle.load(file)
            file.close()
        else:
            save_list = [8, 8, 0, datetime.datetime.now(), 0]
        self.happiness = save_list[0]
        self.health    = save_list[1]
        self.hunger    = save_list[2]
        then = save_list[3]
        self.time_cycle = save_list[4]

        difference = datetime.datetime.now() - then
        ticks = difference.seconds / 50  
        for i in range(0, ticks):
            self.time_cycle += 1
            if self.time_cycle == 60:
                self.time_cycle = 0
            if self.time_cycle <= 48:        #awake
                self.sleeping = False
                if self.hunger < 8:
                    self.hunger += 1                
            else:                            #sleeping
                self.sleeping = True
                if self.hunger < 8 and self.time_cycle % 3 == 0:
                    self.hunger += 1
            if self.hunger == 7 and (self.time_cycle % 2 ==0) and self.health > 0:
                self.health -= 1
            if self.hunger == 8 and self.health > 0:  
                self.health -=1
        if self.sleeping:
            self.imageList = self.sleepImages
        else:
            self.imageList = self.nothingImages
Exemple #7
0
 def on_initialize(self, event):
     self.doctor = False
     self.walking = False
     self.sleeping = False
     self.playing = False
     self.eating = False
     self.paused = False                       # We added this attribute for Paused
     self.time_cycle = 0
     self.hunger = 0
     self.happiness  = 8
     self.health = 8
     self.forceAwake = False
     self.sleepImages = ["sleep1.gif","sleep2.gif","sleep3.gif", "sleep4.gif"]  
     self.eatImages = ["eat1.gif", "eat2.gif"]                                  
     self.walkImages = ["walk1.gif", "walk2.gif", "walk3.gif", "walk4.gif"]     
     self.playImages = ["play1.gif", "play2.gif"]                               
     self.doctorImages = ["doc1.gif", "doc2.gif"]                               
     self.nothingImages  = ["pet1.gif", "pet2.gif", "pet3.gif"]                 
     
     self.components.btnPause.label = "Pause"
     self.components.stPaused.text  = ""
     
     self.imageList = self.nothingImages
     self.imageIndex = 0
     
     self.myTimer1 = timer.Timer(self.components.petwindow, -1)          
     self.myTimer1.Start(500) 
     
     self.myTimer2 = timer.Timer(self.components.HungerGauge, -1)        
     self.myTimer2.Start(5000)                                           
     filehandle = True
     try:                                                   
         file = open("savedata_vp.pkl", "r")                
     except:
         filehandle = False
     if filehandle:
         save_list = pickle.load(file)
         file.close()
     else:
         save_list = [8, 8, 0, datetime.datetime.now(), 0, False]  # added pause state 
     self.happiness = save_list[0]                                   # to the default save list
     self.health    = save_list[1]
     self.hunger    = save_list[2]
     then = save_list[3]
     self.time_cycle = save_list[4]
     self.paused = save_list[5]                        # recall the "paused" state
     if self.paused:
         self.components.btnPause.label = "Resume"
         self.components.stPaused.text = "Paused"
     else:
         self.components.btnPause.label = "Pause"
         self.components.stPaused.text = ""
     
     if not self.paused:
         difference = datetime.datetime.now() - then
         ticks = difference.seconds / 50  
         for i in range(0, ticks):
             self.time_cycle += 1
             if self.time_cycle == 60:
                 self.time_cycle = 0
             if self.time_cycle <= 48:        
                 self.sleeping = False
                 if self.hunger < 8:
                     self.hunger += 1                
             else:                            
                 self.sleeping = True
                 if self.hunger < 8 and self.time_cycle % 3 == 0:
                     self.hunger += 1
             if self.hunger == 7 and (self.time_cycle % 2 ==0) and self.health > 0:
                 self.health -= 1
             if self.hunger == 8 and self.health > 0:  
                 self.health -=1
     if self.sleeping:
         self.imageList = self.sleepImages
     else:
         self.imageList = self.nothingImages
Exemple #8
0
 def on_initialize(self, event):
     self.sucker = None
     self.msgq = None
     self.clockTimer = timer.Timer(self.components.fldURL, -1)
Exemple #9
0
    def on_initialize(self, event):
        self.x = 0
        self.y = 0
        self.filename = None
        self.directory = None
        self.zip = None
        self.bmp = None
        self.fileList = None
        self.fileIndex = 0
        self.clockTimer = timer.Timer(self.components.bufOff, -1)
        self.interval = 1000 * 2  # 5 seconds
        self.loop = 0

        self.components.bufOff.backgroundColor = 'black'
        self.components.bufOff.clear()

        if sys.platform.startswith('win'):
            del self.components['htmlView']
            self.components['htmlView'] = {
                'type': 'IEHtmlWindow',
                'name': 'htmlView',
                'position': (0, 0),
                'size': (150, 150),
                'visible': 0
            }
            # can't disable the component if we want it
            # to scroll, so need another way to capture
            # key presses so the IE control doesn't get them
            # however since slideshow is for displaying HTML
            # where you shouldn't need to scroll this is probably fine
            # there is still some kind of focus bug with the IE control
            # on certain HTML pages
            self.components.htmlView.enabled = 0

        # this is the code from pictureViewer
        # instead of a file argument, slideshow
        # should take either a file or directory
        # argument
        # if given a directory, the slide show would
        # be setup to start in that directory
        # if given a file argument, the contents
        # of the file would contain a list of files to
        # display, one file per line
        if len(sys.argv) > 1:
            # accept a file argument on the command-line
            filename = os.path.abspath(sys.argv[1])
            log.info('slideshow filename: ' + filename)
            if not os.path.exists(filename):
                filename = os.path.abspath(
                    os.path.join(self.application.startingDirectory,
                                 sys.argv[1]))
            #print filename
            if os.path.isfile(filename):
                #self.openFile(filename)
                self.buildFileListFromFile(filename)
                self.on_menuSlideshowFirstSlide_select(None)
            elif os.path.isdir(filename):
                includeSubDirs = self.menuBar.getChecked(
                    'menuOptionsIncludeSubDirectories')
                self.buildFileListFromDirectory(filename, includeSubDirs)
                self.on_menuSlideshowFirstSlide_select(None)

        # PythonCard doesn't currently support
        # binding key presses to just the background, so this
        # is a hack
        wx.EVT_KEY_UP(self.components.bufOff, self.on_keyPress)
        wx.EVT_KEY_UP(self.components.htmlView, self.on_keyPress)

        self.visible = True
        self.on_size(None)