Cannot enter text into wx.TextCtrl in newly created Frame

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
hiephm
Posts: 2
Joined: Sat Jul 24, 2010 6:48 pm

Cannot enter text into wx.TextCtrl in newly created Frame

Post by hiephm » Sat Jul 24, 2010 7:16 pm

Hi all,

I have an idea to create a new Frame right in plugin's Action.
(because I think it will be easier to interact between eg and this frame than completely independent app). Like this snippet:

Code: Select all

import eg

eg.RegisterPlugin()

# Create new Frame, containing a text box.
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(200,100))
        self.control = wx.TextCtrl(self,-1)
        self.Show(True)

class HelloWorldPlugin(eg.PluginBase):
    def __init__(self):
        self.AddAction(HelloWorld)

class HelloWorld(eg.ActionBase):
    name = "Hello World"

    def __call__(self):
        frame = MyFrame(None, 'Small editor') 
The problems is, I cannot enter text to above text box by keyboard. I can use right mouse button to cut/paste, however.

Are there anyone have the same problem?

Any suggestion will be appreciated.

Best regards.
HiepHM.

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Cannot enter text into wx.TextCtrl in newly created Frame

Post by Pako » Sun Jul 25, 2010 5:26 pm

Code: Select all

class HelloWorld(eg.ActionBase):
    name = "Hello World"

    def __call__(self):
        frame = wx.CallAfter(MyFrame, None, 'Small editor') 
Pako

hiephm
Posts: 2
Joined: Sat Jul 24, 2010 6:48 pm

Re: Cannot enter text into wx.TextCtrl in newly created Frame

Post by hiephm » Mon Jul 26, 2010 3:53 pm

Thanks Pako

After refered to CallAfter in wiki, I understood the reason.

It works alright now, thanks again.

HiepHM.

Post Reply