You Are Here:

Community: Developer Discussion Boards

#1 Old how to list the text(*.txt) in 'e:\a' - 2008-07-03, 08:42

Join Date: May 2008
Posts: 17
anyko38155285
Offline
Registered User
first,thank everyone have helped me,I'm from China,my English is not good…

like the title,I want to list them with 'Listbox',and when I select one of them,can rename it,write it

for example,if 'a.text' and 'b.text' are in the dir'e:\c\',l write it like this:
>>> import os
>>> os.listdir('e:\\c\\')
it will print:
['a.text', 'b.text']
>>>

now I want kown the code,when I have got the list,how to list the file though 'appuifw.app.body=appuifw.Listbox( , )',that I can select 'a.text' and creat.can you tell me the whole code,thanks very much

could you understand?I think it's terrible that I did not learn English hard
Last edited by anyko38155285 : 2008-07-03 at 14:42.
Reply With Quote

#2 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 08:48

Join Date: Dec 2007
Posts: 409
Location: Tempe, AZ
Send a message via Yahoo to shubhendra Send a message via Skype™ to shubhendra
shubhendra's Avatar
shubhendra
Offline
Forum Nokia Champion
Hi anyko38155285 ,
Your question is not clear could you please explain it.


IDEAS is all they need but still they think only Genius can give them that.
Reply With Quote

#3 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 08:55

Join Date: May 2008
Posts: 17
anyko38155285
Offline
Registered User
i have revised it,you are so early,aha
Reply With Quote

#4 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 11:36

Join Date: Dec 2007
Posts: 409
Location: Tempe, AZ
Send a message via Yahoo to shubhendra Send a message via Skype™ to shubhendra
shubhendra's Avatar
shubhendra
Offline
Forum Nokia Champion
I really cant understand the question now also.


IDEAS is all they need but still they think only Genius can give them that.
Reply With Quote

#5 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 11:40

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by anyko38155285 View Post
first,thank everyone have helped me,I'm from China,my English is not good

first,thank everyone have helped me,I'm from China,my English is not good…
like the title,I want to list them with 'Listbox',and when I select one of them,can rename it,write it

could you understand?I think it's terrible that I did not learn English hard
Hi,

Check out this article which would solve your problem


How to search a file extension


You need to search .txt files in E:\\a so modify the path and file_extension variable accordingly.

Best Regards,
Croozeus
Reply With Quote

#6 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 11:58

Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
Send a message via Yahoo to gaba88 Send a message via Skype™ to gaba88
gaba88's Avatar
gaba88
Online
Forum Nokia Champion
hi anyko38155285
dont worry about your English it will become good.
now as far as your problem is concerned croozeus has already given you the wiki link. that will help.
moreover as far as i understand you want to change the name of the the file you selected am i correct????


Gargi Das- http://gargidas.blogsot.com

Forum Nokia Python Wiki


Learn Python at http://mobapps.org/PyS60
Reply With Quote

#7 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 14:40

Join Date: May 2008
Posts: 17
anyko38155285
Offline
Registered User
yes.for example,if 'a.text' and 'b.text' are in the dir'e:\c\',l write it like this:
>>> import os
>>> os.listdir('e:\\c\\')
it will print:
['a.text', 'b.text']
>>>

now I want kown the code,when I have got the list,how to list the file though 'appuifw.app.body=appuifw.Listbox( , )',that I can select 'a.text' and creat.can you tell me the whole code,thanks very much
Reply With Quote

#8 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 18:22

Join Date: May 2007
Posts: 2,737
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by anyko38155285 View Post
yes.for example,if 'a.text' and 'b.text' are in the dir'e:\c\',l write it like this:
>>> import os
>>> os.listdir('e:\\c\\')
it will print:
['a.text', 'b.text']
>>>

now I want kown the code,when I have got the list,how to list the file though 'appuifw.app.body=appuifw.Listbox( , )',that I can select 'a.text' and creat.can you tell me the whole code,thanks very much
Just a hint:

1) List all the files in the folder with the os.listdir function.
2) Check for the extension, Append the entries which have the required extension - .txt

You will need to use a for or a while loop for doing the two steps.
For appending the entries you need to have an empty array set up.

Like
Quote:
filelist=[].
.
.
.
filelist.append("...")
3) Show the selection list with the appended entries
Quote:
index=appuifw.selection_list(filelist)
4) Triger required action on the basis of selection -> del, rename, etc

Hope that helps,

btw, I think you must read this
Fishing for information

