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

Skip to content

Commit c0967cd

Browse files
committed
Added a bunch of new winfo options; we should now be up to date with
Tk 4.2. The new winfo options supported are: mananger, pointerx, pointerxy, pointery, server, viewable, visualid, visualsavailable. Also fixed bugs in winfo_colormapfull() and winfo_containing().
1 parent e4ac0aa commit c0967cd

2 files changed

Lines changed: 58 additions & 4 deletions

File tree

Lib/lib-tk/Tkinter.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,13 @@ def winfo_class(self):
297297
return self.tk.call('winfo', 'class', self._w)
298298
def winfo_colormapfull(self):
299299
return self.tk.getboolean(
300-
self.tk.call('winfo', 'colormapfull'))
300+
self.tk.call('winfo', 'colormapfull', self._w))
301301
def winfo_containing(self, rootX, rootY, displayof=0):
302302
args = ('winfo', 'containing') \
303303
+ self._displayof(displayof) + (rootX, rootY)
304-
return self._nametowidget(apply(self.tk.call, args))
304+
name = apply(self.tk.call, args)
305+
if not name: return None
306+
return self._nametowidget(name)
305307
def winfo_depth(self):
306308
return self.tk.getint(self.tk.call('winfo', 'depth', self._w))
307309
def winfo_exists(self):
@@ -324,6 +326,8 @@ def winfo_interps(self, displayof=0):
324326
def winfo_ismapped(self):
325327
return self.tk.getint(
326328
self.tk.call('winfo', 'ismapped', self._w))
329+
def winfo_manager(self):
330+
return self.tk.call('winfo', 'manager', self._w)
327331
def winfo_name(self):
328332
return self.tk.call('winfo', 'name', self._w)
329333
def winfo_parent(self):
@@ -335,6 +339,15 @@ def winfo_pathname(self, id, displayof=0):
335339
def winfo_pixels(self, number):
336340
return self.tk.getint(
337341
self.tk.call('winfo', 'pixels', self._w, number))
342+
def winfo_pointerx(self):
343+
return self.tk.getint(
344+
self.tk.call('winfo', 'pointerx', self._w))
345+
def winfo_pointerxy(self):
346+
return self._getints(
347+
self.tk.call('winfo', 'pointerxy', self._w))
348+
def winfo_pointery(self):
349+
return self.tk.getint(
350+
self.tk.call('winfo', 'pointery', self._w))
338351
def winfo_reqheight(self):
339352
return self.tk.getint(
340353
self.tk.call('winfo', 'reqheight', self._w))
@@ -372,11 +385,25 @@ def winfo_screenvisual(self):
372385
def winfo_screenwidth(self):
373386
return self.tk.getint(
374387
self.tk.call('winfo', 'screenwidth', self._w))
388+
def winfo_server(self):
389+
return self.tk.call('winfo', 'server', self._w)
375390
def winfo_toplevel(self):
376391
return self._nametowidget(self.tk.call(
377392
'winfo', 'toplevel', self._w))
393+
def winfo_viewable(self):
394+
return self.tk.getint(
395+
self.tk.call('winfo', 'viewable', self._w))
378396
def winfo_visual(self):
379397
return self.tk.call('winfo', 'visual', self._w)
398+
def winfo_visualid(self):
399+
return self.tk.call('winfo', 'visualid', self._w)
400+
def winfo_visualsavailable(self, includeids=0):
401+
data = self.tk.split(
402+
self.tk.call('winfo', 'visualsavailable', self._w,
403+
includeids and 'includeids' or None))
404+
def parseitem(x, self=self):
405+
return x[:1] + tuple(map(self.tk.getint, x[1:]))
406+
return map(parseitem, data)
380407
def winfo_vrootheight(self):
381408
return self.tk.getint(
382409
self.tk.call('winfo', 'vrootheight', self._w))

Lib/tkinter/Tkinter.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,13 @@ def winfo_class(self):
297297
return self.tk.call('winfo', 'class', self._w)
298298
def winfo_colormapfull(self):
299299
return self.tk.getboolean(
300-
self.tk.call('winfo', 'colormapfull'))
300+
self.tk.call('winfo', 'colormapfull', self._w))
301301
def winfo_containing(self, rootX, rootY, displayof=0):
302302
args = ('winfo', 'containing') \
303303
+ self._displayof(displayof) + (rootX, rootY)
304-
return self._nametowidget(apply(self.tk.call, args))
304+
name = apply(self.tk.call, args)
305+
if not name: return None
306+
return self._nametowidget(name)
305307
def winfo_depth(self):
306308
return self.tk.getint(self.tk.call('winfo', 'depth', self._w))
307309
def winfo_exists(self):
@@ -324,6 +326,8 @@ def winfo_interps(self, displayof=0):
324326
def winfo_ismapped(self):
325327
return self.tk.getint(
326328
self.tk.call('winfo', 'ismapped', self._w))
329+
def winfo_manager(self):
330+
return self.tk.call('winfo', 'manager', self._w)
327331
def winfo_name(self):
328332
return self.tk.call('winfo', 'name', self._w)
329333
def winfo_parent(self):
@@ -335,6 +339,15 @@ def winfo_pathname(self, id, displayof=0):
335339
def winfo_pixels(self, number):
336340
return self.tk.getint(
337341
self.tk.call('winfo', 'pixels', self._w, number))
342+
def winfo_pointerx(self):
343+
return self.tk.getint(
344+
self.tk.call('winfo', 'pointerx', self._w))
345+
def winfo_pointerxy(self):
346+
return self._getints(
347+
self.tk.call('winfo', 'pointerxy', self._w))
348+
def winfo_pointery(self):
349+
return self.tk.getint(
350+
self.tk.call('winfo', 'pointery', self._w))
338351
def winfo_reqheight(self):
339352
return self.tk.getint(
340353
self.tk.call('winfo', 'reqheight', self._w))
@@ -372,11 +385,25 @@ def winfo_screenvisual(self):
372385
def winfo_screenwidth(self):
373386
return self.tk.getint(
374387
self.tk.call('winfo', 'screenwidth', self._w))
388+
def winfo_server(self):
389+
return self.tk.call('winfo', 'server', self._w)
375390
def winfo_toplevel(self):
376391
return self._nametowidget(self.tk.call(
377392
'winfo', 'toplevel', self._w))
393+
def winfo_viewable(self):
394+
return self.tk.getint(
395+
self.tk.call('winfo', 'viewable', self._w))
378396
def winfo_visual(self):
379397
return self.tk.call('winfo', 'visual', self._w)
398+
def winfo_visualid(self):
399+
return self.tk.call('winfo', 'visualid', self._w)
400+
def winfo_visualsavailable(self, includeids=0):
401+
data = self.tk.split(
402+
self.tk.call('winfo', 'visualsavailable', self._w,
403+
includeids and 'includeids' or None))
404+
def parseitem(x, self=self):
405+
return x[:1] + tuple(map(self.tk.getint, x[1:]))
406+
return map(parseitem, data)
380407
def winfo_vrootheight(self):
381408
return self.tk.getint(
382409
self.tk.call('winfo', 'vrootheight', self._w))

0 commit comments

Comments
 (0)