def __init__(self):
     self.path=AppDisk+":\\system\\Apps\\PJChat\\"
     self.OL_start=0
     self.OL_gaptime=None
     self.OL_old_starttime=None
     self.OL_new_starttime=None
     self.OL_keep=e32.Ao_timer()
     self.MSG_auto=0
     self.MSG_gaptime=None
     self.MSG_starttime=None
     self.MSG_keep=e32.Ao_timer()
Esempio n. 2
0
 def __init__(self):
     self.lock = e32.Ao_lock()
     self.sets = Settings()
     self.timert = e32.Ao_timer()
     self.timerip = e32.Ao_timer()
     self.apid_list = [-1] + [ap["iapid"] for ap in socket.access_points()]
     self.ap_list = [u"Ask User"
                     ] + [ap["name"] for ap in socket.access_points()]
     self.i = 1
     self.yesno = [ru("No"), ru("Yes")]
     self.count = 0
     self.developer = "gauravssnl"
Esempio n. 3
0
 def __init__(self):
     global orientation
     EventFilter.__init__(self)
     self.__orientation_old = orientation.TOP
     self.__orientation_cur = orientation.TOP
     self.__timedout = False
     self.__timer = e32.Ao_timer()
Esempio n. 4
0
 def __init__(s,path=None,waitTime=0):
   s.screenSize=appuifw.app.layout(appuifw.EScreen)[0]
   s.maxLines=[5,8][s.screenSize[1]>240]
   s.__doc__=__doc__
   s.__canvas=appuifw.Canvas(s.__redraw,s.__events)
   appuifw.app.body=s.__canvas
   try:
     s.blit(Image.open(path))
     e32.ao_sleep(waitTime)
   except:pass
   del path,waitTime
   appuifw.app.exit_key_handler=s.__exit
   s.__imgOld=Image.new(s.screenSize)
   s.__img=s.__imgOld
   s.__mask=Image.new(s.screenSize,"L")
   s.__mask.clear(0x888888)
   s.__imgBlack=Image.new(s.screenSize)
   s.index=0
   s.super=0
   s.selectType=0
   s.keyType=0
   s.keyList=[[16,50,63497],[17,56,63498],[14,52,63495],[15,54,63496],[167,53,63557],[196,63586]]
   s.TitleName="BingyiApp模块".decode("u8")
   s.__lock=e32.Ao_lock()
   s.__timer=e32.Ao_timer()
Esempio n. 5
0
 def __init__(self):
     self.imglist = {}
     self.urlhead = 'http://api.ithome.com/'
     self.host="api.ithome.com"
     self.newsListUrl = '/json/newslist/news?r=0'
     self.slideUrl = '/json/slide/index'
     self.newsContentUrl ='/json/newscontent/'
     self.newsCornor = 2
     self.newImgHeight = 0
     self.newImgWidth = 0
     self.SlideHeight = 0
     self.SlideWidth = 0
     self.newslist = []
     self.slidelist = []
     self.th1 = e32.Ao_timer()
     self.th2 = e32.Ao_timer()
     self.errorImg = None
     self.newsLoadingImg = None
     self.slideLoadingImg = None
     self.asyncLoad = None
     self.imgcount = 0
     self.nowimgindex = 0
     self.loadingPrecent = 0
     self.nowUrl = ['',(200,200)]
Esempio n. 6
0
 def show_about(self):
     img_path = self.drive + u':\\data\\python\\about.png'
     if self.orientation == 'landscape' or not os.path.exists(img_path):
         appuifw.note(u"Scribble is Copyright (c) 2009 Nokia Corporation")
         self.canvas.blit(self.draw_img)
         self.draw_buttons()
     else:
         self.about_window = Image.open(img_path)
         self.about_active = True
         self.clear_button_bindings()
         self.canvas.blit(self.about_window)
         self.canvas.bind(EButton1Up, self.clear_about_screen,
                          ((0, 0), (self.x_max, self.y_max)))
         self.about_timer = e32.Ao_timer()
         self.about_timer.after(5, self.clear_about_screen)
Esempio n. 7
0
        def __init__(self, play_mode, sock):
            self.play_mode = play_mode
            self.sock = sock

            self.orientation = sensor.orientation.TOP
            self.won = False
            self.elapsed_time = 0.0
            self.last_attack = 0.0
            self.health = INITIAL_HEALTH
            self.orientation_history = zeros(HISTORY_SIZE)
            self.index = 0
            self.game_over = False
            self.quitting = False

            volume_options = [[u"Volume off", 0], [u"Volume low", 1],
                              [u"Volume med", 2], [u"Volume high", 3]]

            appuifw.app.exit_key_handler = self.quit
            appuifw.app.menu = [(u"Choose skin",
                                 tuple([(unicode(skin["skinName"].title()),
                                         self.skin_changer(skin))
                                        for skin in ui.SKINS])),
                                (u"Set volume",
                                 tuple([(option[0],
                                         self.volume_changer(option[1]))
                                        for option in volume_options])),
                                (u"Back to the fight", self.back_to_fight),
                                (u"Back to main menu", self.quit)]

            self.__timer = e32.Ao_timer()

            self.event = None
            self.eventlock = e32.Ao_lock()

            axyz.connect(self.new_accel_data)

            sensor_type = sensor.sensors()['RotSensor']
            self.rotation_sensor = sensor.Sensor(sensor_type['id'],
                                                 sensor_type['category'])
            self.rotation_sensor.set_event_filter(sensor.RotEventFilter())
            self.rotation_sensor.connect(self.new_rotation_data)

            self.tick()
