Esempio n. 1
0
 def __init__(self,init_dir = ""):       
     self.lock = e32.Ao_lock()
     app.title = u"Explorer demo"
     app.screen = "full"
     self.show_images = True        
     app.menu = [(u"Hide images", lambda: self.images_menu(False)),
                 (u"About", self.about),
                 (u"Quit", self.close_app)]
     self.cur_dir = unicode(init_dir)
     if not os.path.exists(self.cur_dir):
         self.cur_dir = u""
     self.fill_items()
     
     pos = (0,0) + sysinfo.display_pixels()
     self.listbox = CanvasListBox(items=self.items,
                                  cbk=self.item_selected,
                                  images=self.images,
                                  position=pos,
                                  margins=[6,2,2,2],
                                  selection_border_color=(124,104,238),
                                  image_size=(44,44),
                                  title=self.cur_dir)
     
     app.body = self.listbox
     self.lock.wait()
Esempio n. 2
0
    def sendSysinfo(self,  full):
        self.send(NUM_SYSINFO_REPLY_START)
        self.send(NUM_SYSINFO_REPLY_LINE, "program_version", VERSION)
        self.send(NUM_SYSINFO_REPLY_LINE, "battery", sysinfo.battery())
        self.send(NUM_SYSINFO_REPLY_LINE, "active_profile", sysinfo.active_profile())
        self.send(NUM_SYSINFO_REPLY_LINE, "free_ram", sysinfo.free_ram())
        self.send(NUM_SYSINFO_REPLY_LINE, "pys60_version", e32.pys60_version)

        if sysinfo.active_profile() == u"offline":
            # Return an error code if the phone is in offline mode
            self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", -1)
            self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", -1)
        else:
            self.send(NUM_SYSINFO_REPLY_LINE, "signal_dbm", sysinfo.signal_dbm())
            self.send(NUM_SYSINFO_REPLY_LINE, "signal_bars", sysinfo.signal_bars())

        for drive,  free in sysinfo.free_drivespace().iteritems():
            self.send(NUM_SYSINFO_REPLY_LINE, "free_drivespace", str(drive) + str(free))

        if full:
            self.send(NUM_SYSINFO_REPLY_LINE, "display", str(sysinfo.display_pixels()[0]) + "x" + str(sysinfo.display_pixels()[1]))
            self.send(NUM_SYSINFO_REPLY_LINE, "imei", sysinfo.imei())
            self.send(NUM_SYSINFO_REPLY_LINE, "model", sysinfo.sw_version())
            self.send(NUM_SYSINFO_REPLY_LINE, "s60_version", e32.s60_version_info[0],  e32.s60_version_info[1] )
            self.send(NUM_SYSINFO_REPLY_LINE, "total_ram", sysinfo.total_ram())
            self.send(NUM_SYSINFO_REPLY_LINE, "total_rom", sysinfo.total_rom())

        self.send(NUM_SYSINFO_REPLY_END)
Esempio n. 3
0
def screen_resize():
 global screen_height,color_height,screen_height_coef
 screen_height=sysinfo.display_pixels()[1]
# screen_width=sysinfo.display_pixels()[0]
# screen_height=128+font_height*6
 left=screen_height-font_height*6
 screen_height_coef=(left/256.0,divmod(left,256)[0])[left>256]
 color_height=int(256*screen_height_coef)
Esempio n. 4
0
    def __init__(self):
      # app title
      appuifw.app.title = u"Sissi"

      # app lock
      self.lock = e32.Ao_lock()

      # ensure data dir exists
      self.datadir = os.path.join(u"C:\\Data", u"Sissi")
      if not os.path.exists(self.datadir):
        os.makedirs(self.datadir)

      # create a directory for temporary data
      self.cachedir = u"D:\\Sissi"
      if not os.path.exists(self.cachedir):
        os.makedirs(self.cachedir)

      # get screen resolution
      self.screen = sysinfo.display_pixels()

      # extra classes instantiated
      self.scanner = Scanner(self)
      self.netmapper = NetMapper(self)
      self.map = Map(self)
      self.cos_api = COSApi(self)

      # timer
      self.t = e32.Ao_timer()
      self.active = False

      # set canvas
      self.activate()
      
      # configuration / settings
      self.draw_screen('reading config')
      self.config_file = os.path.join(self.datadir, "settings.ini")
      self.config = {} # TODO: read these from a configuration file
      self.apid = None # Default access point
      self.read_config()
      if self.config.has_key("apid"):
        self._select_access_point(self.config["apid"])

      # set extra handler to be called on each GPS loop
      self.scanner.set_extra_handler(self.loop)

      # update our menu
      self._update_menu()
      self.draw_screen('ready!')
#        self.debug(self.screen)
      self.scanner_handler() # start scanning automatically

      # set exit key handler
      appuifw.app.exit_key_handler = self.exit_key_handler
