Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88b02cf

Browse files
committed
Use a better way to bind the checkext instance variable to a check
button widget, not involving a __getattr__() method but a callback on the widget.
1 parent 2135117 commit 88b02cf

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

Tools/webchecker/wcgui.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ def __init__(self, parent, root=webchecker.DEFROOT):
120120
self.__step = Button(self.__controls, text="Check one",
121121
command=self.step)
122122
self.__step.pack(side=LEFT)
123-
self.__cv = BooleanVar()
124-
self.__cv.set(1)
123+
self.__cv = BooleanVar(parent)
124+
self.__cv.set(self.checkext)
125125
self.__checkext = Checkbutton(self.__controls, variable=self.__cv,
126-
text="Check nonlocal links")
126+
command=self.update_checkext,
127+
text="Check nonlocal links",)
127128
self.__checkext.pack(side=LEFT)
128129
self.__reset = Button(self.__controls, text="Start over", command=self.reset)
129130
self.__reset.pack(side=LEFT)
@@ -144,17 +145,12 @@ def __init__(self, parent, root=webchecker.DEFROOT):
144145
self.__errors = ListPanel(mp, "Pages w/ bad links", self.showinfo)
145146
self.__details = LogPanel(mp, "Details")
146147
webchecker.Checker.__init__(self)
147-
del self.checkext # See __getattr__ below
148148
if root:
149149
root = string.strip(str(root))
150150
if root:
151151
self.suggestroot(root)
152152
self.newstatus()
153153

154-
def __getattr__(self, name):
155-
if name != 'checkext': raise AttributeError, name
156-
return self.__cv.get()
157-
158154
def reset(self):
159155
webchecker.Checker.reset(self)
160156
for p in self.__todo, self.__done, self.__bad, self.__errors:
@@ -299,6 +295,9 @@ def newstatus(self):
299295
self.__status.config(text="Status: "+self.status())
300296
self.__parent.update()
301297

298+
def update_checkext(self):
299+
self.checkext = self.__cv.get()
300+
302301

303302
class ListPanel:
304303

@@ -395,7 +394,7 @@ def __init__(self, parent):
395394
self.panels = {}
396395

397396
def addpanel(self, name, on=0):
398-
v = StringVar()
397+
v = StringVar(self.parent)
399398
if on:
400399
v.set(name)
401400
else:

0 commit comments

Comments
 (0)