Esempio n. 8
0
def finddevices(getnames=True, length=10):
    # originally this used DiscoverDevices in _lightblueutil extension, but
    # that blocks the UI

    import e32

    inquiry = _DeviceInquiry()
    inquiry.start(getnames, length)
    
    timer = None
    try:
        while not inquiry.isdone():
            # keep waiting
            timer = e32.Ao_timer()
            timer.after(0.1)
    finally:
        inquiry.stop()
        if timer is not None: timer.cancel()
    
    return inquiry.getfounddevices()
Esempio n. 9
0
    def __init__(self):
        if DEBUG:
            self.__log()
        self.app_lock = e32.Ao_lock()
        appuifw.app.exit_key_handler = self.quit
        appuifw.app.title = u"Jwcx"
        appuifw.app.screen = "normal"
        self.listbox = appuifw.Listbox([(u"", u"")], self.listCallback)
        appuifw.app.body = self.listbox

        self.timer = e32.Ao_timer()

        self.user = ""
        self.passwd = ""
        self.loginResp = ""
        self.reLogin = False
        self.configFile = "%swin32.sock" % systemRoot

        self.createMenu()
        self.login()
 def run(self):
     """run(self)->None main application cycle"""
     try:
         if self.running == 0:
             return
         self.timer = e32.Ao_timer()
         for i in range(2):
             self.figure[i].new()
         self.canvas.drawNow()
         while self.running == 1:
             if not self.figure[0].move(0, 0, 1):
                 self.score += self.scoretable[self.figure[0].release()]
                 self.figure[0].new()
                 self.figure[0], self.figure[1] = self.figure[
                     1], self.figure[0]
                 self.canvas.drawNow()
                 if not self.figure[0].free(self.figure[0].pos):
                     self.set_exit(2)
             self.delay *= 0.999
             self.timer.after(self.delay)
     finally:
         self.end()
Esempio n. 11
0
    def __init__(self, book_path):
        self.old_body = appuifw.app.body
        self.old_menu = appuifw.app.menu
        appuifw.app.exit_key_handler = self.quit_prog
        appuifw.app.menu = [(u"Start", self.resume_reader),
                            (u"Exit", self.quit_prog)]
        Draw.__init__(self)

        self.exit_flag = False
        self.pause = False

        self.book_path = book_path
        # index of last word
        self.last_word = 0

        self.word_delay = 0.5
        self.punct_delay = self.word_delay * 2
        self.words = []

        self.timer = e32.Ao_timer()
        self.app_lock = e32.Ao_lock()
        self.app_lock.wait()
Esempio n. 12
0
    pic_mask.blit(pic, source=(32, 0, 47, 15))

except:
    pic = None
    pic_mask = None

# Global variables
canvas = None
img = None
screen_x = screen_y = 0
star_x = star_y = 0
g_papa_count = 0
g_papa = []

# Timer variables
timer_papa = e32.Ao_timer()
timer_interval = e32.Ao_timer()
g_time = 0
my_interval = 0

# Global color definitions
RGB_BLACK = (0, 0, 0)
RGB_WHITE = (255, 255, 255)
RGB_RED = (255, 0, 0)
RGB_YELLOW = (255, 255, 0)


def cb_handle_redraw(dummy=(0, 0, 0, 0)):
    ''' Overwrite default screen redraw event handler '''
    if img:
        canvas.blit(img)
