wxtextctrl

set text alignment of rich text ctrl

浪尽此生 提交于 2020-01-17 03:05:38
问题 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() 回答1: Instead of trying to apply both styles I moved the center styling to a new

How to write wxPython textCtrl focus event

 ̄綄美尐妖づ 提交于 2019-12-24 03:10:12
问题 I'm trying to fire a line of code when the user clicks on a textCtrl. The end goal is to highlight the contents of the box when it is clicked on. I am aware that this is possible with wx.EVT_SET_FOCUS, but it's either buggy or I'm implementing it wrong. Here's my code: self.m_textCtrl1 = wx.TextCtrl(self.m_panel2, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(100,-1), wx.TE_LEFT) self.m_textCtrl1.SetMaxLength(8) self.m_textCtrl1.SetMinSize(wx.Size(100,-1)) self.m_textCtrl1.SetMaxSize

The right way to find the size of text in wxPython

谁都会走 提交于 2019-12-13 13:17:11
问题 I have an application I am developing in wxPython. Part of the application creates a large number of TextCtrls in a grid in order to enter four-letter codes for each day of the week for an arbitrarily large list of people. I've managed to make it work, but I'm having to do something kludgy. Specifically, I haven't found a good way to figure out how big (in pixels) a bit of text is, so I have to guess at sizing the TextCtrls in order to just fit the biggest (4 letter) code. My concern is that

wxPython: binding wx.EVT_CHAR_HOOK disables TextCtrl backspace

谁说胖子不能爱 提交于 2019-12-11 01:33:42
问题 I have a wx.TextCtrl and I want to be able to type in it, but also detect key presses such as UP, DOWN, RETURN, ESC. So I binded wx.EVT_KEY_DOWN to recognize any key press, and wx.EVT_CHAR_HOOK to do the same thing even when TextCtrl has focus. self.Bind(wx.EVT_KEY_DOWN, self.keyPressed) self.Bind(wx.EVT_CHAR_HOOK, self.keyPressed) Key presses UP, DOWN, RETURN, ESC were recognized and working fine, but due to binding EVT_CHAR_HOOK I cannot use LEFT RIGHT BACKSPACE SHIFT anymore when I type in