dummy tk windows

Christos TZOTZIOY Georgiou tzot at sil-tec.gr
Wed Sep 29 03:29:51 EDT 2004


On Fri, 17 Sep 2004 09:19:26 GMT, rumours say that "Elaine Jackson"
<elainejackson7355 at home.com> might have written:

>"Paul Miller" <pwmiller1 at adelphia.net> wrote in message
>news:pan.2004.09.17.04.39.08.814115 at adelphia.net...
><snip> HTH
>
>It did. Thank you. I made a wrapper for this stuff that I'll include here for
>the benefit of anyone who may be following the discussion from the sidelines.
>
>Peace
>
>def dialog(className):
>    from Tkinter import Tk
>    from tkFileDialog import Open,SaveAs,Directory
>    Tk().withdraw()
>    name = eval(className)().show()
>    if className=='Directory': return name
>    mode = (className=='Open' and 'r') or (className=='SaveAs' and 'w')
>    return file(name,mode)
>

Elaine,

"""eval(className)""" is generally insecure.  Another (more secure and
direct) idea would be to """import tkFileDialog""" and then use
"""getattr(tkFileDialog, className)""" instead.
-- 
TZOTZIOY, I speak England very best,
"Tssss!" --Brad Pitt as Achilles in unprecedented Ancient Greek



More information about the Python-list mailing list