Esempio n. 13
0
    def __init__(self):
        """ Get info about drives in Symbian OS """
        self.appDrive()
        self.generateDriveList()
        """ Set app info """
        self.__NAME__ = u"sypFTP"
        self.__VERSION__ = u"0.1.0"
        self.__AUTHOR__ = u"Intars Students"
        self.__EMAIL__ = u"*****@*****.**"
        self.__URL__ = u"http://code.google.com/p/sypftp/"
        self.__UPDATE__ = u"http://sypftp.googlecode.com/svn/trunk/VERSION"

        self.log_arr = []
        self.ftpd_running = False
        self.ftpd_auto = True
        self.db = u"%s\\options.db" % self.__APPDIR__
        """ Set default user options and load custom ones (if there is some) """
        self.default = {
            u"port": 21,
            u"user": u"user",
            u"pass": u"12345",
            u"dir": u"C:\\"
        }

        self.getOptions()
        """ Hook FTP server log's to main console output """
        ftpserver.log = self.log
        ftpserver.logline = self.log
        ftpserver.logerror = self.log
        """ Set look and feel of main console """
        self.uiConsole = appuifw.Text()
        self.uiPopup = globalui

        appuifw.app.title = self.__NAME__
        self.uiMenu(["connect", "options", "about", "exit"])
        appuifw.app.body = self.uiConsole
        appuifw.app.screen = "normal"
        appuifw.app.exit_key_handler = self.exit
        """ Set look and feel of options """
        self.uiOptions = appuifw.Form(
            [(u"Port", "number", self.default["port"]),
             (u"User", "text", self.default["user"]),
             (u"Paswd", "text", self.default["pass"]),
             (u"Dir.", "combo",
              (self.available_drives,
               self.available_drives.index(self.default["dir"])))],
            appuifw.FFormEditModeOnly)
        self.uiOptions.save_hook = self.saveOptions
        """ Start console output thread """
        self.console_thread = e32.Ao_timer()
        self.console_thread.after(0, self.console)
        """ Start up network (if it possible) """
        self.networking()
        """ If there is network connection, start ftp server """
        if self.getIP() != False:
            self.ftp_server_start()
        """ Start network check thread """
        self.network_thread = e32.Ao_timer()
        self.network_thread.after(10, self.network_deamon)
        """ Update thread """
        self.update_thread = e32.Ao_timer()
        """ Lock and load """
        self.app_lock = e32.Ao_lock()
        self.app_lock.wait()
Esempio n. 14
0
    def __init__(self, path):
        self.TitleName = "iniche"
        self.running = 1
        ui.app.exit_key_handler = self.exit
        # 当前选择项目的index
        self.selectedIndex = 0
        self.loading = 0
        ui.app.screen = "full"

        self.articleMenuL = [(cn("刷新"), self.refushArticle),
                             (cn("清除缓存"), self.delCache),
                             (cn("退出"), self.exit2)]
        self.mainMenu = [(cn("刷新"), self.refush), (cn("到顶部"), self.toTop),
                         (cn("到底部"), self.toBottom),
                         (cn("清除缓存"), self.delCache), (cn("退出"), self.exit2)]

        self.menuL = self.mainMenu

        self.lock = e32.Ao_lock()
        screen = ui.app.layout(ui.EScreen)[0]

        self.width = screen[0]
        self.height = screen[1]
        self.img = ph.Image.new((self.width, self.height))
        self.background = ph.Image.new((self.width, self.height))
        self.bgcolor = 0xeeeeee
        self.selectedColor = 0xbbbbbb
        self.background.clear(self.bgcolor)
        self.x = -1
        self.y = 0
        self.baseCornor = 5
        self.newsCornor = 2
        self.SlideHeight = 80
        self.SlideWidth = self.width - self.baseCornor * 2
        self.newsHeight = 60
        self.newImgHeight = self.newsHeight - self.newsCornor * 2
        self.newImgWidth = int(self.newImgHeight / 0.75)
        self.loadingImg = ph.Image.open(mypath + "image_loading.jpg").resize(
            (self.newImgWidth, self.newImgHeight))
        self.articleContent = ""
        self.maskImg = Image.new(screen, "L")
        self.maskImg.clear(0x888888)
        self.deepMaskImg = Image.new(screen, "L")
        self.deepMaskImg.clear(0x333333)

        self.newsWidth = self.width - self.baseCornor * 2
        self.SlideIndex = 0
        self.nowtime = 0
        self.__canvas = ui.Canvas(self.__redraw, self.key)
        ui.app.body = self.__canvas
        self.imgOld = Image.new(screen)
        self.startUpImg = ph.Image.open(path)
        self.img.blit(self.startUpImg)

        itnet.newImgHeight = self.newImgHeight
        itnet.newImgWidth = self.newImgWidth
        itnet.SlideHeight = self.SlideHeight
        itnet.SlideWidth = self.SlideWidth
        self.allForm = AllForm()
        self.menuIndex = 0
        self.minMenuWidth = 0
        self.menuHeight = 35
        # 是否在刷新界面
        self.isRefush = 0
        # 文章最顶部高度
        self.articleMinIndex = 5
        # 文章index
        self.articleIndex = self.articleMinIndex
        # 文章上下走动的step
        self.articleStep = 60
        self.articleMinStep = 10
        self.articleMaxIndex = self.height + self.articleStep
        self.tempImg = ph.Image.new((1, 1))
        self.menuSpeed = 40
        self.RunningForm = self.allForm.loading
        self.drawAsyncLoad(10)
        self.newsList = itnet.getNewList()
        self.SlideList = itnet.getSlide()
        self.fontSizeCache = {}
        self.slideChangeThread = e32.Ao_timer()
        #self.refushListThread = e32.Ao_timer()
        self.genMenuList()
        self.lastRunningForm = self.RunningForm
        self.lastX = self.selectedIndex - 1
        itnet.loadImg()
        self.AsyncLoad()
import sys
import e32
import appuifw
import os

start_timer = e32.Ao_timer()
screensaver_on = True

def u(x):
    return x.decode('utf8')
   
def handle_screensaver():
    global g_screensaver_on
    if screensaver_on:
        e32.reset_inactivity()
        start_timer.cancel()
        start_timer.after(4, handle_screensaver)
    else:
        start_timer.cancel()
   
