예제 #1
0
 def itemevent(self):
     it = self.body.current()
     if it == 0 : 
         ind = appuifw.popup_menu(self.functname, self.dtext['function'])
         if ind is None : 
             return None
         else : 
             self.set_function(ind)
         pass
     elif it == 1 : 
         ind = appuifw.popup_menu(self.keylist + [self.dtext['enterkeycode']], self.dtext['key'])
         if ind is None : 
             return None
         elif ind == 17 : 
             self.enter_keycode(0)
         else : 
             self.set_key(self.curfunctind, self.strtokeycode(self.keylist[ind]))
         pass
     elif it == 2 : 
         ind = appuifw.popup_menu(self.keylist + [self.dtext['enterkeycode']], self.dtext['modifier'])
         if ind is None : 
             return None
         elif ind == 17 : 
             self.enter_keycode(1)
         else : 
             self.set_mod(self.curfunctind, self.strtokeycode(self.keylist[ind]))
         pass
     elif it == 3 : 
         to = appuifw.query(self.dtext['modtimeout'], 'number', self.gettimeout())
         if to is None : 
             return None
         else : 
             self.settimeout(to)
         pass
 def event(self):
     i = self.box.current()
     global settingslist
     settingslist = [
         u"Text color: ", u"Font: ", u"Highlight: ", u"Oper. color: ",
         u"Screen: "
     ]
     if i == 0:
         color = self.colorselect(self.bintostr(self.textcolor))
         self.items[0] = settingslist[0] + color
         self.textcolor = self.strtobin(color)
         self.lbrefresh(0)
     elif i == 1:
         fonts = appuifw.available_fonts()
         font = appuifw.popup_menu(fonts)
         if font != None:
             self.textfont = fonts[font]
             self.items[1] = settingslist[1] + self.textfont
             self.lbrefresh(1)
     elif i == 2:
         color = self.colorselect(self.bintostr(self.highcolor))
         self.items[2] = settingslist[2] + color
         self.highcolor = self.strtobin(color)
         self.lbrefresh(2)
     elif i == 3:
         color = self.colorselect(self.bintostr(self.opercolor))
         self.items[3] = settingslist[3] + color
         self.opercolor = self.strtobin(color)
         self.lbrefresh(3)
     elif i == 4:
         scr = appuifw.popup_menu(screens.values())
         if scr != None:
             self.screen = screens.keys()[scr]
             self.items[4] = settingslist[4] + screens.values()[scr]
             self.lbrefresh(4)
예제 #3
0
def test_list_query():
    query_types = ['text', 'code', 'number', 'query', 'float', 'date', 'time']
    for query in query_types:
        appuifw.note(u'Testing query type: ' + unicode(query))
        value = appuifw.query(u'Test query', query)
        if value is not None:
            if query == 'date':
                value = time.strftime("%d/%m/%y", time.localtime(value))
            elif query == 'time':
                value = time.strftime("%H:%M", time.gmtime(value))
            appuifw.note(u'Value : ' + unicode(value))
        else:
            appuifw.note(u'Query cancelled')

    single_item_list = [unicode(x) for x in range(10)]
    double_item_list = [(unicode(x), unicode(x + 1)) for x in range(10)]
    appuifw.note(u'Testing single item list')
    value = appuifw.popup_menu(single_item_list, u'Single item list')
    appuifw.note(u'Selected item : ' + unicode(value))
    appuifw.note(u'Testing double item list')
    value = appuifw.popup_menu(double_item_list, u'Double item list')
    appuifw.note(u'Selected item : ' + unicode(value))

    appuifw.note(u'Testing selection list with search field')
    value = appuifw.selection_list(single_item_list, search_field=1)
    appuifw.note(u'Selected item : ' + unicode(value))

    for selection_style in ['checkbox', 'checkmark']:
        appuifw.note(u'Testing multi-selection list, style - ' +
                     unicode(selection_style))
        value = appuifw.multi_selection_list(single_item_list,
                                             style=selection_style)
        appuifw.note(u'Selected items : ' + unicode(value))
예제 #4
0
 def displayQuestion():
     currentIndex = qListBox.current()
     currentItem = qList[currentIndex]
     if currentItem[0] == qName[0]:
         self.userName = appuifw.query(u'Please tell us your name.',
                                       'text')
         qList[currentIndex] = u'Name : ' + self.userName
         qListBox.set_list(qList)
     elif currentItem[0] == qLocation[0]:
         locationTags = [
             u'Home', u'Work', u'UCLA', u'Santa Monica', u'Westwood',
             u'Brentwood'
         ]
         locationTags.sort()
         locationTagIndex = appuifw.popup_menu(
             locationTags, u"Select your location and press ok.")
         if (locationTagIndex in range(0, 6)):
             self.locationTag = locationTags[locationTagIndex]
             qList[currentIndex] = u'Location : ' + self.locationTag
             qListBox.set_list(qList)
     elif currentItem[0] == qActivity[0]:
         activityTags = [
             u'Working', u'Playing', u'Walking', u'Shopping', u'Eating',
             u'Relaxing'
         ]
         activityTags.sort()
         activityTagIndex = appuifw.popup_menu(
             activityTags, u"Select your activity and press ok.")
         if (activityTagIndex in range(0, 7)):
             self.activityTag = activityTags[activityTagIndex]
             qList[currentIndex] = u'Activity : ' + self.activityTag
             qListBox.set_list(qList)