Esempio n. 5
0
 def __init__(self):       
     self.lock = e32.Ao_lock()
     app.title = u"Scribble"
     app.screen = "full_max"
     self.maintb = None
     self.ticktb = None
     self.colortb = None
     self.line_colors = [(0,0,255),(0,128,0),(255,255,0),
                         (255,255,255),(255,0,0)]
     self.line_color = 0
     self.line_ticks = [1,3,6]
     self.line_tick = 0
     self.prev_x = 0
     self.prev_y = 0
     self.saving = False
     self.drag_started = False
     self.load_imgs()
     sz = max(sysinfo.display_pixels())
     self.drw_buf = graphics.Image.new((sz,sz))
     self.scr_buf = graphics.Image.new((sz,sz))
     self.drw_buf.clear((255,255,255))
     self.canvas = Canvas(redraw_callback=self.redraw,
                          event_callback=self.event)
     self.maintb = ctoolbar.CanvasToolbar(self.scr_buf,
                                          self.maintb_selected,
                                          self.redraw,
                                          self.maintb_imgs,
                                          (0,0),
                                          (200,200,200),
                                          transparency=20)
     self.ticktb = ctoolbar.CanvasToolbar(self.scr_buf,
                                          self.ticktb_selected,
                                          self.redraw,
                                          self.ticktb_imgs,
                                          (54,97),
                                          (200,200,200),
                                          orientation=ctoolbar.O_HORIZONTAL,
                                          transparency=20)
     self.colortb = ctoolbar.CanvasToolbar(self.scr_buf,
                                           self.colortb_selected,
                                           self.redraw,
                                           self.colortb_imgs,
                                           (54,145),
                                           (200,200,200),
                                           orientation=ctoolbar.O_HORIZONTAL,
                                           transparency=20)
     app.body = self.canvas
     app.menu = []
     self.maintb.show()
     self.lock.wait()
Esempio n. 6
0
 def __init__(self, start=0, end=100, color=(0,0,77),
              fill=(255,255,200), outline=(0,0,0)):
     screen_size = display_pixels()
     #sizes & positions
     self.height = 60
     self.width = int(screen_size[0] * 0.8)
     self.top = (screen_size[1] - self.height)/2
     self.left = int((screen_size[0] - self.width) / 2)
     #ProgressBar size
     self.progress_margin = 5
     self.progress_w = self.width - (2 * self.progress_margin)
     self.progress_h = 18 #height of progressbar
     self.progress_l = self.progress_margin
     self.progress_t = self.height - self.progress_h - \
                       self.progress_margin
     #internal progressbar expects that external has 1px border
     self.internal_w_max = self.progress_w - 2
     self.internal_h = self.progress_h - 2
     self.internal_l = self.progress_l + 1
     self.internal_t = self.progress_t + 1
     self.internal_w = 0
     self.glow_h = int(self.internal_h / 2)
     #colors & values
     self.start = start
     self.end = end
     self.value = start
     self.color = color
     self.glow_color = self.color_combine(color, (255,255,255), 0.5)
     self.outline = outline
     self.fill = fill
     #text attributes
     self.caption = u""
     self.font = (u"dense", 12, FONT_ANTIALIAS)
     self.text_top = self.progress_t - \
                     self.progress_margin - \
                     self.font[1]
     #create topwindow
     self.window = TopWindow()
     self.window.corner_type = 'square'
     self.window.position = (self.left, self.top)
     self.window.size = (self.width, self.height)
     self.canvas = Image.new(self.window.size)
     self.window.add_image(self.canvas,(0,0,self.width,self.height))
     #shows initial progressbar
     self.redraw()
     self.window.show()
Esempio n. 7
0
def ShowStartFrame():
    _screenW , _screenH = sysinfo.display_pixels()  #获取屏幕宽/高
    try:
        try:
            _imgstart = graphics.Image.open(r"C:\python\images\KumReader_start.jpg")
        except SymbianError:
            _imgstart = graphics.Image.open(r"D:\python\images\KumReader_start.jpg")
    except:
        appuifw.note(cn("应用程序已损坏,请重新安装!\nError:401"), "error")
        appuifw.app.set_exit()
        
    screen = topwindow.TopWindow()
    screen.add_image(_imgstart, (0, 0, _screenW, _screenH))
    screen.size = (_screenW, _screenH)
    screen.show()
    e32.ao_sleep(2)
    screen.hide()
