Posts

Showing posts with the label PyS60

Py2SIS create sis file to make standalone application

You have coded the program and tested it using PyS60 emulator or in your mobile phone. Now you want to make standalone application out of your Python code to deploy in mobile phones. You have to create SIS (Symbian Installation System) file. Format of the command is: py2sis [sisfile] [--uid=0x12345678] [--appname=myapp] [--presdk20] [--leavetemp] I used the following command to create SIS file for my program: F:\Nokia\Tools\Python_for_Series_60\py2sis>py2sis.exe dse_stock_tracker.py dse.sis --uid 0x12345678 --appname=DSEStockPriceTracker If you want to know details about py2sis, get the book (ebook is there) "Programming with Python for Series 60 Platform" and go to chapter 14. The book is freely available.

Create selection list from a file in PyS60

Image
Let's come back to the project - DSE price tracker. The next step was to load all the company names from a file (stored in the mobile phone memory) and display in the selection list. The file contains the company names, one per line. So I wrote the following code: import appuifw def get_data_from_file(): fp = open('c:\\names.txt', 'r') li = fp.readlines() fp.close() compList = [] for item in li: item = item.decode("utf-8") compList.append(item) return compList L = get_data_from_file() index = appuifw.selection_list(choices=L , search_field=1) Yes, it works. Note that you must decode each line to unicode (utf-8). ( item = item.decode("utf-8") ) But wait, what are those small boxes beside each name? I guess it's the newline character ('\n') after each line. So I need to replace '\n' with a blank ''. Here is the modified get_data_from_file() def get_data_from_file(): fp = open...

Create a selection list in PyS60

Image
Creating a selection list for my software - 'DSE Stock Tracker' was very important task. It will show the list of companies of Dhaka Stock Exchange. So for demo I tried to create a list of four companies. Here is the code: import appuifw L = ['DHAKABANK', 'AIMS1STMF', 'EXIMBANK', 'TRUSTBANK'] index = appuifw.selection_list(choices=L , search_field=1) I tried to run the program but got the following error: SymbianError: [Errno -6] KErrArgument Oh, I forgot to add the 'u' (u for unicode) before each string. So I changed my code and it works. import appuifw L = [u'DHAKABANK', u'AIMS1STMF', u'EXIMBANK', u'TRUSTBANK'] index = appuifw.selection_list(choices=L , search_field=1) Now, as there are hundreds of companies, it's not wise to write every name in the code. So the next to-do is load the list from a file.