×

Discussion Board

Results 1 to 11 of 11

Thread: File Path????

  1. #1
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    71

    File Path????

    Is there any function or method let me when i click the file from the list it give me the path for that file???
    thanks
    Last edited by programer_asal; 2009-06-20 at 05:00.

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: File Path????

    What list?

  3. #3
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    71

    Re: File Path????

    This type of list
    appuifw.Listbox
    thanks

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: File Path????

    And what does this list contain? You can't expect us to help you if you don't describe the situation with as many details as possible...

  5. #5
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    71

    Re: File Path????

    Sorry for that the idea is that am trying to let the user to browse for file and after selecting that file I pass the path of it to the send function to send that file by Bluetooth is it clear now or should I describe more?sorry again and thank you

  6. #6
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: File Path????

    OK. So the list contains the names of the files, right?

    Could you show us the code you used?

  7. #7
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    71

    Re: File Path????

    Code:
    import os
    import appuifw
    import e32
    import dir_iter
    
    class Filebrowser:
        def __init__(self):
            self.script_lock = e32.Ao_lock()
            self.dir_stack = []
            self.current_dir = dir_iter.Directory_iter(e32.drive_list())
    
        def run(self):
            from key_codes import EKeyLeftArrow
            entries = self.current_dir.list_repr()
            if not self.current_dir.at_root:
                entries.insert(0, (u"..", u""))
            self.lb = appuifw.Listbox(entries, self.lbox_observe)
            self.lb.bind(EKeyLeftArrow, lambda: self.lbox_observe(0))
            old_title = appuifw.app.title
            self.refresh()
            self.script_lock.wait()
            appuifw.app.title = old_title
            appuifw.app.body = None
            self.lb = None
    
        def refresh(self):
            appuifw.app.title = u"File browser"
            appuifw.app.menu = []
            appuifw.app.exit_key_handler = self.exit_key_handler
            appuifw.app.body = self.lb
    
        def do_exit(self):
            self.exit_key_handler()
    
        def exit_key_handler(self):
            appuifw.app.exit_key_handler = None
            self.script_lock.signal()
    
        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] == '.py':
                    i = appuifw.popup_menu([u"execfile()", u"Delete"])
                else:
                    i = appuifw.app.menu = [(u"Send",Send(item)]
               
    
    
            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)
    
    
    
    def Send(item):
        from socket import *
        import appuifw
        import e32
        addr,services=bt_obex_discover()
        print "Discovered: %s, %s"%(addr,services)
        if len(services)>0:
            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=services[services.keys()[0]]
        address=(addr,port)
        
    
        #print "Sending file %s to host %s port %s"%(send_path, address[0], address[1])
        bt_obex_send_file(address[0], address[1], item)
        print "File sent."
    
    
    
        
    
    
    
    
    
    
    if __name__ == '__main__':
        Filebrowser().run()


    I wish that it is ok right now am really very sorry for that
    about the problem when executing this code said that socket.error2,'No such file or directory')
    and the file didnot sent

    thank you very much and sorry for annoying
    Last edited by programer_asal; 2009-06-20 at 12:17.

  8. #8
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: File Path????

    Please edit your post and use the code tags (after you click on the Edit/Delete Message button, click on the Go Advanced button. In the editor that shows up, delete all the code you posted and post it again, exactly as it is in your script. Then select the code and press the button with the # symbol on it). This will maintain the code indentation and make it a lot easier to read.

    Another important thing: exactly what problem are you facing? Does the code give errors? Is there something you want to do but don't know how (if so, what?)?

  9. #9
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    71

    Re: File Path????

    I have edited the last post

    what I wnat to do exactly is browsing for a file and then sending it I tried alot and I have edited the code a lot but with no benefit
    thank you Mr.bogdan.galiceanu a lot and sorry alot for the unordered post

  10. #10
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: File Path????

    The line
    Code:
    i = appuifw.app.menu = [(u"Send",Send(item)]
    gives a syntax error because you forgot to close the tuple's bracket. So change it to
    Code:
    i = appuifw.app.menu = [(u"Send",Send(item))]

  11. #11
    Regular Contributor
    Join Date
    Jan 2009
    Posts
    71

    Re: File Path????

    Sorry Mr.bogdan.galiceanu
    but still the same problem!

Similar Threads

  1. Regarding BMCONV
    By sanah007 in forum Symbian
    Replies: 2
    Last Post: 2009-05-26, 12:47
  2. [split] mbm build error
    By mando222 in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2009-03-29, 12:32
  3. File Path problem
    By SingerSinger in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2008-11-30, 07:22
  4. sound file path
    By symbians60 in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2007-09-10, 13:30
  5. Help needed with a 3gp file...
    By joedoe_1981 in forum Streaming and Video
    Replies: 0
    Last Post: 2007-07-18, 18:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×