[Tutor] Fwd: Re: trouble placing code into wxpython
Steven D'Aprano
steve at pearwood.info
Thu Feb 2 13:37:31 CET 2012
shane wrote:
> i was trying to put the math.py into a frame Ive watched many tutorials.
> But cant seem to find out how to or where to place the code
> the files I want combined are attached.
Do you mean you want to show the code in the GUI? You need to know the
location of the file, then read the file and put the text into the frame. The
fact that the text is actually code is irrelevant -- it could be poetry, a
shopping list, code, or random gibberish.
I'm afraid I don't know enough about wxPython to tell you how to display text
in the frame, but you can read the file like this:
fp = open(r'C:\path\to\my\file\module.py', 'r')
text = fp.read()
fp.close()
Also I see that you have a file called "math.py". That is a bad idea, because
it will clash with a standard Python module also called "math". Best to find
another name for it.
--
Steven
More information about the Tutor
mailing list