]> granicus.if.org Git - python/commitdiff
Use a better way to bind the checkext instance variable to a check
authorGuido van Rossum <guido@python.org>
Thu, 5 Mar 1998 20:12:18 +0000 (20:12 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 5 Mar 1998 20:12:18 +0000 (20:12 +0000)
button widget, not involving a __getattr__() method but a callback on
the widget.

Tools/webchecker/wcgui.py

index 10c77d014da61e6f65e01680b43a0f60edb17aaf..027718fb5bf2c266f3308bf18891a53d647efee3 100755 (executable)
@@ -120,10 +120,11 @@ class CheckerWindow(webchecker.Checker):
        self.__step = Button(self.__controls, text="Check one",
                             command=self.step)
        self.__step.pack(side=LEFT)
-       self.__cv = BooleanVar()
-       self.__cv.set(1)
+       self.__cv = BooleanVar(parent)
+       self.__cv.set(self.checkext)
        self.__checkext = Checkbutton(self.__controls, variable=self.__cv,
-                                     text="Check nonlocal links")
+                                     command=self.update_checkext,
+                                     text="Check nonlocal links",)
        self.__checkext.pack(side=LEFT)
        self.__reset = Button(self.__controls, text="Start over", command=self.reset)
        self.__reset.pack(side=LEFT)
@@ -144,17 +145,12 @@ class CheckerWindow(webchecker.Checker):
        self.__errors = ListPanel(mp, "Pages w/ bad links", self.showinfo)
        self.__details = LogPanel(mp, "Details")
        webchecker.Checker.__init__(self)
-       del self.checkext # See __getattr__ below
        if root:
            root = string.strip(str(root))
            if root:
                self.suggestroot(root)
        self.newstatus()
 
-    def __getattr__(self, name):
-       if name != 'checkext': raise AttributeError, name
-       return self.__cv.get()
-
     def reset(self):
        webchecker.Checker.reset(self)
        for p in self.__todo, self.__done, self.__bad, self.__errors:
@@ -299,6 +295,9 @@ class CheckerWindow(webchecker.Checker):
        self.__status.config(text="Status: "+self.status())
        self.__parent.update()
 
+    def update_checkext(self):
+       self.checkext = self.__cv.get()
+
 
 class ListPanel:
 
@@ -395,7 +394,7 @@ class MultiPanel:
        self.panels = {}
 
     def addpanel(self, name, on=0):
-       v = StringVar()
+       v = StringVar(self.parent)
        if on:
            v.set(name)
        else: