2012-08-15 5 views

답변

7

알 수 있습니다.

c = Tkinter.Canvas(width=100, height=100, highlightthickness=0) 
>>> c.winfo_reqwidth() 
100 

내가 문제가 아니라 필요로하는 다른 사람에게 유용 할 수있는 디버깅 방법 :

import pprint 
pprint.pprint(c.configure()) 
{'background': ('background', 
       'background', 
       'Background', 
       'SystemButtonFace', 
       'SystemButtonFace'), 
'bd': ('bd', 'borderWidth'), 
'bg': ('bg', 'background'), 
'borderwidth': ('borderwidth', 'borderWidth', 'BorderWidth', '0', '0'), 
'closeenough': ('closeenough', 'closeEnough', 'CloseEnough', '1', '1.0'), 
'confine': ('confine', 'confine', 'Confine', '1', '1'), 
'cursor': ('cursor', 'cursor', 'Cursor', '', ''), 
'height': ('height', 'height', 'Height', '7c', '100'), 
'highlightbackground': ('highlightbackground', 
         'highlightBackground', 
         'HighlightBackground', 
         'SystemButtonFace', 
         'SystemButtonFace'), 
'highlightcolor': ('highlightcolor', 
        'highlightColor', 
        'HighlightColor', 
        'SystemWindowFrame', 
        'SystemWindowFrame'), 
'highlightthickness': ('highlightthickness', 
         'highlightThickness', 
         'HighlightThickness', 
         '2', 
         '0'), 
'insertbackground': ('insertbackground', 
         'insertBackground', 
         'Foreground', 
         'SystemButtonText', 
         'SystemButtonText'), 
'insertborderwidth': ('insertborderwidth', 
         'insertBorderWidth', 
         'BorderWidth', 
         '0', 
         '0'), 
'insertofftime': ('insertofftime', 'insertOffTime', 'OffTime', '300', '300'), 
'insertontime': ('insertontime', 'insertOnTime', 'OnTime', '600', '600'), 
'insertwidth': ('insertwidth', 'insertWidth', 'InsertWidth', '2', '2'), 
'offset': ('offset', 'offset', 'Offset', '0,0', '0,0'), 
'relief': ('relief', 'relief', 'Relief', 'flat', 'flat'), 
'scrollregion': ('scrollregion', 'scrollRegion', 'ScrollRegion', '', ''), 
'selectbackground': ('selectbackground', 
         'selectBackground', 
         'Foreground', 
         'SystemHighlight', 
         'SystemHighlight'), 
'selectborderwidth': ('selectborderwidth', 
         'selectBorderWidth', 
         'BorderWidth', 
         '1', 
         '1'), 
'selectforeground': ('selectforeground', 
         'selectForeground', 
         'Background', 
         'SystemHighlightText', 
         'SystemHighlightText'), 
'state': ('state', 'state', 'State', 'normal', 'normal'), 
'takefocus': ('takefocus', 'takeFocus', 'TakeFocus', '', ''), 
'width': ('width', 'width', 'Width', '10c', '100'), 
'xscrollcommand': ('xscrollcommand', 
        'xScrollCommand', 
        'ScrollCommand', 
        '', 
        ''), 
'xscrollincrement': ('xscrollincrement', 
         'xScrollIncrement', 
         'ScrollIncrement', 
         '0', 
         '0'), 
'yscrollcommand': ('yscrollcommand', 
        'yScrollCommand', 
        'ScrollCommand', 
        '', 
        ''), 
'yscrollincrement': ('yscrollincrement', 
         'yScrollIncrement', 
         'ScrollIncrement', 
         '0', 
         '0')} 

그래서 구성의 전체 집합을보고 후 나는 그것이 하이라이트 또는 closeenough 매개 변수 중 하나를 짐작.

+0

다음 예를 통해 시각적으로 확인할 수 있습니다. [link] (http://stackoverflow.com/a/11894636/1217270). 'highlightthickness = 0'을 추가하면 사라지는 얇은 밝은 회색 테두리를 볼 수 있습니다. –

0

winfo_reqwith()winfo_reqheight() 메서드는 실제 위젯의 너비와 높이를 반환하지 않기 때문에. 이 문서는 말씀입니다 :

winfo_reqheight(), winfo_reqwidth(). 

반환 자기의 "자연"높이 (폭). 자연적인 크기는 최소 크기는 으로, 패딩, 테두리 등을 포함하여 위젯의 내용을 표시하는 데 필요합니다. 이 크기는 주어진 옵션을 기반으로 위젯 자체에 의해 계산됩니다. 실제 위젯 크기는이 값, 위젯의 마스터 크기 및 geometry 관리자에 지정된 옵션에 따라 위젯의 형상 인 관리자에 의해 결정됩니다.

+1

이것이 질문에 어떻게 대답하는지 모르겠습니다. 질문자는'winfo_reqwidth'가 반환하는 것을 알고 있다고 생각합니다. 요청 된 너비와 높이 이외의 값을 반환하는지 묻습니다. –

관련 문제