예제 #5
0
 def outopt_edit(self):
     ind = self.optbody.current()
     if ind == 0 : 
         result = appuifw.query(self.dtext['savepath'], 'text', unicode(self.outpath))
         if result is None : 
             return None
         if path.exists(result) : 
             self.outpath = result
         else : 
             appuifw.note(self.dtext['pathnexist'], 'error')
         self.optbody_update()
         cur = self.optbody.current()
         self.optbody.set_list(self.conf, cur)
     elif ind == 1 : 
         if self.conf == self.pngconf : 
             self.conf = self.jpgconf
             self.format = 'JPG'
         else : 
             self.conf = self.pngconf
             self.format = 'PNG'
         cur = self.optbody.current()
         self.optbody.set_list(self.conf, cur)
     elif ind == 2 : 
         if self.conf == self.jpgconf : 
             result = appuifw.query(self.dtext['quality'], 'number', unicode(self.quality))
             if result is None : 
                 return None
             if 1 > self.quality > 100 : 
                 appuifw.note(self.dtext['e_wrongqual'], 'error')
                 return None
             self.quality = result
             self.optbody_update()
             cur = self.optbody.current()
             self.optbody.set_list(self.conf, cur)
         elif self.conf == self.pngconf : 
             bpp = [24, 8, 1]
             name = [self.dtext['bpp_24'], self.dtext['bpp_8'], self.dtext['bpp_1']]
             ind = appuifw.popup_menu(name, self.dtext['bpp'])
             if ind is None : 
                 return None
             self.bpp = bpp[ind]
             self.optbody_update()
             cur = self.optbody.current()
             self.optbody.set_list(self.conf, cur)
         pass
     elif ind == 3 : 
         if self.conf == self.jpgconf : 
             pass
         if self.conf == self.pngconf : 
             vals = ['no', 'fast', 'default', 'best']
             compr = [self.dtext['comp_no'], self.dtext['comp_fast'], self.dtext['comp_def'], self.dtext['comp_best']]
             ind = appuifw.popup_menu(compr, self.dtext['compression'])
             if ind is None : 
                 return None
             self.compression = vals[ind]
             self.optbody_update()
             cur = self.optbody.current()
             self.optbody.set_list(self.conf, cur)
         pass
예제 #6
0
def select(type="file",initdir="\\",drive="",**options):
  def opt(k):
   if k in options:return options[k]
  initdir=drive+initdir
  path= os.path.normpath(initdir)
  drive,path=os.path.splitdrive(path)
  if not drive or initdir==drive+"\\..\\" and not opt("limitdrive"):
   drvs=e32.drive_list()
   ind=appuifw.popup_menu(drvs,u"Select Drive")
   if not ind==None:drive=drvs[ind]
   else:return None
  if not path[0:1]=="\\":path="\\"+path
  initdir=drive+path
  dirs=[]
  files=[]
  if not initdir[-1:]=="\\":initdir+="\\"
  dirsonly=type=="dir"
  for f in os.listdir(initdir):
   f=f.decode('utf8')
   statistics=os.stat(unicode(initdir+f).encode('utf8'))
   if S_ISDIR(statistics[0]):
    dirs.append([f.lower(),f])
   else:
    files.append([f.lower(),f])
  dirs.sort()
  files.sort()
  realdirs=[]
  if dirsonly:realdirs.append(u"[This Directory]")
  realdirs.append(u"[d] ..")
  for dir in dirs:realdirs.append(unicode("[d] "+dir[1]))
  if not dirsonly:
   realfiles=[]
   for file in files:
    allowed=True
    if opt("extblacklist"):
     for black in opt("extblacklist"):
      if os.path.splitext(file[1])[1][1:]==black:allowed=False
    if opt("extwhitelist"):
     allowed=False
     for white in opt("extwhitelist"):
      if os.path.splitext(file[1])[1][1:]==white:allowed=True
    if allowed:realfiles.append(unicode("[f] "+file[1]))
   realdirs.extend(realfiles)
  if dirsonly:title="Folder"
  else:title="File"
  ind=appuifw.popup_menu(realdirs,u'Select '+title)
  if not ind and ind is not 0:return None
  selected=realdirs[ind]
  if selected[:3]=="[d]":
   if dirsonly and selected[4:]=="[This Directory]":
    return initdir+selected[4:]
   else:
    return select(type,initdir+selected[4:]+"\\",'',**options)
  elif selected==u"[This Directory]":
   return  initdir
  else:
   return initdir+selected[4:]