def bye():
    os.abort()

def main():
    body.color = (0,0,255)
    body.set(u"\n    Your Screensaver now is disable. Do not close this application if you still want the Screensaver disable.\n\n To close this app, please select 'Close Me' from menu.\n\n  Compile by MightyGhost")
        
def help():
    body.color = (0,0,255)
    body.set(u"1. This program is used to pause the screensaver that currently active. That mean,after this program is run, the screensaver will automatically turn off.\n2. The screensaver will be off until this program is close. This mean this program need to be run in background so it will continue working.\n3. The 'Close Me' is use to close this program because the 'Exit' did'nt work.\n4. This program tested on N95-1 and maybe will work on other S60v3 or FP1 phone.\n5. This program is used with other python application that need the screensaver off.")
    body.color = (255,0,0)
Esempio n. 16
0
def testS60():
    import appuifw, key_codes
    import airbotgraphics as graphics
    import e32, e32dbm
    
    def handle_redraw(rect):
        global img
        canvas.blit(img)

    global img
    img = graphics.Image.new((480, 360))
    
    global fps, start
    start = time.time()
    fps = 0

    # create canvas
    canvas = appuifw.Canvas(redraw_callback=handle_redraw)

    appuifw.app.screen = 'full'
    appuifw.app.body=canvas

    global running
    running = True

    timer = e32.Ao_timer()
    
    def quit():
        global running
        running = False
        appuifw.app.set_exit()

    appuifw.app.exit_key_handler=quit

    def timer_callback(arg=None):
        global fps, start
        timer.after(1.0, timer_callback)
        canvas.text((0,100), u"%s fps" % (fps/(time.time()-start)))
        start=time.time()
        fps=0
        
    timer.after(1.0, timer_callback)
    def callback(frame):
        global img, fps
        fps+=1
        img=graphics.Image.from_buffer(frame)
        canvas.blit(img)

    def err_callback(camera):
        print "got error", camera.state
        time.sleep(10)
        running = False
        appuifw.app.set_exit()
    
    target = "00:22:BF:00:01:34"

    c = Camera(Socket(), callback=callback, err_callback=err_callback)
    print "connecting to", target
    c.connect((target, 1))
    asyncore.loop()
    print "loop completed"    
RGB_BLUE = (0, 0, 255)
RGB_RED = (255, 0, 0)
RGB_WHITE = (255, 255, 255)

# Global variables
running = RUN_EXIT
board = None
canvas = None
img = None
im1 = None
pic = None
pic_orig = None
animation_timer = None

my_lock = False
my_timer = e32.Ao_timer()

# Manage screensaver on/off
screen_timer = e32.Ao_timer()
g_screensaver_on = True


def cb_handle_redraw(a_rect=(0, 0, 0, 0)):
    ''' Overwrite default screen redraw event handler '''
    if img:
        canvas.blit(img)


def cb_focus(fg):
    ''' System callback to tell when focus is lost/regained '''
    global g_screensaver_on
