On 13 Sep 2005 08:51:47 +0100, Ian Vincent <[EMAIL PROTECTED]> wrote:

> I am hoping someone may be able to help.
>
> I am using Python and TKinter to create a GUI program that will
> eventually create an XML file for a project I am working on. Now, the XML
> file contents changes depending on the type of file it represents - so I
> am dynamically creating the TK Entry boxes. The problem is, I want the
> variable assigned to each of these boxes to be dynamically assigned as
> well but I cannot see how to do this (if it is indeed possible).
>
> Example
>
> If the file the XML is to represent is a spreadsheet - I want the first
> entry box to be:
>
> spreadsheetField = StringVar()
> value = Entry(root, relief=SUNKEN, justify=LEFT,
> textvariable=spreadsheetField)
>
> however, if the file is a document - I want the first entry box to be:
>
> documentField = StringVar()
> value = Entry(root, relief=SUNKEN, justify=LEFT,
> textvariable=documentField)
>
> I have quite a few Entry boxes for each file type (about 10) and a lot of
> filetypes (over 80), so I do not want to have a custom function for each
> filetype if I can help it.

Your requirements are not very precise here. What do represent the entry 
fields? How do you build them? Are they always strings or can they be integers, 
or floats, or anything else? Do you have only entry fields or other widgets as 
well (check buttons, radio buttons, ...)? How do you know the format of the 
dialog you build?

> I have looked at using a dictionary but I cannot get my head around how
> to do that either.

This is the way I would go, but without answering the questions above, I won't 
be able to give you much advice. Supposing you have only entry fields accepting 
strings, a mapping file type -> field name -> StringVar may be a good solution.

HTH
-- 
python -c "print ''.join([chr(154 - ord(c)) for c in 
'U(17zX(%,5.zmz5(17;8(%,5.Z65\'*9--56l7+-'])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to