예제 #7
0
 def chset(self):
  c=app.body.current()
  if c==0:self.mod_db('debug', ui.popup_menu([u'False', u'True']))
  elif c==1:q=ui.query(u'Database Directory', 'text', u(self.dd));f=open(self.root+'db.dir', 'w');f.write(q);f.close()
  elif c==2:
   opts=['SQL', 'flatfile']
   sel=ui.popup_menu([u(opts[0]), u(opts[1])])
   self.mod_db('mode', opts[sel])
  elif c==3:self.mod_db('a', ui.query(u'Alphabet string', 'text',  u(self.get_db('a'))))
  self.setup()
 def goto(self):
     i = appuifw.popup_menu(
         [u"Begin", u"> Line", u"> Percentage", u"> Char", u"End"])
     if i == 0:
         self.begin()
     elif i == 1:
         line = appuifw.query(
             u"Line (max %d):" %
             (appuifw.app.body.get().count(u"\u2029") + 1), 'number')
         if line != None:
             appuifw.app.body.set_pos(
                 self.findth(appuifw.app.body.get(), u"\u2029", line) + 1)
     elif i == 2:
         percentage = appuifw.query(u"Percentage:", 'number')
         if percentage != None:
             chr = int(
                 round(
                     float(appuifw.app.body.len()) *
                     (float(percentage) / 100.0)))
             appuifw.app.body.set_pos(chr)
     elif i == 3:
         chr = appuifw.query(
             u"Char pos (max %d):" % (appuifw.app.body.len() + 1), 'number')
         if chr != None:
             appuifw.app.body.set_pos(chr)
     elif i == 4:
         appuifw.app.body.set_pos(appuifw.app.body.len())
 def bookmarks(self):
     i = appuifw.popup_menu([
         u"Go to bookmark 1", u"Go to bookmark 2", u"Go to bookmark 3",
         u"Set bookmark 1", u"Set bookmark 2", u"Set bookmark 3",
         u"Clear bookmarks"
     ])
     if i in [3, 4, 5]:
         pos = appuifw.app.body.get_pos()
         i -= 2
         self.clearb(i)
         text = appuifw.app.body.get(pos, appuifw.app.body.len())
         appuifw.app.body.set(appuifw.app.body.get(0, pos))
         appuifw.app.body.color = bookcolor
         appuifw.app.body.add(u" #<%d># " % i)
         appuifw.app.body.color = self.textcolor
         appuifw.app.body.add(text)
         appuifw.app.body.set_pos(pos)
     elif i in [0, 1, 2]:
         i += 1
         txt = appuifw.app.body.get()
         p = txt.find("#<%d>#" % i)
         if p == -1:
             appuifw.note(u"Bookmark %d not set" % i, 'info')
         else:
             appuifw.app.body.set_pos(p + 3)
     elif i == 6:
         self.clearb(1)
         self.clearb(2)
         self.clearb(3)
예제 #10
0
def run(params):
    filename = params[1]
    appuifw.app.title = unicode(os.path.split(filename)[1])
    ext = os.path.splitext(filename)[1].lower()
    if ext in PYTHON_EXTS:
        source_path = os.path.splitdrive(filename)[1].lower()
        # It's safe to exit if we have been started from the Messaging
        # app, but not if we have been started from e.g. the web
        # browser, since then the whole browser would exit. The
        # default is to not exit the app, since that's safer.
        should_exit = source_path.startswith('\\system\\mail')
        if ext in PYTHON_LIB_EXTS:
            actions = [lambda: lib_install(filename)]
            menu = [u"Python lib module"]
        else:
            actions = [
                lambda: script_install(filename),
                lambda: standalone_install(filename),
                lambda: lib_install(filename)
            ]
            menu = [u"Python script", u"py2app", u"Python lib module"]

        index = appuifw.popup_menu(menu, u"Install as")
        try:
            if not index == None:
                appuifw.app.exit_key_handler = exit_wait
                e32.ao_yield()
                actions[index]()
                appuifw.note(u"Installation complete", "info")
        finally:
            appuifw.app.exit_key_handler = None
            if should_exit:
                appuifw.app.set_exit()
예제 #11
0
def bt_connect():
    global sock
    # create a bluetooth socket
    sock = socket.socket(socket.AF_BT, socket.SOCK_STREAM)
    target = ''  # here you can give the bt address of the other mobile if you know it
    if not target:
        # scan for bluetooth devices
        address, services = socket.bt_discover()
        print "Discovered: %s, %s" % (address, services)
        if len(services) > 1:
            choices = services.keys()
            choices.sort()
            # bring up a popup menu and show the available bt devices for selection
            choice = appuifw.popup_menu(
                [unicode(services[x]) + ": " + x for x in choices],
                u'Choose port:')
            target = (address, services[choices[choice]])
        else:
            target = (address, services.values()[0])
    print "Connecting to " + str(target)
    # connect to the serial port of the PC
    sock.connect(target)
    print "OK."

    # call the text input field function
    bt_typetext()
예제 #12
0
 def get_device(self):
     # devices from configuration has the form [devicename, host, tcp_port, username, password]
     devices = configuration.getConfiguration()
     if len(devices)>0 and appuifw.query(u"Choose a previously used device?", "query"):
         # define the list of items
         L = []
         for device in devices:
             name = device[0]
             host = device[1]
             L.append(unicode(host if name == '' else "%s - %s" % (name, host)))
         # create the selection list
         index = appuifw.popup_menu(L, u"Previously connected")
         if index is None:
             return -1
         return devices[index]
     else:
         # define the field list (consists of tuples: (label, type ,value)); label is a unicode string
         # type is one of the following strings: 'text', 'number', 'date', 'time',or 'combo'
         # see <http://gist.github.com/322309#file_form.py>
         data = [(u'Hostname/IP','text', u''),(u'TCP Port','number', 1234),(u'Username','text',u'admin')]
         # set the view/edit mode of the form  
         flags = appuifw.FFormEditModeOnly
         # creates the form
         f = appuifw.Form(data, flags)
         f.save_hook = self.save_input
         # make the form visible on the UI
         f.execute()
         self.host = f[0][2]
         self.tcp_port = f[1][2]
         self.username = f[2][2]
         password = appuifw.query(u"Password",'code')
         return ['', self.host, self.tcp_port, self.username, password]
 def showmenu(self):
     m = [
         u"def declaration", u"class declaration", u"for cycle",
         u"for i in range cycle", u"main function", u"import", u"import all"
     ]
     i = appuifw.popup_menu(m)
     if i != None:
         pos = appuifw.app.body.get_pos()
         text1 = appuifw.app.body.get(0, appuifw.app.body.get_pos())
         if i == 0:
             text2 = "def ():\n   \n   "
             pos += 4
         elif i == 1:
             text2 = "class :\n def __init__(self):\n  \n  "
             pos += 6
         elif i == 2:
             text2 = "for in :\n \n "
             pos += 4
         elif i == 3:
             text2 = "for i in range(, ):\n \n"
             pos += 15
         elif i == 4:
             text2 = "if __name__ == \"__main__\":\n main()"
             pos += len(text2)
         elif i == 5:
             text2 = "import "
             pos += 7
         elif i == 6:
             text2 = "from  import *"
             pos += 5
         text3 = appuifw.app.body.get(appuifw.app.body.get_pos())
         appuifw.app.body.set(text1 + text2 + text3)
         appuifw.app.body.set_pos(pos)
