如何使文本左右对齐和居中,因为wx.TE_RIGHT和wx.TE_CENTER在下面的代码中不起作用
import wx
import wx.richtext as rtc
class test(wx.Dialog):
def __init__(self, *args, **kwds):
wx.Dialog.__init__(self, *args, **kwds)
self.V=rtc.RichTextCtrl(self, size=(400,90),style=wx.TE_RIGHT|rtc.RE_MULTILINE)
if __name__ == '__main__':
app = wx.App()
dialog = test(None, -1)
dialog.Show()
app.MainLoop()
我没有尝试应用这两种样式,而是使用本文档中的 ApplyAlignmentToSelction() 将中心样式移动到新的代码行。 http://xoomer.virgilio.it/infinity77/wxPython/richtext/wx.richtext.RichTextAttr.html
import wx
import wx.richtext as rtc
class test(wx.Dialog):
def __init__(self, *args, **kwds):
wx.Dialog.__init__(self, *args, **kwds)
self.V=rtc.RichTextCtrl(self, size=(400,90),style=rtc.RE_MULTILINE)
self.V.ApplyAlignmentToSelection(rtc.TEXT_ALIGNMENT_CENTER)
if __name__ == '__main__':
app = wx.App()
dialog = test(None, -1)
dialog.Show()
app.MainLoop()