Python/wxPython/wx.TextCtrl: Difference between revisions
Jump to navigation
Jump to search
(→Python) |
(→Python) |
||
| Line 1: | Line 1: | ||
= XRC Example = | = XRC Example = | ||
=== Python === | === Python - OnInit() === | ||
<source lang="python"> | <source lang="python"> | ||
self.wxtc = wx.xrc.XRCCTRL(self.frame, 'name_of_wxtc', 'wxTextCtrl') | 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')) | self.wxtc.Bind(wx.EVT_KEY_UP, self.OnKeyPress, id=wx.xrc.XRCID('name_of_wxtc')) | ||
</source> | |||
=== Python - Event Handling === | |||
<source lang="python"> | |||
def OnKeyPress(self, event): | |||
if event.GetKeyCode() == 13: | |||
self.the_text = self.wxtc.GetValue() | |||
self.frame.Close() | |||
</source> | </source> | ||
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