wx/wxPython:如何向网格单元添加滑块?
我需要在网格的一列中显示滑块。我能够创建一个自定义单元格编辑器,当我双击相应列的单元格时,它会显示滑块,使其进入编辑模式。但我不知道如何创建一个自定义 CellRenderer,在所有不处于编辑模式的单元格中显示滑块。 不幸的是 wx.RendererNative 不提供像 DrawSlider() 这样的方法:-(
我很欣赏任何建议。
下面你可以看到到目前为止正在运行的示例。你可以看到带有 sl 的一个单元格
I need to show a slider in one column of a grid. I was able to create a custom CellEditor which displays the slider when I double click into a cell of the appropriate column so it enters the edit mode. But I don't know how to create a custom CellRenderer that displays the slider in all cell that are not in edit mode.
Unfortunately the wx.RendererNative does not offer such a method like DrawSlider() :-(
I appreciate any suggestion.
Below you can see an example of what is working so far. You can see the one cell with the sl
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您可以使用编辑器设置单元格的数值,然后在渲染器上绘制一个垂直条,方法是将该值除以最大可能值,然后乘以单元格的宽度(以 px 为单位,以获得滑块需要出现的单元格)并在此时绘制一个狭窄的垂直矩形作为指示器,类似于:
请注意,这是未经测试的,但我计划在我当前的项目中做类似的事情。只是出于好奇,你是如何让滑块出现在编辑器中的?
Maybe you could use the editor to set the numeric value of the cell, then on the renderer draw a vertical bar by dividing the value by the maximum possible value and multiplying it by the width of the cell (in px, to get the proportion of the cell that the slider needs to appear at) and drawing a narrow vertical rectangle at this point that would act as the indicator, something like:
Note that this is untested, but I plan to do something similar on my current project. Just out of curiosity, how did you get the slider to appear in the editor?