[Tkinter-discuss] StringVar fails to honor None

Russell Adams RLAdams at AdamsInfoServ.Com
Thu Jan 17 00:11:52 CET 2013


Found this while reverting a data entry form to database values (ie:
Undo), all my fields became "None". Set changes None to a string,
creating with value= doesn't.

Seems inconsistent, is this intentional or to be expected?

--

#!/usr/bin/env python3

from tkinter import *
from tkinter import ttk
import tkinter.font as tkFont

root = Tk()

print("Creating a stringvar")
derp=StringVar(value=None)
print("Derp was created with value of None, it's value is '{}'.".format(derp.get()))

print("Now setting derp to None again")
derp.set(None)
print("Derp was set to None, it's value is '{}'.".format(derp.get()))

assert derp.get() == ''



------------------------------------------------------------------
Russell Adams                            RLAdams at AdamsInfoServ.com

PGP Key ID:     0x1160DCB3           http://www.adamsinfoserv.com/

Fingerprint:    1723 D8CA 4280 1EC9 557F  66E8 1154 E018 1160 DCB3


More information about the Tkinter-discuss mailing list