wxPython滚动条不显示

2024-10-02 00:26:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在玩这个cookbook example来用wxPython制作一个可滚动的matplotlib绘图。然而,当我在我的Windows7机器上运行这段代码时,滚动条似乎不能正常工作。特别是,如果我点击并拖动到某个位置,它确实会更新绘图,但是滚动条会向后移动其起始位置,而不是停留在原地。我很好奇是否有人知道这里发生了什么。FWIW,当我在家里的linuxmint14机器上运行时,这个代码运行得很好。在

现在,我正试图用wx.滚动窗口或者wx.lib.滚动面板而不是像示例中那样将滚动条直接添加到画布中。我也在考虑用滑块代替滚动条

谢谢


Tags: 代码机器绘图matplotlibexamplelibwxpythonwx
1条回答
网友
1楼 · 发布于 2024-10-02 00:26:49

Programing Windows, Fifth Edition(强调我的)。。。在

When you use scroll bars within your program, you share responsibility with Windows for maintaining the scroll bars and updating the position of the scroll bar thumb. These are Windows' responsibilities for scroll bars:

  • Handle all processing of mouse messages to the scroll bar.
  • Provide a reverse-video "flash" when the user clicks the scroll bar.
  • Move the thumb as the user drags the thumb within the scroll bar.
  • Send scroll bar messages to the window procedure of the window containing the scroll bar.

These are the responsibilities of your program:

  • Initialize the range and position of the scroll bar.
  • Process the scroll bar messages to the window procedure.
  • Update the position of the scroll bar thumb.
  • Change the contents of the client area in response to a change in the scroll bar.

…所以在OnScrollEvt()方法的某个地方,您需要调用^{}类似于。。。在

self.canvas.SetScrollPos(wx.HORIZONTAL, event.GetPosition(), True)

相关问题 更多 >

    热门问题