如何将文本右对齐和居中对齐,因为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()
答案 0 :(得分:0)
我没有尝试应用这两种样式,而是使用本文档中的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()