设置滚动条大小
我是Python新手,我有(也许)简单的问题,处理滚动条。 我已经构建了一个程序,它允许我通过使用滚动移动频率来改变我的绘图。但是,在 x 方向上有更大的滚动将会很有用。
所以我的问题是:如何设置滚动条大小?
以下是相关部分:
def __init__(self, master):
self.master = master
self.fig = Figure(figsize=(5,4), dpi=100)
self.myplot = self.fig.add_subplot(111)
self.myplot.axis('equal')
self.canvas = FigureCanvasTkAgg(self.fig, master=master)
self.canvas.show()
self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
self.toolbar = NavigationToolbar2TkAgg( self.canvas, master )
self.toolbar.update()
self.canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)
self.button = Button(master=root, text='Quit', command=self.quit_App)
self.button.pack(side=BOTTOM)
self.freq_label = Label(master, text="Frequency: ")
self.freq_label.pack(side=TOP)
self.scrollbar = Scrollbar(master, orient = HORIZONTAL)
self.scrollbar.pack(side=LEFT, fill = X)
self.scrollbar.config(command=self.slider_update)`
谢谢您帮助我!
I'm new in Python, and I have (maybe) easy question, dealing with scrollbars.
I've built a prog which allows me to change my plot by moving the frequency using a scroll. But, it will be useful to have a huger scroll in the x direction.
So here my question: how setting the scrollbar size?
Here the part concerned :
def __init__(self, master):
self.master = master
self.fig = Figure(figsize=(5,4), dpi=100)
self.myplot = self.fig.add_subplot(111)
self.myplot.axis('equal')
self.canvas = FigureCanvasTkAgg(self.fig, master=master)
self.canvas.show()
self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
self.toolbar = NavigationToolbar2TkAgg( self.canvas, master )
self.toolbar.update()
self.canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)
self.button = Button(master=root, text='Quit', command=self.quit_App)
self.button.pack(side=BOTTOM)
self.freq_label = Label(master, text="Frequency: ")
self.freq_label.pack(side=TOP)
self.scrollbar = Scrollbar(master, orient = HORIZONTAL)
self.scrollbar.pack(side=LEFT, fill = X)
self.scrollbar.config(command=self.slider_update)`
Thank you for helping me !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
滚动条设计用于滚动,并且通常具有由可见数据的相对量确定的拇指大小。由于您控制的是绘图而不是滚动,您是否考虑过使用比例小部件?
您可以在 tkdocs.com 上查看缩放小部件的示例,并找到 < effbot.org 以及其他地方的 href="http://effbot.org/tkinterbook/scale.htm" rel="nofollow">有关体重秤小部件的文档。
Scrollbars are designed to scroll, and typically have a thumb size that is determined by the relative amount of data that is visible. Since you are controlling a plot rather than scrolling, have you considered using a scale widget instead?
You can see an example of a scale widget at tkdocs.com, and find documentation on the scale widget at effbot.org, amoung other places.