예제 #14
0
 def options_callback(self, pos):
     option = appuifw.popup_menu([u'Save', u'Point/Line Width', u'About'],
                                 u'Options')
     pen_width_options = [u'1', u'2', u'3', u'4', u'5', u'6']
     if option == 0:
         self.save_callback()
     elif option == 1:
         pen_width_choice = appuifw.popup_menu(pen_width_options)
         if pen_width_choice is not None:
             self.pen_width = int(pen_width_options[pen_width_choice])
     elif option == 2:
         self.is_about_active = True
         self.show_about()
         return
     self.canvas.blit(self.draw_img)
     self.draw_buttons()
예제 #15
0
    def menu_language(self):
        """Show language list, save changes in config.
        """
        def find_translations():
            """Get list of language codes.

            `gettext.find()` can't do it without defined system variables
            """
            # __builtin__.__dict__['_'] = lambda x: x  # Monkey path
            all_translations = set()
            if self._localedir:
                localedir = self._localedir
            else:
                localedir = gettext._default_localedir
            for loc_folder in os.listdir(localedir):
                for mo in os.listdir(
                        os.path.join(localedir, loc_folder, 'LC_MESSAGES')):
                    if mo.endswith('.mo'):
                        all_translations.add(unicode(loc_folder))
            return list(all_translations)

        translations = find_translations()
        translations.append(u'en')
        idx = appuifw.popup_menu(translations, _(u"Select language:"))
        if idx is not None:
            self.set_language(translations[idx])
            self._cfg.set(self._cfg_section, 'language', translations[idx])
            self.save_cfg()
            self.update_calcs()
            appuifw.note(
                _(u"Please reload the program to apply the changes."), 'info')
예제 #16
0
    def spendCoins(self):

        cdd,alreadythere = self.getCurrentCurrency()
        
        amount = self.getAmount(max=alreadythere)
        if not amount:
            return
        
        target = self.getTarget()
        if not target:
            return
            
        methodlist = [u'bluetooth',u'internet']
        method = appuifw.popup_menu(methodlist,u'how to connect?')


        if method == 1:
            url = appuifw.query(u'address','text',u'192.168.2.105:%s' % walletport)
            if not url:
                return                
            else:     
                url = 'http://%s' % (url)
            transport = self.getHTTPTransport(url)
            if not transport:
                self.displayActionMenu()
                return
            self.wallet.spendCoins(transport,cdd.currencyId,amount,target)
        else:
            ready =self.query('Is the other side ready to receive?')
            if ready:
                transport = self.getBTTransport() 
                self.wallet.spendCoins(transport,cdd.currencyId,amount,target)

        self.displayWalletMenu()
예제 #17
0
    def show_log(self):
        logdir = logs_dir + "\\"
        
        try:
            flist = [ unicode(file)
                      for file
                      in os.listdir(logdir)
                      if file.endswith(".txt") ]
        except:
            # The directory not existing will cause an exception that
            # appears to be quietly consumed, i.e., it is not printed
            # to the console.
            flist = []

        if len(flist) == 0:
            appuifw.note(u"No logs to display", "info")
            return

        index = appuifw.popup_menu(flist, u'Select file to view')
        if index is None:
            return
        fname = logdir + flist[index]

        print "opening " + fname
        doc_lock = e32.Ao_lock()
        ch = appuifw.Content_handler(doc_lock.signal)
        ch.open(fname)
        doc_lock.wait()
def bt_connect():
    global sock
    # create a bluetooth socket
    sock=socket.socket(socket.AF_BT,socket.SOCK_STREAM)
    target=''# here you can give the bt address of the other mobile if you know it
    if not target:
        # scan for bluetooth devices
        address,services=socket.bt_discover()
        print "Discovered: %s, %s"%(address,services)
        if len(services)>1:
            choices=services.keys()
            choices.sort()
            # bring up a popup menu and show the available bt devices for selection
            choice=appuifw.popup_menu([unicode(services[x])+": "+x
                                        for x in choices],u'Choose port:')
            target=(address,services[choices[choice]])
        else:
            target=(address,services.values()[0])
    print "Connecting to "+str(target)
    # connect to the serial port of the PC
    sock.connect(target)
    print "OK."

    # call the text input field function   
    bt_typetext()