Esempio n. 8
0
 def __init__(self,cbk):
     """
     """
     self.blog_uri = BLOG.curr_blog["blog"]
     self.api_key = BLOG.curr_blog["api_key"]
     self.proxy = BLOG.proxy
     self.max_days = 365
     self.stats = {"daily"  :{"data":[],"title":LABELS.loc.ws_info_daily},
                   "weekly" :{"data":[],"title":LABELS.loc.ws_info_weekly},
                   "monthly":{"data":[],"title":LABELS.loc.ws_info_monthly},
                   "current":"daily"}
     self.wps = WPStats(self.api_key,self.blog_uri,max_days=self.max_days,proxy=self.proxy)
     self.scr_buf = None
     self.toolbar = None
     app.screen = 'normal'
     self.body = Canvas(redraw_callback = self.stats_canvas_redraw,
                        event_callback = self.stats_event,
                        resize_callback = self.stats_resize)
     # alloc maximum size, avoiding new allocation when resizing
     sz = max(sysinfo.display_pixels())
     self.scr_buf = graphics.Image.new((sz,sz))
     if sz < 400:
         # create small graphics for tiny screens
         self.SRD = 2
         self.SLW = 2
     if not TOUCH_ENABLED:
         self.body.bind(key_codes.EKeyLeftArrow,self.key_left)
         self.body.bind(key_codes.EKeyRightArrow,self.key_right)
         self.body.bind(key_codes.EKeySelect,self.key_sel)
         self.body.bind(key_codes.EKeyUpArrow,self.key_up)
         self.body.bind(key_codes.EKeyDownArrow,self.key_down)
     self.tooltip = InfoPopup()
     self.font = ('dense',16,graphics.FONT_ANTIALIAS)
     self.set_new_data(self.stats[self.stats["current"]]["title"],
                       self.stats[self.stats["current"]]["data"])
     self.create_toolbar(sz < 400)
     self.menu = [(LABELS.loc.ws_menu_updt,self.update_stats),
                  (LABELS.loc.ws_menu_views,(
                      (LABELS.loc.ws_menu_daily,lambda: self.set_view('daily')),
                      (LABELS.loc.ws_menu_weekly,lambda: self.set_view('weekly')),
                      (LABELS.loc.ws_menu_monthly,lambda: self.set_view('monthly')))),
                  (LABELS.loc.ws_menu_exit,self.close_app)]
     Dialog.__init__(self,cbk,LABELS.loc.wm_menu_stat,self.body,self.menu)
     Dialog.refresh(self)
Esempio n. 9
0
    def run(self):
        if sys.platform == 'symbian_s60':
            img_share = os.path.join(sys.prefix, 'share\\medcalc', self.fname)
        else:
            img_share = os.path.join(os.getcwdu(), 'img', self.fname)
        appuifw.app.screen = 'full'
        img1 = graphics.Image.open(img_share)
        w, h = sysinfo.display_pixels()
        if w > h:
            img1 = img1.transpose(graphics.ROTATE_270)

        def handle_redraw(rect):
            canvas.blit(img1)

        canvas = appuifw.Canvas(redraw_callback=handle_redraw)
        try:
            canvas.blit(img1)
            appuifw.app.body = canvas
        except:
            appuifw.note(u"Error %s" % img_share, "note")
Esempio n. 10
0
 def __init__(self):
     """
     """
     self.update_in_progress = False
     if not self.load():
         self.api_key = u"api_key"
         self.blog_uri = u"http://blog_name.wordpress.com"
         self.max_days = 365
         self.stats = {"daily"  :{"data":[],"title":u"Blog views per day"},
                       "weekly" :{"data":[],"title":u"Blog views per week"},
                       "monthly":{"data":[],"title":u"Blog views per month"},
                       "current":"daily"}
     self.dlg = None
     self.wps = WPStats(self.api_key,self.blog_uri,max_days=self.max_days)
     self.scr_buf = None
     self.toolbar = None
     app.screen = 'full'
     app.directional_pad = False
     self.body = Canvas(redraw_callback = self.stats_canvas_redraw,
                        event_callback = self.stats_event,
                        resize_callback = self.stats_resize)
     # alloc maximum size, avoiding new allocation when resizing
     sz = max(sysinfo.display_pixels())
     self.scr_buf = graphics.Image.new((sz,sz))
     if sz < 400:
         # create small graphics for tiny screens
         self.SRD = 2
         self.SLW = 2
     self.body.bind(key_codes.EKeyLeftArrow,self.key_left)
     self.body.bind(key_codes.EKeyRightArrow,self.key_right)
     self.body.bind(key_codes.EKeySelect,self.key_sel)
     self.body.bind(key_codes.EKeyUpArrow,self.key_up)
     self.body.bind(key_codes.EKeyDownArrow,self.key_down)
     self.tooltip = InfoPopup()
     self.font = ('dense',16,graphics.FONT_ANTIALIAS)
     self.set_new_data(self.stats[self.stats["current"]]["title"],
                       self.stats[self.stats["current"]]["data"])
     self.create_toolbar(sz < 400)
     Application.__init__(self,u"WP Stats",self.body)
Esempio n. 11
0
    def __init__(self, app):
        """

        +   ``query`` -- search query, a list of digits stored as
            unicode strings.
        +   ``canvas`` -- screen.
        +   ``results`` -- list of search results.
        +   ``shown_count`` -- how many items are shown.
        +   ``results_count`` -- how many items matches query.
        +   ``result_shown`` -- which result is shown now. (None, if none.)

        """

        self.query = []
        self.query_match = -1
        self.screen_w, self.screen_h = sysinfo.display_pixels()
        self.app = app
        self.canvas = appuifw.Canvas(
                event_callback=self.handle_event,
                redraw_callback=self.handle_redraw,
                )
        self.app.body = self.canvas
        self.canvas.dictionary = self

        self.results = []
        self.active_result = None

        self.key_numbers = dict([
            (getattr(key_codes, 'EScancode' + str(i)), unicode(i))
            for i in range(10)
            ])

        self.dictionaries = []
        for file_name in os.listdir(DICTS_DIR):
            self.dictionaries.append(
                    (file_name, Dict(os.path.join(DICTS_DIR, file_name))))
        self.active_dictionary = 0
