after tests I get the following:

>>> import params
>>> dir(params)
['EntryTextMail', 'EntryTextName', '__builtins__', '__doc__', '__file__', '__name__', '__package__']
>>> params.EntryTextName
'myName'
>>> params.EntryTextMail
'mym...@gmail.com'

But the file to import should have '.py' extension (<Module>.py) (if there is a way to avoid that I wanted to use a 'hidden' file kind of ".config" , I can create a dynamical link to that file with <Module>.py then import it and at last delete the symbolic link). I should do a small class
for that to reuse it.

At first I tried to access it as variables instead of using <Module>.variable. I learnt something here!

Regards
Karim

On 08/24/2010 09:38 PM, Karim wrote:

Correction indents disappear (sic !) and lines are inverted (my mistake too)
 :o):

def sourceConfigGui(mySourceFile,path_to_mysourcefile):
        import sys
        sys.path.append(path_to_mysourcefile)
        import mySourceFile

Karim

On 08/24/2010 09:28 PM, Karim wrote:

Ok I find a solution (need to test it) that seems correct:

Suppose we have a python file mySourceFile with this setting:

EntryTextName = "myName"
EntryTextMail   = "mym...@gmail.com"

In the calling script or main python file we could define a function sourceConfigGui as follow:

def sourceConfigGui(mySourceFile,path_to_mysourcefile):

import mySourceFile
import sys
sys.path.append(path_to_mysourcefile)


If you have any other solution to source a external py file let me know.

Regards



On 08/24/2010 08:21 PM, Karim wrote:

Thank you Alan for your answer.
In fact I want to do it in python format.
I want to source it (I will declare it each
input as a python variable).
I don't want to parse it. I just want to source it
like an external file in bash for example.
Is there a way to not use string evaluation. But really load it
 as python setting file inside python program.

PS: ConfigParser, hum very good , this could be of use for other part...

Karim

On 08/24/2010 08:03 PM, Alan Gauld wrote:
"Karim" <karim.liat...@free.fr> wrote

I am figuring this out. I want a sort of file who store values entered previously in a gui.

Thats easy enough - have you succeeded with this bit - check the
file with a text editor...

Th e next time the user launch his gui in the same directory the gui load the previous value from this file.

Again thats pretty easy, did you get this working - create the file
with a text editior?

Is there any modules in Tkinter for that?

No, Tkinter is for building GUIs. Python core language includes
functions for reading and writing to files. Can you do this outside a GUI?

Write a program to read the users name and save it to a file.
Write a program to read the file and print the name it finds.
Write a program that says Hello <name> if it finds a name and asks for a name if it doesn't.

Now translate that to your GUI.

suppose the file could
be in xml format or whatever?

Yes, it could be in whatever. CSV, XML, ConfigParser or even plain text.

HTH,


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to