2012-01-08 19 views
3

私は、私のPythonプログラムでテキスト関連のものすべてにラベルを使用する傾向があります。約50の参照用に非常に長いラベルをコーディングした後は、複数のラインラベルを持つトップレベルのウィンドウがスクロールバーを必要とし、ラベルがスクロールしません。python scroll回避策

私はウィンドウ上にスクロールバーを持っていますが、スクロールしません。私の 'テキスト'ラベルを上下にスクロールするための回避策がありますか、または私のトップレベルのウィンドウに配置する別のウィジェットが必要ですか?

 filewin = Toplevel(background="white") 

     scrollbar=Scrollbar(filewin) 
     scrollbar.pack(side=RIGHT, fill=Y) 
     yscrollcommand=scrollbar.set 


     Label(filewin, text=". . .\n \ 
    Acidophilium \n\ 
      Wichlacz,P.L., Unz,R.F., Langworthy,T.A. 1986. Acidiphilium angustum sp. nov. Acidiphilium facilis sp. nov. and Acidiphilium vubrum sp. nov. : \n\ 
       Acidophilic Heterotrophic Bacteria Isolated from Acidic Coal Mine Drainage. Int J Syst Bacteriol 36:197-201. \n\ 
    Acinetobacter \n\ 
      Bouvet,P.J.M., Grimont,P.A.D. 1986. Taxonomy of the Genus Acinetobacter with the Recognition of Acinetobacter baumannii sp. nov. Acinetobacter haemolyticus sp. \n\ 
       nov. Acinetobacter johnsonii sp. nov. and Acinetobacter junii sp. nov. and Emended Descriptions of Acinetobacter calcoaceticus and Acinetobacter lwofii. \n\ 
       Int J Syst Bacteriol 36:228-240.", 
     justify=LEFT, background="white", foreground="black", wraplength=1000).pack() 
     filewin.title("Matrix References") 
+7

あなたはおそらく、あなたの使ってどのようなGUIツールキット言及する必要があります。 –

+0

これは本当にPythonの質問ではありません。 –

+0

私たちが実行できるように、インポートなどのコードをいくつか追加するとよいでしょう。 –

答えて

3

ラベルが付いたスクロールバーは使用できません。代わりに
使用Text

これは生産
from Tkinter import * 

root = Tk() 

mytext = "Here_your very long text" 

scrbar = Scrollbar(root, orient=VERTICAL) 
scrbar.pack(side=RIGHT,fill=Y) 

text = Text(root, width=80, height=10, state=NORMAL, background="white", foreground="black") 
text.insert(INSERT, mytext) 
text['state'] = DISABLED 
text.pack() 

text['yscrollcommand'] = scrbar.set 
scrbar['command'] = text.yview 

root.title("Matrix References") 
root.mainloop() 

(あなたはおそらくテキスト形式を適応させる必要がありますが):

enter image description here