Best Regards,
Croozeus
Reply With Quote

#9 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 18:42

Join Date: May 2008
Posts: 17
anyko38155285
Offline
Registered User
thanks for your helping.
the proverb is truth
Reply With Quote

#10 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-03, 19:20

Join Date: Jun 2005
Posts: 382
y.a.k
Offline
Regular Contributor
Here's a quick mockup:

Code:
items = []
for name in os.listdir('e:\\some\\directory'):
    if os.path.splitext(name)[-1].lower() == '.txt':
        items.append(name)

def select_click():
    name = items[appuifw.app.body.current()]
    path = os.path.join('e:\\some\\directory', name)
    
    appuifw.note(u'Selected: %s' % path.decode('utf8'))
    
appuifw.app.body = appuifw.Listbox([x.decode('utf8') for x in items], select_click)
Sorry for this .decode() stuff and list comprehension but I couldn't make myself to write a more "beginner" code. Luckily I haven't used list comprehension to build the items list .

The decode() method is a better choice to convert a path/filename to unicode than unicode() because it works properly if the filename contains non-ascii characters.

This code displays a list of .txt files in some directory and allows you to click on them. Clicking pops up a note with a full path to the file.
Reply With Quote

#11 Old Re: how to list the text(*.txt) in 'e:\a' - 2008-07-04, 00:24

Join Date: May 2008
Posts: 17
anyko38155285
Offline
Registered User
Quote:
Originally Posted by y.a.k View Post
Here's a quick mockup:

Code:
items = []
for name in os.listdir('e:\\some\\directory'):
    if os.path.splitext(name)[-1].lower() == '.txt':
        items.append(name)

def select_click():
    name = items[appuifw.app.body.current()]
    path = os.path.join('e:\\some\\directory', name)
    
    appuifw.note(u'Selected: %s' % path.decode('utf8'))
    
appuifw.app.body = appuifw.Listbox([x.decode('utf8') for x in items], select_click)
Sorry for this .decode() stuff and list comprehension but I couldn't make myself to write a more "beginner" code. Luckily I haven't used list comprehension to build the items list .

The decode() method is a better choice to convert a path/filename to unicode than unicode() because it works properly if the filename contains non-ascii characters.

This code displays a list of .txt files in some directory and allows you to click on them. Clicking pops up a note with a full path to the file.
thank you!
Reply With Quote

#12 Old Re: how to list the text(*.txt) in 'e:\a' - 2009-09-15, 21:53

Join Date: Jul 2009
Posts: 9
pacificace
Offline
Registered User
i have a question, given that you can access the txt file and append new entries in it, once i convert the whole code to sis, would i need more than just the user capabilities during the signing? would the ReadUserdata and WriteUserdata suffice the need for file access and modification.

I am working on making a log. E.g. every text msg sent via python, i would make a log and append it to an existing text entry in a text file.

Thanks.
Reply With Quote

#13 Old Smile Re: how to list the text(*.txt) in 'e:\a' - 2009-09-16, 02:37

Join Date: Jul 2008
Posts: 471
Location: Pakistan
sajisoft's Avatar
sajisoft
Offline
Regular Contributor
Quote:
Originally Posted by pacificace View Post
i have a question, given that you can access the txt file and append new entries in it, once i convert the whole code to sis, would i need more than just the user capabilities during the signing? would the ReadUserdata and WriteUserdata suffice the need for file access and modification.

I am working on making a log. E.g. every text msg sent via python, i would make a log and append it to an existing text entry in a text file.

Thanks.
Firstly, please start a new thread for a new issue :P . Secondly, yes u r right , u just need ReadUserData and WriteUserData which means u can self signed ur app . But remember u cant write to sensitive areas like c:\sys .

Best Regards,
SajiSoft


"The purpose of software engineering is to control complexity, not to create it."

--§ajid Ali Anjum--
http://sajisoft.wordpress.com/
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
File Browsing Problem Marwa Mobile Java Networking & Messaging & Security 13 2007-10-10 16:52
Change the List type of the LIST ??? divyas Mobile Java General 2 2006-09-15 21:27
6680 and bluetooth service profiles ceruault Mobile Java Networking & Messaging & Security 1 2005-10-08 23:24
Bluetooth Virtual Serial Port mealos Bluetooth Technology 2 2004-12-03 04:46
List item selection SanDan Mobile Java General 2 2003-05-06 11:57

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d81449X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZuserE5ftagQSxpythonX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