| Reply | « Previous Thread | Next Thread » |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
hi to all
i want to make a file whose contents are constantly changing with a function whose output are simple integer numbers. i am trying to write the output of the function in the file using f.write() but i am not sucessfull can anyone help me out. thanks a lot Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Quote:
And remember to post the code using the CODE(#) tabs ![]() Best Regards, Croozeus |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
my code goes like this
Code:
def myfunction()
whose output goes changing with a single click
input = myfunction()
logfile = open('c:\\test.txt','w')
logfile.write(input)
logfile.close()
argument 1 must be a string or read only character buffer not none. my outputs are numbers Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Please post the code for myfunction()
Quote:
![]() Best Regards, Croozeus |
|
Oh my friend, use of keyword "input" is giving you an error. Try with some other like xyz
Code:
def myfunction()
whose output goes changing with a single click
xyz = myfunction()
logfile = open('c:\\test.txt','w')
logfile.write(xyz)
logfile.close()
IDEAS is all they need but still they think only Genius can give them that. |
| shubhendra |
| View Public Profile |
| Find all posts by shubhendra |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
nice question croozeus
![]() ![]() ![]() by a click means whenever i press a button in my keypad the output of myfunction changes. hope you got it this time and that change i want to write it in a file. waitin for ur reply Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Online
Forum Nokia Champion
|
|
|
Quote:
Please post the code for myfunction() |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
|
Quote:
i am not using the text input as i shown it as an example only. Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Quote:
Quote:
Croozeus |
|
Join Date: Feb 2008
Posts: 2,542
Location: Bhavnagar, Gujarat, India
gaba88
Offline
Forum Nokia Champion
|
|
hi bogdan after all you got my real name
![]() ![]() sorry for replying late my code goes like this" Code:
import appuifw
import graphics
import e32
keyboard_state={}
last_keycode=0
def myfunction():
canvas.clear()
canvas.text((0,48),u'Last received keycode:', 0x008000)
f = canvas.text((0,60),u'%s'%(last_keycode))
logfile = open('c://keylogger.txt','w')
logfile.write(f)
logfile.close()
hope you all will help me when i m makin a write to a file it give a error Gargi Das- http://gargidas.blogsot.com Forum Nokia Python Wiki Learn Python at http://mobapps.org/PyS60 |
|
Quote:
1) Where have you defined "canvas" ? Defining Canvas is missing. 2) You mixed up the slashes in the path. It should be \\ instead of // 3) You are trying to write the latest keypress on the canvas. But again why do you want to write the canvas to the file ![]() and you make last_keycode=0 so you want to write "0 " everywhere. Why do all this stuff then? ![]() Does it make sense to any one? Best Regards, Croozeus |
|
Join Date: Oct 2007
Posts: 2,841
Location: Deva, Romania
Online
Forum Nokia Champion
|
|
Definitely not to me.
gaba88, please try to build your code as logically as possible. And maybe you should add comments. |
|
I strongly recommend gabba88 to read the Mobile Python Book based on Rapid Prototyping of Applications on the Mobile Platform by Jürgen Scheible and Ville Tuulos.
Its a must read book for PyS60 developers, especially begineers. Best Regards, Croozeus |
|
gaba88 what you wont to do?
if you wont only write last_keycode to file do soCode:
import appuifw
import graphics
import e32
keyboard_state={}
last_keycode=0
def myfunction():
canvas.clear()
f=str(last_keycode)
canvas.text((0,48),u'Last received keycode:'+f, 0x008000)
logfile = open('c://keylogger.txt','w')
logfile.write(f)
logfile.close()
|
|
@gaba
The error you mentioned earlier says you want to write a number to a file. You can't do that by directly passing a number to write() method. A file is a stream of bytes/chars, in ither words a string. Therefore you first have to convert your number to a string. The simpliest way is: Code:
logfile.write(str(f)) |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Theme Studio 3.1 not creating themes | zemm | Themes/Carbide.ui | 11 | 2008-10-18 09:41 |
| Problem with pyobfuscate | JOM | Python | 3 | 2008-06-20 23:47 |
| Reading and writing to file | rkuppala | General Symbian C++ | 6 | 2008-03-13 10:59 |
| File reading & writing help, wav file redaing help | shubhamlahoti | Mobile Java General | 6 | 2007-06-27 10:07 |
| Writing descriptor to file without length property | toshaga | General Symbian C++ | 1 | 2006-11-16 20:51 |