Esempio n. 12
0
 def __init__(self):       
     self.lock = e32.Ao_lock()
     app.title = u"ToolbarDemo"
     app.screen = "full"
     self.toolbar = None
     self.drag_filter_cnt = 0
     self.load_imgs()
     sz = max(sysinfo.display_pixels())
     self.scr_buf = graphics.Image.new((sz,sz))        
     self.canvas = Canvas(redraw_callback=self.redraw,
                          event_callback=self.event)
     self.toolbar = ctoolbar.CanvasToolbar(self.scr_buf,
                                           self.item_selected,
                                           self.redraw,
                                           self.imgs)
                                           #orientation=ctoolbar.O_HORIZONTAL)
     app.body = self.canvas
     app.menu = [(u"Show toolbar", lambda: self.toolbar.show()),
                 (u"Hide toolbar", lambda: self.toolbar.hide()),
                 (u"Help", self.help),
                 (u"About", self.about),
                 (u"Quit", self.close_app)]
     self.toolbar.show()
     self.lock.wait()
Esempio n. 13
0
def tWrap(t,w=None,f=("normal",15)):
    import graphics
    import sysinfo
    if w==None:
        w=sysinfo.display_pixels()[0]
    img=graphics.screenshot()
    mt=lambda x,s=f,m=-1:\
    img.measure_text(x,font=s,maxwidth=m)
    t=t.replace("\r\n","\n").replace("\r","\n").split("\n")
    (sub,length)=([],0)
    for i in xrange(len(t)):
        if t[i]=="\n" or mt(t[i])[1]<=w:
            sub.append(t[i])
            continue
        while True:
            st=t[i][:mt(t[i],m=w)[2]-length]
            if mt(st,m=w)[1]<=w:
                sub.append(st)
                t[i]=t[i][len(st):]
                length=0
                if not t[i]:break
            else:length+=1
    del graphics,sysinfo
    return sub
yellow=(230, 200, 0)
purple=(155, 10, 160)
img=Image.new((176, 144))
img.clear(lightblue)
img.rectangle((5, 5, 171, 139), purple, width=3)
img.line((5, 65, 170, 65), 0, width=2)
img.text((54, 20), u'SMS Backup', red, font=(None, None, FONT_BOLD))
img.text((85, 35), u'by')
img.text((44, 55), u'ADIKSonline', yellow, font=('title', None, FONT_BOLD))
img.polygon((20, 80, 156, 80, 88, 120), 0, fill=green)
img.ellipse((40, 125, 136, 164), 0, fill=(200, 200, 200), width=2)
img.text((68, 140), u'.enjoy.', font=(None, None, FONT_BOLD))
img.rectangle((0, 0, 175, 143), red, width=2)
img.text((9, 136), u'MENU', (255, 255, 255))
img.text((146, 136), u'EXIT', (255, 255, 255))
img=img.resize(sysinfo.display_pixels())

def draw(rect):
    canvas.blit(img)
    
canvas=ui.Canvas(redraw_callback=draw)
ui.app.body=canvas
    
def view(n):
    e32.start_exe('Z:\\System\\Programs\\AppRun.exe', 'Z:\\System\\Apps\\NpdViewer\\NpdViewer.app "%s"' %n)
    
def author():
    ops=os.path.split
    opd=os.path.dirname
    ui.note(u'ADIO Kingsley O\[email protected]')
    try:
Esempio n. 15
0
#import all modules
import appuifw2, sysinfo, e32, time
lt=time.ctime()

di=sysinfo.display_pixels()
#introduction screen
appuifw2.app.screen='full'
can=appuifw2.app.body=appuifw2.Canvas()

#basic app info
__name__='Speak'
__author__='Vishal Biswas'
__filename__='Speak.py'
__main__=__name__
__doc__='\t\tSpeak\n\tAn application to pronounce text as per the Text-to-Speech engine of the device\n\tReport Bugs or give suggestions or solutions for existing bugs at [email protected]\n\tUser Interaction is highly appreciated'
__version__='2.00.0'
version_info=tuple(__version__.split('.'))

def __init__(mode=''):
    appuifw2.app.title=u'Speak'
    appuifw2.app.set_tabs([],None)
    if mode=='launch':
        sys.setdefaultencoding('u8')
        globalui.global_note(u'Thank You for downloading Speak.')
        global wrap,ans,scroll,no,syst,loc,t,sav,nae,pth,ext,ppb,com,qua,dela,log
        wrap=ans=scroll=1
        no=syst=loc=sav=dela=0
        nae=u'Screenshot'
        pth=u'D:\\'
        ext=u'.jpg'
        ppb=24
