简体   繁体   English

Tkinter滚动条槽请点击

[英]Tkinter scrollbar trough click

Is there a bug in the natural scrollbar trough click event handler, is something wrong with the way I set it up, or something else? 自然滚动条通过点击事件处理程序中是否存在错误,我的设置方式是否存在问题或其他原因? I ask because it doesn't always work (when it doesn't work, it either does nothing or else moves to the wrong position). 我问是因为它并不总是有效(当它不起作用时,它要么什么都不做,要么移到错误的位置)。 The scrollbars otherwise work fine. 滚动条否则可以正常工作。 Sometimes the trough clicks do work, but a lot of the time they don't. 有时低谷点击会起作用,但是很多时候却没有。 (More than one or two clicks is often needed to discover the problem.) (通常需要超过一两次单击才能发现问题。)

hbar=Scrollbar(newTabFrame, orient=HORIZONTAL, bg=self.d["hbgcolor"], troughcolor=self.d["htcolor"]);
vbar=Scrollbar(newTabFrame, orient=VERTICAL, bg=self.d["vbgcolor"], troughcolor=self.d["vtcolor"]);
scroll=Text(self, newTabFrame, font=self.d["font"], undo=True, tabs=("0.4c"), wrap=self.d["wrap"], xscrollcommand=hbar.set, yscrollcommand=vbar.set, bg=self.d["bgcolor"], fg=self.d["fgcolor"], insertbackground=self.d["insertcolor"]);

vbar.grid(row=1, column=2, columnspan=2, rowspan=4, sticky=N+S);
vbar.config(command=scroll.yview);
hbar.grid(sticky=E+W);
hbar.config(command=scroll.xview);

Once again, it's only when I click on the troughs where I experience a problem. 再说一次,只有当我单击遇到问题的槽时,才可以。 All the other scrollbar functionality (which is most of it) works fine. 所有其他滚动条功能(大部分功能)都可以正常工作。 For those who don't know, a scrollbar trough is the long part of the scrollbar that does not move. 对于那些不知道的人,滚动条槽是滚动条的不动部分。

My scrollbars are attached to Text widgets inside Frames that are inside of ttk.Notebook widget tabs. 我的滚动条连接到ttk.Notebook小部件选项卡内部框架中的Text小部件。

To directly answer your question, no, there is no known bug in the scrollbar code. 要直接回答您的问题,不,滚动条代码中没有已知的错误。 This code has been in use for more than a decade without anyone reporting issues with the trough. 该代码已经使用了十多年了,没有人报告过低谷的问题。 That doesn't mean a bug isn't possible, but it is highly unlikely. 这并不意味着不可能存在错误,但是极不可能。 There also doesn't appear to be any problems with how you defined the scrollbar or how you attached it to the text widget. 定义滚动条或将其附加到文本小部件的方式似乎也没有任何问题。 .

Based on comments to the original question, it sounds like you have some bindings in your app that may be interfering with the default behavior of the scrollbar. 根据对原始问题的评论,听起来您的应用程序中存在一些绑定,这些绑定可能会干扰滚动条的默认行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM