gpt4 book ai didi

python-3.x - 如何在 Wx.Stc.StyledTextCtrl 中不允许撤消 (Ctrl+Z)

转载 作者:行者123 更新时间:2023-12-04 10:58:25 25 4
gpt4 key购买 nike

我在 python-3 中做了一个项目,我用 wxpython 创建了一个 gui。在 gui 中,我使用 wx.stc.StyledTextCtrl 并且我不想用户无法撤消(Ctrl + Z)。有没有办法做到这一点?如果有人知道如何不允许(Ctrl + V),这也很棒。

感谢回答的人!

下面是创建 wx.stc.StyledTextCtrl 的基本代码:

import wx
from wx.stc import StyledTextCtrl

app = wx.App()
frame = wx.Frame(None, -1, title='2', pos=(0, 0), size=(500, 500))
frame.Show(True)
messageTxt = StyledTextCtrl(frame, id=wx.ID_ANY, pos=(0, 0), size=(100 * 3, 100),
style=wx.TE_MULTILINE, name="File")

app.SetTopWindow(frame)
app.MainLoop()

最佳答案

另一种选择是使用 stcCmdKeyClear函数,允许 stc为你做这项工作。

import wx
from wx.stc import StyledTextCtrl

app = wx.App()
frame = wx.Frame(None, -1, title='2', pos=(0, 0), size=(500, 500))
frame.Show(True)
messageTxt = StyledTextCtrl(frame, id=wx.ID_ANY, pos=(0, 0), size=(100 * 3, 100),
style=wx.TE_MULTILINE, name="File")

messageTxt.CmdKeyClear(ord('V'), wx.stc.STC_SCMOD_CTRL)
messageTxt.CmdKeyClear(ord('Z'), wx.stc.STC_SCMOD_CTRL)

app.SetTopWindow(frame)
app.MainLoop()

关于python-3.x - 如何在 Wx.Stc.StyledTextCtrl 中不允许撤消 (Ctrl+Z),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59022183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com