【发布时间】:2014-07-08 04:29:45
【问题描述】:
我有一个只有一个文本区域的文本编辑器 GUI。我添加了一个滚动条,它将 GUI 的大小调整为非常小,这是脚本的顶部。
请记住,在我添加滚动条之前,GUI 有点大,这正是我想要的。
class Application(Frame):
def __init__(self, parent):
Frame.__init__(self,parent)
self.pack(side=LEFT,fill=BOTH,expand=YES)
self.saved = None
self.fontcolor = "Black"
self.backgroundcolor = "White"
self.fontsize = IntVar()
self.check = None
self.create_widgets()
def create_widgets(self):
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="New", command=self.newfile)
filemenu.add_command(label="Open", command=self.openfile)
filemenu.add_command(label="Save", command=self.savefile)
filemenu.add_command(label="Save As", command=self.saveas_file)
menubar.add_cascade(label="File", menu=filemenu)
formatmenu = Menu(menubar, tearoff=0)
formatmenu.add_command(label="Font Size", command=self.fsc)
formatmenu.add_command(label="Font Color", command=self.fcc)
formatmenu.add_command(label="Background Color", command=self.bcc)
menubar.add_cascade(label="Format", menu=formatmenu)
helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="View help", command=self.helpfile)
menubar.add_cascade(label="help", menu=helpmenu)
root.config(menu=menubar)
self.Cont = Text(self,wrap=WORD)
self.Cont.pack(side=LEFT,fill=BOTH,expand=YES)
self.Scroll = Scrollbar(self.Cont)
self.Scroll.pack(side=RIGHT,fill=Y)
self.Cont.configure(yscrollcommand=self.Scroll.set)
root.protocol("WM_DELETE_WINDOW", self.verify)
【问题讨论】:
-
你的代码缩进不正确。
标签: python user-interface tkinter scrollbar