设置RTF文本Ctrl的文本对齐方式 [英] set text alignment of rich text ctrl
本文介绍了设置RTF文本Ctrl的文本对齐方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于wx.TE_RIGHT和wx.TE_CENTER在下面的代码中不起作用,因此如何使文本右对齐和居中对齐
how to align text right and center because wx.TE_RIGHT and wx.TE_CENTER is not working in the code below
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
Instead of trying to apply both styles I moved the center styling to a new line of code using ApplyAlignmentToSelction() from this documentation. 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()
这篇关于设置RTF文本Ctrl的文本对齐方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文