Esempio n. 18
0
        def initialize(self):

            if self.debug_ui:
                debug_skins = ['sword', 'lightsaber']
                self.__progress_per_skin_section = 1.0 / (len(debug_skins) *
                                                          19)
                self.__load_skins(self.__SKINS_PATH, debug_skins)
                return

            # Check to see if skins directory exists
            if not os.path.exists(self.__SKINS_PATH):
                log("No skin directory found\n\nYou must download at least one skin to this phone"
                    )
                return False

            # Create the canvas
            appuifw.app.orientation = 'portrait'
            appuifw.app.screen = 'large'
            self.__canvas = appuifw.Canvas(
                redraw_callback=self.__handle_redraw,
                event_callback=self.__handle_event)
            appuifw.app.body = self.__canvas

            # Create an offscreen buffer - draw onto this in the __handle_redraw method and then blit onto the main canvas
            self.__buffer = graphics.Image.new(self.__canvas.size)

            # Show the loading image
            self.__loading_image = self.__load_image(self.__DATA_PATH +
                                                     "loading_image.png")
            self.__buffer.blit(self.__loading_image)
            self.__canvas.blit(self.__buffer)

            # Check the skins directory and get the subdirs
            skinsArray = os.listdir(self.__SKINS_PATH)
            numSkins = len(skinsArray)

            # We need at least one directory in the skins path, so check and proceed if there is one
            if 0 == numSkins:
                log("No skins found.  You might need to reinstall, or alternatively put some skins in the e:\data\phonefight\skins directory"
                    )
                return False

            # Initialize some vars for the loading bar
            self.__progress_per_skin_section = 1.0 / (
                19 * numSkins)  # There are 17 different sections for skins

            self.__load_skins(self.__SKINS_PATH, skinsArray)

            # Initialize the ui to be the first skin in the SKINS array
            self.__skin = self.SKINS[0]
            log("Initial skin set to : " + self.__skin["skinName"])

            # Make sure that the background gets drawn immediately
            self.__handle_redraw(None)

            # Start the refresh timer
            self.__timer = e32.Ao_timer()
            self.__timer.after(UI.__FRAME_INTERVAL, self.__update_ui)

            # If we get here, we have initialized properly
            self.__initialized = True
            return True
 def change():
     c = self.canvas.current()
     if self.cur_tab == 0:
         if c == 0:
             r = appuifw.query(self.options[c].title, 'float',
                               self.options[c].value)
             if r != None:
                 if (0 <= r < 1.5):
                     self.options[c].value = r
                 else:
                     appuifw.note(
                         u('Скорость должна быть в пределах:\n0<=v<1.5'
                           ), 'error')
         elif c == 1:
             r = appuifw.query(self.options[c].title, 'number',
                               self.options[c].value)
             if r != None:
                 if (4 <= r <= 20) and (r % 2 == 0):
                     self.options[c].value = r
                 else:
                     appuifw.note(
                         u('Ширина должна быть четной и в пределах:\n4<=x<=20'
                           ), 'error')
         elif c == 2:
             r = appuifw.query(self.options[c].title, 'number',
                               self.options[c].value)
             if r != None:
                 if (4 <= r <= 20) and (r % 2 == 0):
                     self.options[c].value = r
                 else:
                     appuifw.note(
                         u('Длина должна быть четной и в пределах:\n4<=y<=20'
                           ), 'error')
         elif c == 3:
             r = appuifw.query(self.options[c].title, 'number',
                               self.options[c].value)
             if r != None:
                 if (4 <= r <= 20):
                     self.options[c].value = r
                 else:
                     appuifw.note(
                         u('Глубина должна быть в пределах:\n4<=z<=20'),
                         'error')
     elif self.cur_tab == 1:
         appuifw.app.body = appuifw.Canvas(event_callback=catch_key)
         appuifw.app.body.clear(0)
         appuifw.app.body.text((5, 40),
                               u('Нажми клавишу для:'),
                               fill=0x00ff00)
         appuifw.app.body.text((40, 80),
                               self.keyopt[c].title,
                               fill=0xff0000)
         appuifw.app.body.text((5, 120),
                               u('(не софткей и красную кнопку)'),
                               fill=0x00ff00)
         appuifw.app.body.text((5, 160),
                               u('Очистка через 3 секунды'),
                               fill=0x00ff00)
         appuifw.app.set_tabs([], None)
         self.options[c].value = 0
         self.timer = e32.Ao_timer()
         self.timer.after(3, self.lock2.signal)
         self.lock2.wait()
         self.timer.cancel()
         appuifw.app.body = self.canvas
         appuifw.app.set_tabs(
             [u('Игра'), u('Управление'),
              u('Экран')], tab_cb)
         appuifw.app.activate_tab(self.cur_tab)
     elif self.cur_tab == 2:
         if c == 0:
             orients = ['automatic', 'portrait', 'landscape']
             r = appuifw.popup_menu([u(i) for i in self.options[c].lst],
                                    self.options[c].title)
             if r != None:
                 try:
                     appuifw.app.orientation = orients[r]
                     self.options[c].value = r
                 except:
                     appuifw.note(
                         u('Смартфон не поддерживает смену ориентации!'
                           ), 'error')
         elif c == 1:
             r = appuifw.query(self.options[c].title, 'number',
                               self.options[c].value)
             if r != None:
                 if (0 <= r <= 255):
                     self.options[c].value = r
                 else:
                     appuifw.note(
                         u('Непрозрчачность должна быть в пределах от 0 до 255'
                           ), 'error')
     self.needsave = 1
     self.canvas.set_list([(opt.title, u(opt.f(opt)))
                           for opt in self.options], c)
Esempio n. 20
0
RGB_VIOLET = (153, 0, 153)
RGB_WHITE = (255, 255, 255)
my_colors = [
    RGB_BLACK, RGB_RED, RGB_GREEN, RGB_BLUE, RGB_ORANGE, RGB_VIOLET,
    RGB_YELLOW, RGB_WHITE
]
g_colors = len(my_colors) - 1

# Global variables
running = RUN_EXIT
board = None
canvas = None
img = None
user_set = None

my_timer = e32.Ao_timer()
g_screensaver_off = False
timer_screen = e32.Ao_timer()

# SENSOR: if exception, it's not available in this device
SENSOR_ACC = False
try:
    import sensor
    from sensor import orientation
    SENSOR = True  # Sensor interface available
except ImportError:
    SENSOR = False  # Sensor interface not available


def handle_orientation(a_data):
    ''' My own handler for accelerator events '''
Esempio n. 21
0
 def test_Ao_timer(self):
     timer = e32.Ao_timer()
     timer.after(sleep_time, self.call_modify_test_data)
     # sleep for an extra second to avoid a race condition
     e32.ao_sleep(sleep_time + 1)
     self.failUnlessEqual(self.test_data, changed_val)