Esempio n. 16
0
 def save(self, path):
     self.opt_list_keys = [
         'toolspanel', 'colorspanel', 'brushsize', 'winswitch', 'zoom',
         'zoomin', 'zoomout', 'zoom_multiply', 'zoom_1_1', 'font', 'undo',
         'redo', 'copy', 'cut', 'paste', 'clear', 'templet', 'preview',
         'imtemplet', 'navigation', 'gradient'
     ]
     parser = iniparser.TIniParser()
     parser.create(path)
     parser.writegroup('MISC')
     parser.writeint('firststart', 0)
     parser.writeint('language', self.lang)
     parser.writeint('skin', self.skin)
     parser.writeint('toolslidespeed', (self.toolbar_slidespeed - 1))
     parser.writeint('cursortype', self.cursor)
     parser.writeint('cursorsize', (self.cursorsize - 1))
     parser.writeint('changecursor', self.cursormultiplier)
     parser.writeint('undosize', self.undo_size)
     parser.writeint('rectselecttype', self.rectselecttype)
     parser.writeint('cursordelay', self.curs_del, ',')
     parser.writeint('cursorstep', self.curs_step, ',')
     parser.writestr('imagefolder', self.lastpath_img)
     parser.writeint('confirmonexit', self.exitconfirm)
     parser.writecomment('')
     parser.writegroup('DISPLAY')
     if self.screen_size != display_pixels():
         size = str(self.screen_size[0]) + ',' + str(self.screen_size[1])
     else:
         size = 'None'
     parser.writeint('force_display_size', size)
     parser.writecomment('example: force_display_size = 240,320')
     parser.writecomment('')
     parser.writegroup('UI_FONTS')
     parser.writestr('menu_font', self.ui_menu_font[0])
     parser.writestr('status_font', self.ui_status_font[0])
     parser.writeint('menu_font_forceheight', self.ui_menu_font_fheight)
     parser.writecomment('')
     parser.writegroup('UI_COLORS')
     parser.writestr('menu_form_out', he(self.ui_menu_color[0][0]))
     parser.writestr('menu_form_in', he(self.ui_menu_color[0][1]))
     parser.writestr('menu_form_shade', he(self.ui_menu_color[0][2]))
     parser.writestr('menu_selbox_out', he(self.ui_menu_color[1][0]))
     parser.writestr('menu_selbox_in', he(self.ui_menu_color[1][1]))
     parser.writestr('menu_item', he(self.ui_menu_color[1][2]))
     parser.writestr('menu_selitem', he(self.ui_menu_color[1][3]))
     parser.writestr('menu_blckitem', he(self.ui_menu_color[1][4]))
     parser.writestr('backgr_form', he(self.ui_form_color[2]))
     parser.writestr('status_form', he(self.ui_form_color[0]))
     parser.writestr('status_font', he(self.ui_form_color[1]))
     parser.writestr('editor_scroll_outline', he(self.ui_form_color[3][0]))
     parser.writestr('editor_scroll_slider', he(self.ui_form_color[3][1]))
     parser.writestr('editor_scroll_fill', he(self.ui_form_color[3][2]))
     parser.writestr('grid_selector_color', he(self.ui_grid_color))
     parser.writestr('fileman_background', he(self.ui_req_color[0]))
     parser.writestr('fileman_infobar', he(self.ui_req_color[1]))
     parser.writestr('fileman_selbox_out', he(self.ui_req_color[2][0]))
     parser.writestr('fileman_selbox_in', he(self.ui_req_color[2][1]))
     parser.writestr('fileman_item', he(self.ui_req_color[2][2]))
     parser.writestr('fileman_selitem', he(self.ui_req_color[2][3]))
     parser.writestr('fileman_markitem', he(self.ui_req_color[2][4]))
     parser.writestr('fileman_scroll_outline', he(self.ui_req_color[3][0]))
     parser.writestr('fileman_scroll_slider', he(self.ui_req_color[3][1]))
     parser.writestr('fileman_scroll_fill', he(self.ui_req_color[3][2]))
     parser.writestr('progressbar_out', he(self.ui_prog_color[0]))
     parser.writestr('progressbar_slider', he(self.ui_prog_color[1]))
     parser.writestr('progressbar_fill', he(self.ui_prog_color[2]))
     parser.writecomment('')
     parser.writegroup('HOTKEYS')
     keys = [x[2] for x in self.keyconfig.data]
     mods = [x[3] for x in self.keyconfig.data]
     parser.writeint('keys', keys)
     parser.writeint('mods', mods)
     parser.writeint('mods_timeout', self.keyconfig.gettimeout())
     parser.writecomment('')
     parser.writegroup('CUSTOM_PALETTES')
     for t in xrange(len(self.custompal)):
         parser.writestr(str(t), self.custompal[t])
     parser.writecomment('')
     parser.writegroup('RECENT_FILES')
     for t in self.recentfiles:
         parser.writestr(t, '')
     parser.close()