예제 #19
0
    def menu_language(self):
        """Show language list, save changes in config.
        """
        def find_translations():
            """Get list of language codes.

            `gettext.find()` can't do it without defined system variables
            """
            # __builtin__.__dict__['_'] = lambda x: x  # Monkey path
            all_translations = set()
            if self._localedir:
                localedir = self._localedir
            else:
                localedir = gettext._default_localedir
            for loc_folder in os.listdir(localedir):
                for mo in os.listdir(
                        os.path.join(localedir, loc_folder, 'LC_MESSAGES')):
                    if mo.endswith('.mo'):
                        all_translations.add(unicode(loc_folder))
            return list(all_translations)

        translations = find_translations()
        translations.append(u'en')
        idx = appuifw.popup_menu(translations, _(u"Select language:"))
        if idx is not None:
            self.set_language(translations[idx])
            self._cfg.set(self._cfg_section, 'language', translations[idx])
            self.save_cfg()
            self.update_calcs()
            appuifw.note(_(u"Please reload the program to apply the changes."),
                         'info')
예제 #20
0
    def getBTTransport(self):
        if sys.platform == 'symbian_s60': 
            import btsocket
            sock=btsocket.socket(btsocket.AF_BT,btsocket.SOCK_STREAM)
            addr,services=btsocket.bt_discover()
            if len(services)>0:
                port = services[u'opencoin']
            else:
                port=services[services.keys()[0]]
            address=(addr,port)
            sock.connect(address)
        else:
            import bluetooth as bt
            #evil hack
            appuifw.note(u'Searching for devices','info')
            results = [r for r in bt.find_service() if r['name']==None]
            targets = []
            for result in results:
                targets.append(u'%s' % (bt.lookup_name(result['host'])))
            selected = appuifw.popup_menu(targets,u'Connect to...?')
            
            host = results[selected]['host']
            #port = results[selected]['port']
            port = 3
            print 'host: %s, port: %s' % (host,port)
            sock=bt.BluetoothSocket( bt.RFCOMM )
            sock.connect((host, port))

            



        return transports.BTTransport(sock)
예제 #21
0
def backup():
    qu=ui.popup_menu([u'Phone', u'Memory Card'], u'Select Location')
    loc=['c:\\', 'e:\\']
    try:
        dir=loc[qu]+'ADIKStools\\mySMSbackup\\'+time.strftime('%Y%m%d')+'\\'
    except:
        return
    if not os.path.exists(dir):
        os.makedirs(dir)
        ui.note(u'Folder Successfully Created', 'conf')
    n=dir+time.strftime('%H.%M.%S')+'.txt'
    gui.global_note(u'backing up\nplease wait', 'info')
    fl=open(n, 'a')
    fl.write(u'ADIKSonline SMS Backup\n\n%s\n' %q)
    b=t.sms_messages()
    if len(b)==0:
        ui.note(u'you have no message in your inbox'.upper())
        fl.write(u'No message in Inbox ! ! !\n\n%s\n' %u)
        fl.close()
        return
    y=0
    for i in b:
        try:
            fl.write(u'MESSAGE ID: %d\nSENDER: %s\nTIME: %s\nCONTENTS: %s\n\n%s\n\n' %(i, str(t.address(i)), time.ctime(t.time(i)), t.content(i), u))
            e32.ao_yield()
        except:
            y+=1
            gui.global_note(u'an error occured', 'error')
    fl.write(u'get more, contact:\[email protected]\n+2347035536245')
    fl.close()
    gui.global_note(str(len(b)-y)+u' successful'+u'\n'+str(y)+u' errors', 'confirm')
    e32.ao_sleep(1.5)
    if len(b)-y and msgquery.infopopup(u'View Backup Now?', u'View Backup', msgquery.OKRBack):
        view(n)
예제 #22
0
    def show_log(self):
        logdir = u'c:\\logs\\cl2\\'

        try:
            flist = [ unicode(file)
                      for file
                      in os.listdir(logdir)
                      if file.endswith(".txt") ]
        except:
            # The directory not existing will cause an exception that
            # appears to be quietly consumed, i.e., it is not printed
            # to the console.
            flist = []

        if len(flist) == 0:
            appuifw.note(u"No logs to display", "info")
            return

        index = appuifw.popup_menu(flist, u'Select file to view')
        if index is None:
            return
        fname = logdir + flist[index]

        print "opening " + fname
        doc_lock = e32.Ao_lock()
        ch = appuifw.Content_handler(doc_lock.signal)
        ch.open(fname)
        doc_lock.wait()
def test_appuifw():
    """ Call different api's of appuifw like query, multi_query,
        selection_list, multi_selection_list, popup_menu and check if these
        respond to user input appropriately.

    """
    first, last = appuifw.multi_query(u"First Name", u"Last Name")
    appuifw.note(u"Enter these fields to proceed, " + first, "info")
    query_func()
    selected_team = appuifw.selection_list(choices=teams, search_field=1)
    if selected_team == 1:
        appuifw.note(u"Nice team to be in", "info")
        team_members_list = appuifw.multi_selection_list(team_members,
                                                         style='checkbox',
                                                         search_field=1)
        appuifw.note(u"Lets verify it again", "info")
        team_members_list = appuifw.multi_selection_list(team_members,
                                                         style='checkmark',
                                                         search_field=1)
        appuifw.note(u"Verification Done", "conf")
    option = appuifw.popup_menu(choice_list, u"How was the experience?")
    if option == 0:
        appuifw.note(u"Thank You", "info")
    else:
        appuifw.note(u"Loads to improve on!!", "error")
