[Tutor] Retriving previous user inputs in a gui
Karim
karim.liateni at free.fr
Tue Aug 24 21:28:15 CEST 2010
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 = "myMail at 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.liateni at 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 at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list