class Image(object):
    _twips = sysinfo.display_twips()
    _pixels = sysinfo.display_pixels()
    _default_density = (float(_twips[0]) / _pixels[0],
                        float(_twips[1]) / _pixels[1])
    _modemap = {
        '1': _graphics.EGray2,
        'L': _graphics.EGray256,
        'RGB12': _graphics.EColor4K,
        'RGB16': _graphics.EColor64K,
        'RGB': _graphics.EColor16M
    }
    _moderevmap = _revdict(_modemap)

    def __init__(self, img):
        self._image = img
        if img.twipsize == (0, 0):
            img.twipsize = (self._default_density[0] * img.size[0],
                            self._default_density[1] * img.size[1])
        self._drawapi = self._image._drawapi
        self._draw = _graphics.Draw(self._image)
        self._bitmapapi = self._image._bitmapapi
        self.getpixel = self._image.getpixel
        self._lock = None
        self._errcode = 0
        self._waiting = 0
        self._resized_image = None
        for k in _graphics._draw_methods:
            setattr(self, k, getattr(self._draw, k))

    size = property(lambda self: self._image.size)
    mode = property(lambda self: self._moderevmap[self._image.mode])

    twipsize = property(
        lambda self: self._image.twipsize,
        lambda self, value: setattr(self._image, "twipsize", value))

    def from_cfbsbitmap(bitmap):
        return Image(_graphics.ImageFromCFbsBitmap(bitmap))

    from_cfbsbitmap = staticmethod(from_cfbsbitmap)

    def from_icon(filename, image_id, size):
        if e32.s60_version_info >= (3, 0):
            return Image(
                _graphics.ImageFromIcon(filename, image_id, size[0], size[1]))
        else:
            raise RuntimeError('not supported')

    from_icon = staticmethod(from_icon)

    def new(size, mode='RGB16'):
        if not Image._modemap.has_key(mode):
            raise ValueError('invalid mode')
        return Image(_graphics.ImageNew(size, Image._modemap[mode]))

    new = staticmethod(new)
    if not SDK12:

        def open(filename):
            def finish_load(errcode):
                img._errcode = errcode
                lock.signal()

            lock = e32.Ao_lock()
            img = Image(_graphics.ImageOpen(unicode(filename), finish_load))
            lock.wait()
            if img._errcode != 0:
                raise SymbianError, (img._errcode, "Error loading image:" +
                                     e32.strerror(img._errcode))
            return img

        open = staticmethod(open)

        def inspect(filename):
            (size, mode) = _graphics.ImageInspect(unicode(filename))
            return {'size': size}

        inspect = staticmethod(inspect)

        def load(self, filename, callback=None):
            self._wait()
            self._filename = unicode(filename)
            self._usercallback = callback
            self._lock = e32.Ao_lock()
            self._image.load(self._filename, self._callback)
            if callback is None:
                self._wait()
                if self._errcode != 0:
                    err = self._errcode
                    self._errcode = 0
                    raise SymbianError, (err, "Error loading image:" +
                                         e32.strerror(err))

        def save(self,
                 filename,
                 callback=None,
                 format=None,
                 quality=75,
                 bpp=24,
                 compression='default'):
            if format is None:
                if filename.lower().endswith(
                        '.jpg') or filename.lower().endswith('.jpeg'):
                    format = 'JPEG'
                elif filename.lower().endswith('.png'):
                    format = 'PNG'
                else:
                    raise ValueError(
                        'unrecognized suffix and format not specified')
            self._wait()
            lock = e32.Ao_lock()
            self._image.save(unicode(filename), self._callback, format,
                             quality, compression, bpp)
            # If the code above didn't raise an exception, this method
            # will succeed, so now it's safe to modify object state.
            self._usercallback = callback
            self._lock = lock
            if callback is None:
                self._wait()
                if self._errcode != 0:
                    err = self._errcode
                    self._errcode = 0
                    raise SymbianError, (err, "Error saving image:" +
                                         e32.strerror(err))

        def resize(self, size, callback=None, keepaspect=0):
            self._wait()
            newimage = Image.new(size, self.mode)
            lock = e32.Ao_lock()
            self._image.resize(newimage, keepaspect, self._callback)
            # If the code above didn't raise an exception, this method
            # will succeed, so now it's safe to modify object state.
            self._lock = lock
            self._usercallback = callback
            self._resized_image = newimage
            if callback is None:
                self._wait()
                if self._errcode != 0:
                    err = self._errcode
                    self._errcode = 0
                    raise SymbianError, (err, "Error resizing image:" +
                                         e32.strerror(err))
                t = self._resized_image
                self._resized_image = None
                return t

        def transpose(self, direction, callback=None):
            self._wait()
            if direction == ROTATE_90 or direction == ROTATE_270:
                newsize = (self.size[1], self.size[0])
            else:
                newsize = self.size
            newimage = Image.new(newsize, self.mode)
            lock = e32.Ao_lock()
            self._image.transpose(newimage, direction, self._callback)
            # If the code above didn't raise an exception, this method
            # will succeed, so now it's safe to modify object state.
            self._lock = lock
            self._usercallback = callback
            self._resized_image = newimage
            if callback is None:
                self._wait()
                if self._errcode != 0:
                    err = self._errcode
                    self._errcode = 0
                    raise RuntimeError("Error resizing image:" + str(err))
                t = self._resized_image
                self._resized_image = None
                return t

        def _callback(self, errcode):
            self._errcode = errcode
            if self._lock:
                self._lock.signal()
            self._lock = None
            if self._usercallback is not None:
                t = self._usercallback
                self._usercallback = None
                if self._resized_image is not None:  # resize in progress
                    if self._errcode == 0:
                        newimage = self._resized_image
                        self._resized_image = None
                        t(newimage)
                    else:
                        t(None)
                else:
                    t(self._errcode)

        def _wait(self):
            if self._lock:
                if self._waiting:
                    raise RuntimeError("Image object busy.")
                self._waiting = 1
                self._lock.wait()
                self._waiting = 0

        def stop(self):
            self._image.stop()
            if self._lock:
                self._errcode = 0
                self._lock.signal()
                self._lock = None
