Tkinter Scrollbar Grayed Out

时间:2018-05-05 17:57:04

标签: python python-3.x user-interface tkinter scrollbar

我有一个GUI,底部有一个消息框(一个包含画布的框架,另一个框架在该画布内,还有一个滚动条)。所有内容都正确显示在窗口中,但滚动条始终显示为灰色,无法滚动。谁知道怎么修它? (我知道有些人问了类似的问题,但我还没有能够用我读过的任何答案来修复我的代码。)

    frmMess = Frame(self.window)
    frmMess.pack(side = BOTTOM)
    frmMess.pack(expand = True, fill = X)
    frmMess.bind("<Configure>", lambda e: msgPark.configure(width=e.width-10))         

    self.canvas_main = Canvas(frmMess)
    self.canvas_main.pack(side = LEFT)
    self.canvas_main.pack(expand = True, fill = X)
    self.canvas_main.bind("<Configure>", lambda e: msgPark.configure(width=e.width-10)) 
    self.canvas_main.configure(scrollregion = self.canvas_main.bbox('all'))


    self.frmMessageBox = Frame(self.canvas_main, bg = self.bgcolor_m)
    self.frmMessageBox.pack(side = BOTTOM)
    self.frmMessageBox.pack(expand = True, fill = X)
    self.frmMessageBox.bind("<Configure>", lambda e: msgPark.configure(width=e.width-10)) 

    messageScroll = Scrollbar(frmMess, orient = "vertical")
    self.canvas_main.configure(yscrollcommand = messageScroll.set)
    messageScroll.pack(side = LEFT, fill = Y)
    messageScroll.configure(command = self.canvas_main.yview)

我稍后调用一个函数将消息放入嵌入框架(最初为空)。我不知道问题是来自我后来打电话的功能,还是原来的设置

addMessage():
    event = myString
    msgPark = Message(self.frmMessageBox, text = event, bg = self.bgcolor_m,
                      pady = 5, padx = 10)
    msgPark.pack(expand = True, fill = X)
    msgPark.bind("<Configure>", lambda e: msgPark.configure(width=e.width-10)) 

有什么建议吗?

0 个答案:

没有答案