Python/wxPython/wx.TextCtrl: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
(→Python) |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
''' | = XRC Example = | ||
=== Python - OnInit() === | |||
<source lang="python"> | |||
self.wxtc = wx.xrc.XRCCTRL(self.frame, 'name_of_wxtc', 'wxTextCtrl') | |||
self.wxtc.Bind(wx.EVT_KEY_UP, self.OnKeyPress, id=wx.xrc.XRCID('name_of_wxtc')) | |||
</source> | |||
= | === Python - Event Handling === | ||
<source lang="python"> | <source lang="python"> | ||
def OnKeyPress(self, event): | |||
if event.GetKeyCode() == 13: | |||
self.the_text = self.wxtc.GetValue() | |||
self.frame.Close() | |||
</source> | </source> | ||
= XRC = | === XRC === | ||
<source lang="xml"> | <source lang="xml"> | ||
<object name="name_of_wxtc" class="wxTextCtrl"> | |||
<size>200,25</size> | |||
</object> | |||
</source> | </source> | ||
= Programmatically Example = | |||
<source lang="python"> | |||
# TODO | |||
</source> | |||
= Documents = | |||
* [https://docs.wxpython.org/wx.CheckBox.html#wx.CheckBox wxPython] | |||
* [https://wiki.wxwidgets.org/Using_XML_Resources_with_XRC#wxCheckBox XRC] | |||
* [https://docs.wxpython.org/wx.KeyEvent.html KeyEvent] | |||
Latest revision as of 09:59, 4 December 2019
XRC Example
Python - OnInit()
self.wxtc = wx.xrc.XRCCTRL(self.frame, 'name_of_wxtc', 'wxTextCtrl')
self.wxtc.Bind(wx.EVT_KEY_UP, self.OnKeyPress, id=wx.xrc.XRCID('name_of_wxtc'))
Python - Event Handling
def OnKeyPress(self, event):
if event.GetKeyCode() == 13:
self.the_text = self.wxtc.GetValue()
self.frame.Close()
XRC
<object name="name_of_wxtc" class="wxTextCtrl">
<size>200,25</size>
</object>
Programmatically Example
# TODO