Error using tkinter

J

JyotiC

Hi,

I am making a gui, in which specifiction are taken from user, which are
wriiten to a file. and that file will bw executed.

finalstr is a string

f = open('crossManual.sh','w')
f.write(finalstr)
f.close()

I am getting the error

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "gui.py", line 248, in writescript
f = open('crossManual.sh','w')
TypeError: an integer is required

Couldn't understand what it means
Plz tell me how to correct it.

Thanx in advance
 
F

Fredrik Lundh

JyotiC said:
I am getting the error

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
File "gui.py", line 248, in writescript
f = open('crossManual.sh','w')
TypeError: an integer is required

Couldn't understand what it means

let me guess: gui.py contains the line "from os import *" ?

this means that "open" refers to os.open, which is not the same thing as the
built-in open function.

the solution? use "import os", and add "os." in front of all functions from
that module. never use from-import in application code, unless you have
very good reasons:

http://effbot.org/zone/import-confusion.htm#which-way-should-i-use

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top