예제 #24
0
 def connect(self):
     self.sock = btsocket.socket(btsocket.AF_BT, btsocket.SOCK_STREAM)
     btsocket.set_default_access_point(
         btsocket.access_point(btsocket.select_access_point()))
     addr, services = btsocket.bt_discover()
     print "Discovered: %s, %s" % (addr, services)
     if len(services) > 0:
         import appuifw
         choices = services.keys()
         choices.sort()
         choice = appuifw.popup_menu(
             [unicode(services[x]) + ": " + x for x in choices],
             u'Choose port:')
         port = services[choices[choice]]
     else:
         port = 1
     address = (addr, port)
     print "Connecting to " + str(address) + "...",
     self.sock.connect(address)
     #except socket.error, err:
     #    if err[0]==54: # "connection refused"
     #        if _s60_UI:
     #            appuifw.note(u'Connection refused.','error')
     #        else:
     #            print "Connection refused."
     #        return None
     #    raise
     print "OK."
예제 #25
0
def obex_send():
    print "it will send a file towards an unknown device"
    LF = open(u"C:\\testSocket\\obexSending.txt", "w")
    try:
        addr, serv = bt_obex_discover()
        print("\nbt_discover called")
        LF.write("\nbt_discover called")
        LF.write("\naddress: %s, len dict %d" % (addr, len(serv)))
        LF.write("\n%s" % serv)
        LF.flush()
        list = serv.keys()
        channel = appuifw.popup_menu(list, u"Choose a remote service")
        bt_obex_send_file(addr, serv[(list[channel])],
                          u"c:\\testSocket\\pythonHi.gif")
        print "file sent"
        print "port used: %d" % (serv[(list[channel])])
        LF.write("\nfile Sent")
        LF.flush()
    except:
        print "exception risen"
        LF.write("\nexception risen for bt_discover")
        type, value, tb = sys.exc_info()
        LF.write((str(type) + '\n' + str(value)))
        LF.flush()
        print((str(type) + '\n' + str(value)))
    LF.close()
    print "done"
예제 #26
0
 def availcss(self,usedcss):
  allcss=[x for x in self.allcss] # local copy
  for k in usedcss:allcss.remove(k)
  availcss=[unicode(l) for l in allcss]
  select=appuifw.popup_menu(availcss,u'Available CSS Properties')
  label=unicode(availcss[select])
  return label,appuifw.query(u'Value','text') or u''
예제 #27
0
 def call(*args, **kwargs):
     if handled:
         handle_exit()
     else:
         ans = popup_menu([u"Yes", u"No"], u"Confirm Exit?")
         if ans == 0:
             self.is_running = 0
예제 #28
0
파일: UBBEdit.py 프로젝트: Symbian9/pycoder
 def face(self):  #添加表情
     try:
         i = ui.popup_menu(self.face_list, cn('表情'))
         i += 1001
         self.t.add(u'BQ%s' % i)
     except:
         pass
예제 #29
0
def query_for_host_and_port(default_port = 1):
    """Returns a 2-tuple of (unicode string) BT address and (int)
    port. Returns (None, None) on failure or cancel."""

    # Ask for the hostname:
    bt_choices = devices.keys()
    bt_choices.append(u"Enter manually")
    choice = appuifw.popup_menu(bt_choices, u"Choose server's BT address:")

    # If the user's choice was "enter manually", ask them to type
    # in the ID.
    if choice == (len(bt_choices) - 1):
        host = appuifw.query(u"Input server's BT address:", 'text', u"00:00:00:00:00:00")
        if host == None:
            return (None, None)
    else:
        host = devices.values()[choice]

    # Now ask for the port:
    port_input = appuifw.query(u"Input server's port:", 'number', default_port)
    if port_input == None:
        return (None, None)
    else:
        port_input = int(port_input)

    return (host, port_input)
예제 #30
0
def popup_menu():
    list = [cn("菜单一"), cn("菜单二")]  #这是列表,详见元组、列表和字典一节
    index = appuifw.popup_menu(list, cn("无限菜单"))
    if index == 0:
        appuifw.note(cn("这是菜单一"), "info")
    else:
        appuifw.note(cn("这是菜单二"), "info")
예제 #31
0
def menu():
    S = None
    lastfilename = "silence"
    while(1):
	index = appuifw.popup_menu(L)
	if index == 0:
	    piano()
	elif index == 1:
	    metronome()
	elif(index >= 2 and index <= 6):
	    # playtuning(menu2note[index])
	    filename = "D:\\"+ menu2note[index] +".mid"
	    if S is not None:
		S.stop()
	    if(filename != lastfilename):
		if S is not None:
		    S.close()
		S = audio.Sound.open(filename)
	    S.play((tuninglength+1),0)
	elif index == 7:
	    settings()
	elif index == 8:
	    about()
	elif index == 9:
	    exit_key_handler()
	    return
