[Python-checkins] CVS: python/dist/src/Lib/lib-tk ScrolledText.py,1.10,1.11

Guido van Rossum gvanrossum@users.sourceforge.net
2001年12月10日 08:42:46 -0800


Update of /cvsroot/python/python/dist/src/Lib/lib-tk
In directory usw-pr-cvs1:/tmp/cvs-serv22951
Modified Files:
	ScrolledText.py 
Log Message:
SF patch #491183 (Jeff Epler): ScrolledText.grid() doesn't work
Using grid methods on ScrolledText widgets does not 
work as expected. It either fails to pack a widget, or 
can even cause Tk to lock up. 
The problem is that the .grid method is being called on 
the text widget, not the frame widget. This can lead 
to the well-known lockup in Tk when a frame's children 
are managed by both the pack and grid managers. Even 
if it doesn't lock up, the frame is never placed within 
the intended widget. 
Program fragment: 
>>> import ScrolledText 
>>> s = ScrolledText.ScrolledText() 
>>> s.grid(row=0, column=0, rowspan=2) 

The following patch uses the same hack to copy the 
'grid' and 'place' geometry manager methods to the 
ScrolledText instance as is already used for the 'pack' 
manager. 
Index: ScrolledText.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/lib-tk/ScrolledText.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ScrolledText.py	2000年10月23日 18:31:14	1.10
--- ScrolledText.py	2001年12月10日 16:42:43	1.11
***************
*** 34,39 ****
 self.vbar['command'] = self.yview
 
! # Copy Pack methods of self.frame -- hack!
! for m in Pack.__dict__.keys():
 if m[0] != '_' and m != 'config' and m != 'configure':
 setattr(self, m, getattr(self.frame, m))
--- 34,43 ----
 self.vbar['command'] = self.yview
 
! # Copy geometry methods of self.frame -- hack!
! 	methods = Pack.__dict__.keys()
! 	methods = methods + Grid.__dict__.keys()
! 	methods = methods + Place.__dict__.keys()
! 
! for m in methods:
 if m[0] != '_' and m != 'config' and m != 'configure':
 setattr(self, m, getattr(self.frame, m))

AltStyle によって変換されたページ (->オリジナル) /