2012-08-15 6 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(). 

戻る "自然な" 高さ (幅)自己のために:これは、ドキュメントが言うことです。自然なサイズは最小サイズは のように、パッド、罫線などを含むウィジェットのコンテンツを表示する必要があります。この のサイズは、指定されたオプションに基づいてウィジェット自体によって計算されます。 実際のウィジェットサイズは、この値、ウィジェットのマスターのサイズ、およびジオメトリマネージャに与えられた オプションに基づいて、ウィジェットのジオメトリ マネージャによって決定されます。

+1

これがどのように質問に答えるかわかりません。私は質問者が 'winfo_reqwidth'が返すものを知っていると思っています、彼らは要求された幅と高さ以外のものを_why_に返しています。 –

関連する問題