- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的项目中,我使用wx.stc.StyledTextCtrl()。我绑定(bind)了按键按下和按键按下的事件。当我想在 TextCtrl 中添加一个字母时,我不会跳过该事件,由于某些原因,我使用方法 AddText() 来添加文本。当文本很长并且滚动条(屏幕宽度)打开时,我希望滚动条位于我可以看到添加的字母的位置(将按应有的方式自动移动)。目前,ScrollBar 始终位于屏幕的左侧。我正在寻找一个可以做到这一点的函数。
当字母超过 TextCtrl 的宽度(超过 pos 300)时,ScrollBar 仍然不会移动。我希望它像框架右侧的 messageTxt 一样。这是提出我的问题的基本代码:
import wx
import wx.stc
def on_key_down(event):
pass
def on_key_up(event):
key_code = event.GetKeyCode()
messageTxt.AddText(chr(key_code))
app = wx.App()
frame = wx.Frame(None, -1, title='2', pos=(0, 0), size=(500, 500))
frame.Show(True)
messageTxt = wx.stc.StyledTextCtrl(frame, id=wx.ID_ANY, pos=(0, 0), size=(300, 300),
style=wx.TE_MULTILINE, name="File")
messageTxt.Bind(wx.EVT_KEY_DOWN, on_key_down)
messageTxt.Bind(wx.EVT_KEY_UP, on_key_up)
messageTxt2 = wx.stc.StyledTextCtrl(frame, id=wx.ID_ANY, pos=(320, 0), size=(150, 150),
style=wx.TE_MULTILINE, name="File")
app.SetTopWindow(frame)
app.MainLoop()
最佳答案
显然,在关键事件之后发生了另一个事件,而该事件被错过了。
在绑定(bind)到按键事件的函数中使用 event.Skip()
。
Skip(self, skip=True) This method can be used inside an event handler to control whether further event handlers bound to this event will be called after the current one returns.
Without Skip (or equivalently if Skip(false) is used), the event will not be processed any more. If Skip(true) is called, the event processing system continues searching for a further handler function for this event, even though it has been processed already in the current handler.
In general, it is recommended to skip all non-command events to allow the default handling to take place. The command events are, however, normally not skipped as usually a single command such as a button click or menu item selection must only be processed by one handler.
import wx
import wx.stc
def on_key_down(event):
event.Skip()
pass
def on_key_up(event):
key_code = event.GetKeyCode()
messageTxt.AddText(chr(key_code))
event.Skip()
app = wx.App()
frame = wx.Frame(None, -1, title='2', pos=(0, 0), size=(500, 500))
frame.Show(True)
messageTxt = wx.stc.StyledTextCtrl(frame, id=wx.ID_ANY, pos=(0, 0), size=(300, 300),
style=wx.TE_MULTILINE, name="File")
messageTxt.Bind(wx.EVT_KEY_DOWN, on_key_down)
messageTxt.Bind(wx.EVT_KEY_UP, on_key_up)
messageTxt2 = wx.stc.StyledTextCtrl(frame, id=wx.ID_ANY, pos=(320, 0), size=(150, 150),
style=wx.TE_MULTILINE, name="File")
app.SetTopWindow(frame)
app.MainLoop()
关于python - Wx.stc.StyledTextCtrl 滚动条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59756826/
我正在尝试在交易策略中使用 STC 指标,但我无法找出它无法正常工作的原因。 我使用的图表是 UTC 上的 BTC/USDT 作为时间范围。 图表时间:UTC 22 年 2 月 1 日 - 16:20
在现代的 Web 开发中,使用 OpenAPI(以前称为 Swagger)规范来描述和定义 API 已经成为一种常见的做法。OpenAPI 规范提供了一种统一的方式来描述API的结构、请求和
由于在很多情况下都没有答案,而我在这里收到了很好的答案,这是我的问题。 我正在为 ABC 乐谱语言编写一个程序(示例如下)。这不是 wx.stc 中支持的语言,而且我还没有找到关于如何执行以下操作的良
在我的项目中,我使用wx.stc.StyledTextCtrl()。我绑定(bind)了按键按下和按键按下的事件。当我想在 TextCtrl 中添加一个字母时,我不会跳过该事件,由于某些原因,我使用方
我有一个在 Ubuntu 上使用 Carrot2 的测试 Solr 环境。使用 Carrot2 工作台,我可以在三种定义的算法(Lingo、STC、kmeans)之间交替。我如何在 Solr 管理查询
我使用 Arduino IDE 对 Arduino 进行编程。但现在我有一个带有 STC(51) 的开发板。我不知道如何在 OSX 中对其进行编程。我发现在 Windows 中有很多 GUI 工具,但
看起来 FindwxWidgets.CMake 无法从 contrib 中找到 stc 模块。我的 CMakeList 文件中有以下内容。 find_package(wxWidgets COMPONE
我在 python-3 中做了一个项目,我用 wxpython 创建了一个 gui。在 gui 中,我使用 wx.stc.StyledTextCtrl 并且我不想用户无法撤消(Ctrl + Z)。有没
§3.7.4.2/2 包含以下句子: The global operator delete with exactly two parameters, the second of which has t
我是一名优秀的程序员,十分优秀!