test_extensions.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:zippy 作者: securesystemslab 项目源码 文件源码
def test_widget_destroy(self):
        # automatically created variable
        x = ttk.LabeledScale()
        var = x._variable._name
        x.destroy()
        self.assertRaises(tkinter.TclError, x.tk.globalgetvar, var)

        # manually created variable
        myvar = tkinter.DoubleVar()
        name = myvar._name
        x = ttk.LabeledScale(variable=myvar)
        x.destroy()
        self.assertEqual(x.tk.globalgetvar(name), myvar.get())
        del myvar
        self.assertRaises(tkinter.TclError, x.tk.globalgetvar, name)

        # checking that the tracing callback is properly removed
        myvar = tkinter.IntVar()
        # LabeledScale will start tracing myvar
        x = ttk.LabeledScale(variable=myvar)
        x.destroy()
        # Unless the tracing callback was removed, creating a new
        # LabeledScale with the same var will cause an error now. This
        # happens because the variable will be set to (possibly) a new
        # value which causes the tracing callback to be called and then
        # it tries calling instance attributes not yet defined.
        ttk.LabeledScale(variable=myvar)
        if hasattr(sys, 'last_type'):
            self.assertFalse(sys.last_type == tkinter.TclError)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号