예제 #32
0
    def connect(self):
        self.sock=btsocket.socket(btsocket.AF_BT,btsocket.SOCK_STREAM)
	btsocket.set_default_access_point(btsocket.access_point(btsocket.select_access_point()))
        addr,services=btsocket.bt_discover()
        print "Discovered: %s, %s"%(addr,services)
        if len(services)>0:
            import appuifw
            choices=services.keys()
            choices.sort()
            choice=appuifw.popup_menu([unicode(services[x])+": "+x
                                       for x in choices],u'Choose port:')
            port=services[choices[choice]]
        else:
            port=1
        address=(addr,port)
        print "Connecting to "+str(address)+"...",
        self.sock.connect(address)
        #except socket.error, err:
        #    if err[0]==54: # "connection refused"
        #        if _s60_UI:
        #            appuifw.note(u'Connection refused.','error')
        #        else:
        #            print "Connection refused."
        #        return None
        #    raise
        print "OK." 
예제 #33
0
def my_select_access_point():
    ap_list = socket.access_points()
    names = [ unicode(m["name"]) for m in ap_list ]
    index = appuifw.popup_menu(names, u'Select AP')
    if index is None:
        return None
    return ap_list[index]["iapid"]
예제 #34
0
파일: chom.py 프로젝트: weynsee/chompy
 def open(self, filename=None):
     if filename is None:
         filename = self.recent[self.lb.current()]
     res = appuifw.popup_menu([u"Offline Mode", u"Online Mode"])
     if res == 0:
         self.open_offline(filename)
     elif res == 1:
         self.open_online(filename)
예제 #35
0
def sel_access_point():
    aps = []
    aps.append({'iapid': 1, 'name': u'Easy WLAN'})
    for api in socket.access_points():
        aps.append(api)
    ap_labels = map(lambda x: x['name'], aps)
    item = appuifw.popup_menu(ap_labels, cn('选择接入点:'))
    return aps[item]['iapid']
예제 #36
0
 def set_type():
     tp = appuifw.popup_menu([u'1- amr', u'2- wav'], ar('Type of recorded Sound'))
     if tp==0:
       settings.TYPE = u'amr'
       std()
     elif tp==1:
       settings.TYPE = u'wav'
       std()
예제 #37
0
def menu():
    index = appuifw.popup_menu(L,u'select')
    if index == 0:
        playsound1()
    if index == 1:
        playsound2()
    if index == 2:
        quit()
예제 #38
0
def select_contact(with_publish):
    db = contacts.open()

    clist = [ c for c
              in [ db[cid] for cid in db ]
              if (not c.is_group) and (c.find("email_address") != []) ]

    if with_publish:
        clist = [PublishContact()] + clist
    else:
        if clist == []:
            appuifw.note(u"No contacts to select", "error")
            return None

    chlist = [ unicode(c.title) for c in clist ]
    index = appuifw.popup_menu(chlist, u'Select contact')
    if index is None:
        return None

    chentry = clist[index]
    cmap = {}

    def get_value(name):
        fields = chentry.find(name)
        if len(fields) > 0:
            cmap[name] = fields[0].value
    
    fields = chentry.find("email_address")
    if len(fields) == 1:
        cmap["email_address"] = fields[0].value
    elif len(fields) > 1:
        chlist = [ unicode(f.value) for f in fields ]
        index = appuifw.popup_menu(chlist, u'Select address')
        if index is None:
            return None
        cmap["email_address"] = fields[index].value
    else:
        raise "assertion failure"

    get_value("first_name")
    get_value("last_name")
    get_value("first_name_reading")
    get_value("last_name_reading")
    get_value("second_name")

    return cmap
 def fonts(self):
     f = appuifw.available_fonts()
     i = appuifw.popup_menu(f)
     if i != None:
         appuifw.app.body.font = f[i]
         pos = appuifw.app.body.get_pos()
         appuifw.app.body.set(appuifw.app.body.get())
         appuifw.app.body.set_pos(pos)
def choose_service(services):
        names = []
        channels = []
        for name, channel in services.items():
                names.append(name)
                channels.append(channel)
        index = appuifw.popup_menu(names, u"Choose service")
        return channels[index]
예제 #41
0
def ask_iap_name():
    # [{'iapid': 17, 'name': u"FooBar"}, ...]
    ap_list = socket.access_points()
    name_list = [ r['name'] for r in ap_list ]
    index = appuifw.popup_menu(name_list, u'Select IAP')
    if index is None:
        return None
    return name_list[index]
예제 #42
0
 def availcss(self, usedcss):
     allcss = [x for x in self.allcss]  # local copy
     for k in usedcss:
         allcss.remove(k)
     availcss = [unicode(l) for l in allcss]
     select = appuifw.popup_menu(availcss, u"Available CSS Properties")
     label = unicode(availcss[select])
     return label, appuifw.query(u"Value", "text") or u""
예제 #43
0
 def del_recent(self):
  if appuifw.query(u'Select items to delete?','query'):
   while len(self.recent):
    i=appuifw.popup_menu(map(lambda x: unicode(os.path.split(x)[1]), self.recent), u'Delete recents:')
    if i>=0: del self.recent[i]
    else: break
   else: appuifw.note(u'Recents list empty')
   self.refresh()
   self.add_to_recents()