Esempio n. 18
0
 def fget(self):
     return sysinfo.display_pixels()
Esempio n. 19
0
# -*- coding: utf-8 -*-
#######wap.wapele.cn#######
#######中文名好听########
#######decompile2########


import sysinfo

DATA_PATH = 'C:\\DATA\\2048_profile'
W, H = sysinfo.display_pixels()
portrait = W < H and 1 or 0
def cn(string):
    try:
        return string.decode('utf-8')
    except:
        return string


TWIP = 5
TILE = 55
FIELD = 220
STEP = (H / 10)
LX = portrait and 10 or 50
TY = portrait and 55 or 15
RX = LX + FIELD
BY = TY + FIELD
loc = [[[0, 0] for i in range(4)] for i in range(4)]
for i in range(len(loc)):
    for j in range(len(loc)):
        loc[i][j] = ((i * TILE) + LX, (j * TILE) + TY)
MAX_UNDO_STEPS = 20
Esempio n. 20
0
# limitations under the License.

import sysinfo

print "OS: "
print sysinfo.os_version()
print "SW: "
print sysinfo.sw_version()
print "IMEI: "
print sysinfo.imei()
print "Bat: "
print sysinfo.battery()
print "Net: "
print sysinfo.signal()
print "Ram: "
print sysinfo.total_ram()
print "Rom: "
print sysinfo.total_rom()
print "MaxRamDrive: "
print sysinfo.max_ramdrive_size()
print "Twips: "
print sysinfo.display_twips()
print "Pixels: "
print sysinfo.display_pixels()
print "RamFree: "
print sysinfo.free_ram()
print "DriveSpace: "
print sysinfo.free_drivespace()
print "RingType: "
print sysinfo.ring_type()
Esempio n. 21
0
import sysinfo, appuifw, e32


def cn(x):
    return x.decode("utf8")


appuifw.app.body = t = appuifw.Text()
t.focus = False
appuifw.app.screen = "full"
t.add(cn("情景模式:") + sysinfo.active_profile())
t.add(cn("\n电量:") + unicode(sysinfo.battery()))
t.add(cn("\n屏幕分辨率:") + unicode(sysinfo.display_pixels()))
t.add(cn("\n剩余空间:\n"))
i = 0
drive = [u"C:", u"D:", u"E:"]
while i < len(drive):
    t.add(drive[i] + unicode(sysinfo.free_drivespace()[drive[i]] / 1024) +
          u"kb\n")
    i += 1
t.add(cn("剩余运存:") + unicode(sysinfo.free_ram() / 1024) + u"kb")
t.add(cn("\nIMEI:") + unicode(sysinfo.imei()))
t.add(cn("\n系统版本:") + unicode(sysinfo.os_version()))
t.add(cn("\n响铃方式:") + unicode(sysinfo.ring_type()))
t.add(cn("\n手机版本:") + unicode(sysinfo.sw_version()))
t.add(cn("\n缓存总大小:") + unicode(sysinfo.total_ram() / 1024) + u"kb")
t.add(cn("\nZ盘总大小:") + unicode(sysinfo.total_rom() / 1024) + u"kb")
t.add(cn("\n信号强度:") + unicode(sysinfo.signal_bars()))
t.add(cn("\n信号强度:") + unicode(sysinfo.signal_dbm()) + u"dbm")

e32.ao_sleep(3)
Esempio n. 22
0
__version__='0.96'
__site__='http://code.google.com/p/still-rainbow'
__author__='Serhiy Zagoriya (int_ua)'
__copyright__ = "Copyright 2009-2010, Serhiy Zagoriya"
__license__ = "GPLv3"
__email__ = "*****@*****.**"
# todo: i18n, scenario linking to other scenario, bookmark color

import appuifw
try:
 import e32,sysinfo,os
 from graphics import Image
except:
 appuifw.note(u'failed to\n import e32,sysinfo,os,graphics','error')

img=Image.new(sysinfo.display_pixels(),'RGB')
appuifw.app.screen='full'
appuifw.app.orientation='portrait'

#home=u'e:\\Python\\sr_files\\'
home=os.path.splitdrive(appuifw.app.full_name())[0]+u'\\private\\e6c858ac\\'
homecsv=home+u'csv\\'

color=[0,255,0]
velocity=10
custom_accuracy=24
showing_info=1
running=0
paused=0
color_channel=0
to_white=0
Esempio n. 23
0
from time import ctime
from graphics import *
import os, string, codecs, inbox
from appuifw import *
from graphics import *
app_lock = e32.Ao_lock()
appuifw.app.screen='full'
# defining the exit handler
def quit():
    app_lock.signal()
    appuifw.app.exit_key_handler=quit
 
 
 
