每当我在文本编辑器中按Tab键缩进时,它就会显示8列而不是4列。如何将其更改为4?
这是我的文本编辑器:
import wx
import wx.stc as stc
class Window(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(500, 500))
self.control = stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
self.control.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:Courier New")
def main():
app = wx.App()
frame = Window(None, "Text Editor")
frame.Show()
app.MainLoop()
if __name__ == '__main__':
main()
答案 0 :(得分:0)
使用SetIndent(4)
import wx
import wx.stc as stc
class Window(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, title=title, size=(500, 500))
self.control = stc.StyledTextCtrl(self, style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
self.control.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:Courier New")
self.control.SetIndent(4)
self.control.SetIndentationGuides(True)
def main():
app = wx.App()
frame = Window(None, "Text Editor")
frame.Show()
app.MainLoop()
if __name__ == '__main__':
main()
请参阅:https://wxpython.org/Phoenix/docs/html/wx.stc.StyledTextCtrl.html