예제 #44
0
    def lbox_observe(self, ind = None):
        if not ind == None:
            index = ind
        else:
            index = self.lb.current()
        focused_item = 0

        if self.current_dir.at_root:
            self.dir_stack.append(index)
            self.current_dir.add(index)
        elif index == 0:                              # ".." selected
            focused_item = self.dir_stack.pop()
            self.current_dir.pop()
        elif os.path.isdir(self.current_dir.entry(index-1)):
            self.dir_stack.append(index)
            self.current_dir.add(index-1)
        else:
            item = self.current_dir.entry(index-1)
            if os.path.splitext(item)[1].lower() == u'.py':
                i = appuifw.popup_menu([u"execfile()", u"Delete"])
            else:
                i = appuifw.popup_menu([u"Open", u"Delete"])
            if i == 0:
                if os.path.splitext(item)[1].lower() == u'.py':
                    execfile(item, globals())
                    self.refresh()
                    #appuifw.Content_handler().open_standalone(item)
                else:
                    try:
                        appuifw.Content_handler().open(item)
                    except:
                        import sys
                        type, value = sys.exc_info() [:2]
                        appuifw.note(unicode(str(type) + '\n' + str(value)), \
                                     "info")
                return
            elif i == 1:
                os.remove(item)
                focused_item = index - 1

        entries = self.current_dir.list_repr()
        if not self.current_dir.at_root:
            entries.insert(0, (u"..", u""))
        self.lb.set_list(entries, focused_item)
예제 #45
0
def options():
    # creating a pop-up menu for options
    L = [u"Set callChar", u"Other options..."]
    test = appuifw.popup_menu(L, u"Options")

    if test == 0 :
        global callChar
        callChar = appuifw.query(u"Set callChar char", "text", callChar) 
    elif test == 1 :
        appuifw.note(u"Other options will go here.", "info")
예제 #46
0
    def SelectBook(self):
       try:
          listOfBookNames = [unicode(book.bookName) for book in self.library.books]
          index = appuifw.popup_menu(listOfBookNames, u"Select a book:")
          if index >= 0:
	      self.settings.currentBook = self.library.books[index].bookName
	      self.settings.Save()
          self.LoadBook()
       except:
          self.logWriter.Log("\n".join(traceback.format_exception(*sys.exc_info())))
예제 #47
0
 def receiveCoins(self):
     name = self.getActiveCurrency()['name']
     selection = appuifw.popup_menu([u'internet',u'bluetooth'],u'Receive %s via' % name)
     if selection == 0:
         w = oc2.Wallet()
         sst = oc2.SocketServerTransport('0.0.0.0',12008)
         r = urllib.urlopen('https://opencoin.org/myownip')
         appuifw.note(u'send the coins now')
         w.receiveMoney(sst)
         appuifw.note(u'got coins: %s' % repr(w.coins))
예제 #48
0
 def select_camera_uid(self):
     old_uid = self.config.db.get("camera_uid", 0x101ffa86)
     nums = [0x101ffa86, 0x101f857a]
     chlist = [ (u"0x%08X" % uid) for uid in nums ]
     index = appuifw.popup_menu(chlist, u'Select Camera UID')
     if index is not None:
         new_uid = nums[index]
         if old_uid != new_uid:
             self.config.db["camera_uid"] = new_uid
             self.config.save()
예제 #49
0
 def pop_options(self):
     ''' Query popup with touch screen '''
     i = appuifw.popup_menu([u"Change Color", u"About", u"Exit"], u"Options menu:")
     # Handle selection
     if i == 0:
         self.menu_settings()
     elif i == 1:
         self.menu_about()
     elif i == 2:
         self.cb_quit()
예제 #50
0
def browse (filetype = EAnyMediaFile, title=None, softkey=None):
    useDefaultTitle = 0
    useDefaultSoftkey = 0
    if title is None:
        useDefaultTitle = 1
        title = u""
    if softkey is None:
        useDefaultSoftkey = 1
        softkey = u""
    filename = popup_menu([u"file_a",u"file_b",u"file_c",u"file_d" ],title)
    return filename
예제 #51
0
 def sendCoins(self):
     name = self.getActiveCurrency()['name']
     number = appuifw.query(u'number of %s' % name,u'number')
     selection = appuifw.popup_menu([u'internet',u'bluetooth'],u'Send %s %s via' % (number,name))
     if selection == 1:
         self.sendCoinsBT()
     elif selection == 0:
         address = appuifw.query(u'Recipients address',u'text')
         conn = httplib.HTTPConnection(address)
         appuifw.note(u'Making connection. May take a while...')
         conn.request('POST','/wallet')
예제 #52
0
def popup_menu():
    # create a list as content for the menu
    L = [u"Stefan", u"Holger", u"Emil"]
    # create the popup menu: appuifw.popup_menu(list, label)
    test = appuifw.popup_menu(L, u"Select + press OK:") 
    if test == 0 : # 0 refers to the first entry in the list L
        print "Stefan was selected"
    if test == 1 : # 1 refers to the second entry in the list L
        print "Holger was selected"
    if test == 2 : # 2 refers to the third entry in the list L
        print "Emil was selected"     
    def home(self):
        user_input = appuifw.popup_menu([u"Connectar", u"Adicionar Servidor"], u"Conexão")
        if user_input is None:
            self.exit()
            return

        self.read_servers()
        if user_input == 0:
            self.select_server()
        else:
            self.add_server()
예제 #54
0
    def SelectBook(self):
        self.logWriter.Log("Selecting a book")
        self.logWriter.Log("There are %d books in the library:"%len(self.library.books))
        for book in self.library.books:
          self.logWriter.Log("   bookname: %s"%book.bookName)
        listOfBookNames = [u"%s"%book.bookName for book in self.library.books]
        self.logWriter.Log("Created List of books")
        index = appuifw.popup_menu(listOfBookNames, u"Select a book:")
        if index >= 0:
	    self.settings.currentBook = self.library.books[index].bookName
	    self.settings.Save()
	    self.LoadBook()