Esempio n. 22
0
def pasek():
    global screen
    global img
    global ekran
    global mp3
    global ladow
    while 1:
        e32.Ao_timer().after(1)
        (rok, mies, dz, godz, min, sek, x, x, x) = time.localtime()
        godz = '%02d' % (godz)
        min = '%02d' % (min)
        sek = '%02d' % (sek)
        if (godz == ustaw[51:53]) and (min == ustaw[53:55]) and (
                sek == '00') and (pb <> 'None'):
            e32.reset_inactivity()
            try:
                appuifw.e32.start_exe(
                    u'c:\\sys\\bin\\' + unicode(pb) + u'.exe', '')
            except:
                try:
                    appuifw.e32.start_exe(
                        u'e:\\sys\\bin\\' + unicode(pb) + u'.exe', '')
                except:
                    try:
                        appuifw.e32.start_exe(
                            u'z:\\sys\\bin\\' + unicode(pb) + u'.exe', '')
                    except:
                        pass
        try:
            if (int(ustaw[36:39]) <> 0) and (sysinfo.active_profile() <>
                                             u'silent'):
                if ((int(min) == 0) and (int(sek) == 0)
                        or (int(sysinfo.battery()) == 100) and (ladow > 0)):
                    if (int(sysinfo.battery()) == 100) and (ladow > 0):
                        ladow = 0
                    if os.path.isdir(sciezkaplik):
                        if (int(min) == 0) and (int(sek) == 0):
                            mp3 = audio.Sound.open(
                                unicode(sciezkaplik + '\\' + str(godz) +
                                        '.mp3'))
                        else:
                            mp3 = audio.Sound.open(
                                unicode(sciezkaplik + '\\' + '24.mp3'))
                    else:
                        mp3 = audio.Sound.open(unicode(sciezkaplik))
                    if (int(ustaw[39:42]) < int(ustaw[42:45])) and (
                            int(godz) >= int(ustaw[39:42])) and (
                                int(godz) <= int(ustaw[42:45])):
                        mp3.play()
                    elif (int(ustaw[39:42]) > int(ustaw[42:45])) and (
                        (int(godz) >= int(ustaw[39:42])) or
                        (int(godz) <= int(ustaw[42:45]))):
                        mp3.play()
                    elif int(godz) == int(ustaw[39:42]):
                        mp3.play()
                    audio.Sound.set_volume(
                        mp3,
                        int(
                            audio.Sound.max_volume(mp3) *
                            (float(int(ustaw[36:39])) / float(100))))
            if audio.Sound.state(mp3) <> 2: mp3 = 0
            if (int(min) == 0) and (int(sek) == 0):
                if (int(ustaw[39:42]) < int(ustaw[42:45])) and (
                        int(godz) >= int(ustaw[39:42])) and (int(godz) <= int(
                            ustaw[42:45])):
                    miso.vibrate(500, 100)
                elif (int(ustaw[39:42]) > int(ustaw[42:45])) and (
                    (int(godz) >= int(ustaw[39:42])) or
                    (int(godz) <= int(ustaw[42:45]))):
                    miso.vibrate(500, 100)
                elif int(godz) == int(ustaw[39:42]):
                    miso.vibrate(500, 100)
        except:
            pass
        if int(ustaw[18:21]) == 888:
            img.blit(ima, ((0, 0), (int(ustaw[0:3]), int(ustaw[3:6]))))
        else:
            img.rectangle(
                [(0, 0), (int(ustaw[0:3]), int(ustaw[3:6]))],
                (int(ustaw[18:21]), int(ustaw[21:24]), int(ustaw[24:27])),
                fill=(int(ustaw[18:21]), int(ustaw[21:24]), int(ustaw[24:27])))
        if pb <> 'None':
            img.line([(0, 0), (0, int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), 0),
                      (-1 + int(ustaw[0:3]), int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if fpp[int(ustaw[56:57])] <> 'None':
            img.line([(0, 0), (0, 4)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(0, 0), (4, 0)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), 0), (-1 + int(ustaw[0:3]), 4)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), 0),
                      (-1 - 4 + int(ustaw[0:3]), 0)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), -1 + int(ustaw[3:6])),
                      (-1 - 4 + int(ustaw[0:3]), -1 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(-1 + int(ustaw[0:3]), -1 + int(ustaw[3:6])),
                      (-1 + int(ustaw[0:3]), -1 - 4 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(0, -1 + int(ustaw[3:6])),
                      (0, -1 - 4 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            img.line([(0, -1 + int(ustaw[3:6])), (4, -1 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if ekran > 0:
            e32.reset_inactivity()
            img.line([(0, -1 + int(ustaw[3:6])),
                      (int(ustaw[0:3]), -1 + int(ustaw[3:6]))],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if ladow > 0:
            img.line([(0, 0), (int(ustaw[0:3]), 0)],
                     (int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
        if int(ustaw[45:48]) / 10 > 0:
            if int(ustaw[45:48]) / 10 == 1:
                k = unicode(str(godz) + ':' + str(min) + ':' + str(sek))
            elif int(ustaw[45:48]) / 10 == 2:
                k = unicode('%02i' % (dz) + '.' + '%02i' % (mies) + '.' +
                            str(rok))
            elif int(ustaw[45:48]) / 10 == 3:
                k = unicode('%06.3f' %
                            (float(sysinfo.free_ram()) / float(1000000)))
            elif int(ustaw[45:48]) / 10 == 4:
                k = unicode('%03i' % (sysinfo.signal_dbm()) + ' dBm')
            elif int(ustaw[45:48]) / 10 == 5:
                k = unicode('%03i' % (sysinfo.battery()) + ' %')
            if int(ustaw[45:48]) % 10 == 1:
                q = (None, None, graphics.FONT_BOLD | graphics.FONT_ANTIALIAS)
            elif int(ustaw[45:48]) % 10 == 2:
                q = (None, None,
                     graphics.FONT_ITALIC | graphics.FONT_ANTIALIAS)
            elif int(ustaw[45:48]) % 10 == 3:
                q = (None, None, graphics.FONT_BOLD | graphics.FONT_ITALIC
                     | graphics.FONT_ANTIALIAS)
            else:
                q = (None, None, graphics.FONT_ANTIALIAS)
            img.text(
                (int(ustaw[12:15]), int(ustaw[15:18])),
                k,
                font=q,
                fill=(int(ustaw[27:30]), int(ustaw[30:33]), int(ustaw[33:36])))
            screen.background_color = 0xffffff
        else:
            screen.hide()
Esempio n. 23
0
def start():
    global running
    t1 = mysets[0]
    t2 = mysets[1]
    if label1:
        n = 0
        sx = [0, 30, 60, 90, 120, 150, 180, 210, 240, 70]
        sy = [280, 360, 100, 350, 280, 150, 220, 340, 300, 270]
        for i in range(97):
            n += 1
            if n < 33:
                g = 1
            elif 32 < n < 65:
                g = 2
            elif 64 < n < 97:
                g = 1
            elif 96 < n < 129:
                g = 2
            elif 128 < n < 161:
                g = 1
            if g == 1:
                sx[0] += 1
                sy[0] -= 5
                sx[1] -= 1
                sy[1] -= 3
                sx[2] += 1
                sy[2] -= 2
                sx[3] -= 1
                sy[3] -= 1
                sx[4] += 1
                sy[4] -= 3.8
                sx[5] -= 1
                sy[5] -= 2.5
                sx[6] += 1
                sy[6] -= 3.5
                sx[7] -= 1
                sy[7] -= 1.5
                sx[8] += 1
                sy[8] -= 5
                sx[9] -= 1
                sy[9] -= 2.2
            else:
                sx[0] -= 1
                sy[0] -= 5
                sx[1] += 1
                sy[1] -= 3
                sx[2] -= 1
                sy[2] -= 2
                sx[3] += 1
                sy[3] -= 1
                sx[4] -= 1
                sy[4] -= 3.8
                sx[5] += 1
                sy[5] -= 2.5
                sx[6] -= 1
                sy[6] -= 3.5
                sx[7] += 1
                sy[7] -= 1.5
                sx[8] -= 1
                sy[8] -= 5
                sx[9] += 1
                sy[9] -= 2.2

            window1.position = (sx[0], sy[0])
            window2.position = (sx[1], sy[1])
            window3.position = (sx[2], sy[2])
            window4.position = (sx[3], sy[3])
            window5.position = (sx[4], sy[4])
            window6.position = (sx[5], sy[5])
            window7.position = (sx[6], sy[6])
            window8.position = (sx[7], sy[7])
            window9.position = (sx[8], sy[8])
            window10.position = (sx[9], sy[9])
            window1.show()
            window2.show()
            window3.show()
            window4.show()
            window5.show()
            window6.show()
            window7.show()
            window8.show()
            window9.show()
            window10.show()
            e32.Ao_timer().after(t1)
    if label2:
        n = 0
        sx = [-160, -80, 0, 60, 120, -120, -60, 0, 60, 120]
        sy = [0, 0, 0, 0, 0, -60, -60, -60, -60, -60]
        for i in range(140):
            n += 1
            sx[0] += 2
            sy[0] += 2
            sx[1] += 1
            sy[1] += 1
            sx[2] += 2
            sy[2] += 2
            sx[3] += 1
            sy[3] += 1
            sx[4] += 3.5
            sy[4] += 3.5
            sx[5] += 2
            sy[5] += 2
            sx[6] += 3
            sy[6] += 3
            sx[7] += 3.5
            sy[7] += 3
            sx[8] += 4
            sy[8] += 4
            sx[9] += 2
            sy[9] += 2
            window1.position = (sx[0], sy[0])
            window2.position = (sx[1], sy[1])
            window3.position = (sx[2], sy[2])
            window4.position = (sx[3], sy[3])
            window5.position = (sx[4], sy[4])
            window6.position = (sx[5], sy[5])
            window7.position = (sx[6], sy[6])
            window8.position = (sx[7], sy[7])
            window9.position = (sx[8], sy[8])
            window10.position = (sx[9], sy[9])
            window1.show()
            window2.show()
            window3.show()
            window4.show()
            window5.show()
            window6.show()
            window7.show()
            window8.show()
            window9.show()
            window10.show()
            e32.Ao_timer().after(t2)
    if running:
        start()
    else:
        window1.hide()
        window2.hide()
        window3.hide()
        window4.hide()
        window5.hide()
        window6.hide()
        window7.hide()
        window8.hide()
        window9.hide()
        window10.hide()
Esempio n. 24
0
# 2008 01 22 - 3.0 fixed stack overflow problem(s), cleaned up some
#            code, improved response time of piano(). - William F. Dudley Jr.
# 2008 01 22 - 3.1 piano tweak, slight speed increase - SL


import appuifw
from graphics import *
import e32
from key_codes import *
import os
import audio
import time
import random
import sysinfo

timer = e32.Ao_timer()
app_lock = e32.Ao_lock()

class Keyboard(object):
    def __init__(self,onevent=lambda:None):
        self._keyboard_state={}
        self._downs={}
        self._onevent=onevent
	self.last_key = None
    def handle_event(self,event):
        if event['type'] == appuifw.EEventKeyDown:
            code=event['scancode']
	    self.last_key = code
            if not self.is_down(code):
                self._downs[code]=self._downs.get(code,0)+1
            self._keyboard_state[code]=1
Esempio n. 25
0
 def test_timer_cancel(self):
     timer = e32.Ao_timer()
     timer.after(sleep_time, self.call_modify_test_data)
     timer.cancel()
     e32.ao_sleep(sleep_time + 1)
     self.failIfEqual(self.test_data, changed_val)
Esempio n. 26
0
class MobilApp:
    """MyApp class doc string"""
    app_lock = e32.Ao_lock()
    timer = e32.Ao_timer()

    def __init__(self):
        self.old_title = app.title
        self.old_screen = app.screen
        self.old_menu = app.menu
        self.old_exit_key_handler = app.exit_key_handler

        self.s = None  # not connected yet

        self.startup()

    def connect(self, addr, channel):
        """ Connects to a remote device on selected channel. """
        import socket
        try:
            self.s = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
            self.s.connect((addr, channel))
            return True
        except:
            return False

    def close_connection(self):
        """ Disconnect from remote device if it is connected. """
        if self.s:
            self.s.close()
            self.s = None
            return True
        else:
            return False

    def startup(self):
        return

    def shutdown(self):
        return

    def handle_keyboard_splash(self, event):
        self.app_lock.signal()

    def show_splash(self, filename, timeout=0):
        img = Image.open(filename)
        old_screen = app.screen
        old_body = app.body
        app.screen = 'full'
        if timeout == 0:
            app.body = Canvas(event_callback=self.handle_keyboard_splash)
        else:
            app.body = Canvas()

        app.body.clear(0)
        app.body.blit(img)

        e32.ao_yield()

        if timeout == 0:
            self.app_lock.wait()
        else:
            self.timer.after(timeout)

        app.screen = old_screen
        app.body = old_body

    def exit_key_handler(self):
        app.exit_key_handler = None
        self.app_lock.signal()

    def run(self):
        app.exit_key_handler = self.exit_key_handler
        self.app_lock.wait()
        self.shutdown()
        app.title = self.old_title
        app.screen = self.old_screen
        app.menu = self.old_menu
        app.exit_key_handler = self.old_exit_key_handler
Esempio n. 27
0
# Settings file
FILE_SET = FILE_PATH + u"nixie.set"

# Hardcoded image resolution
XX = YY = 100

RGB_RED = (255, 0, 0)
RGB_BLACK = (0, 0, 0)

# Global variables
canvas = None
img = None
m = None

# Create timers
t_timer = e32.Ao_timer()
t_screen = e32.Ao_timer()


#############################################################
def cb_focus(fg):
    ''' System callback when focus is lost/regained '''
    if fg:
        # Got focus
        t_screen.cancel()
        t_timer.cancel()
        handle_screensaver()
        draw_time()
    else:
        # Lost focus
        t_timer.cancel()
 def __init__(self, methodName='runTest'):
     unittest.TestCase.__init__(self, methodName=methodName)
     self.lock = e32.Ao_lock()
     self.timer = e32.Ao_timer()
     self.async_request_failed = False
Esempio n. 29
0
 def __init__(self, methodName='runTest'):
     unittest.TestCase.__init__(self, methodName=methodName)
     self.lock = e32.Ao_lock()
     self.timer = e32.Ao_timer()
AICHAL = 2
AIlEXIT = 0
AIlIDLE = 1
AIlPLAY = 2
AIlHARD = 4
AIlWAIT = 8
AIlPAUS = 16
AIlDONE = 32
oo0000 = AIlIDLE
fc_run = AIlEXIT
w_run = []
_oO00 = None
nm = None
mn = None
user_set = None
mnm = e32.Ao_timer()
nmn = e32.Ao_timer()
g_ignore = False
g_oo0000 = 0
T_LEFT = 1
T_RIGHT = 2
T_TOP = 1


def ooo():
    if (oo0000 != AIlPLAY):
        return
    e32.reset_inactivity()
    nmn.after(4, ooo)