#define image resolution
img=graphics.Image.new(sysinfo.display_pixels())
img.rectangle(((30,sysinfo.display_pixels()[1]/2-20),(sysinfo.display_pixels()[0]-20,sysinfo.display_pixels()

 
[1]/2+20)), outline=(0,0,0))
def hr(rect):canvas.blit(img)
canvas=appuifw.Canvas(redraw_callback=hr)
appuifw.app.body=canvas
 
p=0
img=Image.open("c:\\Data\\X-SMS\\5.jpg")
 
#Increment the progress bar by 10% every second.
for i in range(5):
   img.rectangle(((p,sysinfo.display_pixels()[1]/2-20),(p+(sysinfo.display_pixels()[0]-
 
Esempio n. 24
0
 def fget(self):
     return sysinfo.display_pixels()
Esempio n. 25
0
import appuifw,e32,audio
from sysinfo import display_pixels
from graphics import*

appuifw.app.screen='full'

im=Image.new(display_pixels())
path='e:\\'
s=audio.Sound.open(path+'Vol.mp3')

def redraw(rect):
    c.blit(im)

c=appuifw.Canvas(event_callback=redraw)
appuifw.app.body=c
gbr=['vol.jpg','v_up.jpg','v_dw.jpg']

im1= Image.open(path+gbr[0])
im2=Image.open(path+gbr[1])
im3=Image.open(path+gbr[2])

def graph(): 
  vol=s.current_volume()
  im.blit(im1)
  im.blit(im2,target=(150,154))
  im.blit(im3,target=(150,202))
  im.rectangle((145,202-vol*4,165,202),0xff9900,fill=0xff9900)
  im.text((165,130),str(vol*10)+u' %',0xff0000)
  redraw(())

def up():
Esempio n. 26
0
# -*- coding: utf-8 -*-
#######wap.wapele.cn#######
#######中文名好听########
#######decompile2########

import msys
msys.send_bg()
import graphics as gr, appuifw as ap, sysinfo

scrshot = gr.screenshot()
cvs = ap.Canvas()


def redraw(rect):
    cvs.blit(scrshot)


ap.app.body = cvs = ap.Canvas(redraw_callback=redraw)
ap.app.screen = 'full'
mypath = u"..\\..\\python\\pygame\\2048_maps\\"
splash = gr.Image.open(mypath + 'splash_2.1.png')
x, y = sysinfo.display_pixels()
if x > y:
    scrshot.blit(splash, target=(72, 78))
else:
    scrshot.blit(splash, target=(32, 117))
msys.send_fg()
Esempio n. 27
0
import time
import sysinfo
import e32

sys.stdout.write("IMEI: %s\n" % sysinfo.imei())

sys.stdout.write("Battery strength: %s\n" % sysinfo.battery())
 
sys.stdout.write("Signal strength: %s\n" % sysinfo.signal_bars())
 
sys.stdout.write("Network signal strength in dBm: %s\n" % sysinfo.signal_dbm())
 
sys.stdout.write("SW version: %s\n" % sysinfo.sw_version())
 
sys.stdout.write("Display size:\n")
print(sysinfo.display_pixels())
 
sys.stdout.write("Current profile: %s\n" % sysinfo.active_profile())
 
sys.stdout.write("Ringing type: %s\n" % sysinfo.ring_type())
 
sys.stdout.write("OS version:\n")
print(sysinfo.os_version())

sys.stdout.write("Free/total RAM (MB): %.2f / %.2f\n" % (sysinfo.free_ram()/1024/1024,sysinfo.total_ram()/1024/1024))
 
sys.stdout.write("Total ROM (MB): %.2f \n" % (sysinfo.total_rom()/1024/1024))
 
sys.stdout.write("Free disk space C/E (MB): %.2f / %.2f\n" % (sysinfo.free_drivespace()['C:']/1024/1024,sysinfo.free_drivespace()['E:']/1024/1024))

sys.stdout.write("Python version: %s (%s, %s)\n" % (e32.pys60_version,e32.pys60_version_info[0],e32.pys60_version_info[1]))
Esempio n. 28
0
        self.redraw()

    def main(self):
        global id, psw

        can.bind(63498, lambda: self.move_d())
        can.bind(63497, lambda: self.move_u())
        can.bind(63557, lambda: self.enter())
        can.bind(63554, lambda: self.denglu())
        can.bind(63555, lambda: self.fan())
        self.redraw()


class dl:pass
dl.version="V1.0"
dl.w=display_pixels()[0]#屏宽
dl.h=display_pixels()[1]#屏高
dl.bgcr=(100,200,200)#背景颜色
dl.inputcr=(145,125,238)#输入框颜色
dl.oncr=(255,100,100)#选择框颜色
dl.kjcr=0x995599#控件颜色
dl.pnum=0#手机号登录状态
dl.rempsw=1#记住密码状态
dl.kjzt=0#控件状态
dl.dong=1#移动状态
dl.ping=0
#判断横竖屏
if(display_pixels()==(240,320)):
    dl.ping=1#竖屏
elif(display_pixels()==(320,240)):
    dl.ping=2#横屏