首页 / PYTHON / python滚动解决方法
python滚动解决方法
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了python滚动解决方法,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1767字,纯文字阅读大概需要3分钟。
内容图文
![python滚动解决方法](/upload/InfoBanner/zyjiaocheng/655/a78f9348d5424b51ad14a46c37565b67.jpg)
我倾向于在我的python程序中与文本相关的所有内容都使用标签.在为大约50个引用编码了一个很长的标签之后,我现在陷入了一个带有多行标签的顶层窗口,需要一个滚动条,并且标签不会滚动.
我在窗口上有滚动条,但它没有滚动.有没有可以在“文本”标签上上下滚动的解决方法,还是需要在顶层窗口中放置其他小部件?
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")
解决方法:
您不能将滚动条与标签一起使用.
使用文本代替:
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()
这样会产生(您可能应该修改文本格式):
内容总结
以上是互联网集市为您收集整理的python滚动解决方法全部内容,希望文章能够帮你解决python滚动解决方法所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。