Hello, my question is a strange thing, but if in wxpython I have created a window in the main.py file
import wx
import wx.xrc
#from accion import evento
class MyFrame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Muestra", pos=wx.DefaultPosition, size=wx.Size(500, 300),
style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL)
self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)
bSizer1 = wx.BoxSizer(wx.VERTICAL)
self.texto = wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
bSizer1.Add(self.texto, 0, wx.ALIGN_CENTER | wx.ALL, 5)
self.buton = wx.Button(self, wx.ID_ANY, u"ejecutar", wx.DefaultPosition, wx.DefaultSize, 0)
bSizer1.Add(self.buton, 0, wx.ALIGN_CENTER | wx.ALL, 5)
self.SetSizer(bSizer1)
self.Layout()
self.Centre(wx.BOTH)
# Connect Events
self.buton.Bind(wx.EVT_BUTTON, self.iniciar)
def __del__(self):
pass
# Virtual event handlers, overide them in your derived class
def iniciar(self, event):
#evento() quiero ejecutar desde otro py
event.Skip()
if __name__ == "__main__":
app = wx.App(False)
frame = MyFrame(None)
frame.Show()
app.MainLoop()
Now I create the file "accion.py" but I want to make that by clicking, it imports the commands of action.py, I think I need a class class or a def that is created in action, for example
def evento(self):
texto = self.self.texto.GetLineText(0)
print(texto)
and if I want to create for example more button actions or others, this is in order to write less code of the parent and. Can you help me please?