python Tkinter的Text組件中創建x軸和y軸滾動條


#!/usr/bin/python
#coding: utf-8
 
from Tkinter import *
 
root = Tk()
root.title("記事本")
root.geometry("800x600+100+100")
 
s1 = Scrollbar(root)
s1.pack(side = RIGHT, fill = Y)
# HORIZONTAL 設置水平方向的滾動條,默認是豎直
s2 = Scrollbar(root, orient = HORIZONTAL)
s2.pack(side = BOTTOM, fill = X)
 
 
# 創建文本框
# wrap 設置不自動換行
textpad = Text(root, width = 200, yscrollcommand = s1.set, xscrollcommand = s2.set, wrap = 'none')
textpad.pack(expand = YES,fill = BOTH)
 
s1.config(command = textpad.yview)
s2.config(command = textpad.xview)
 
root.mainloop()

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM