Hi.
I’m developing a application in wxPython.
I’ve a BIG problem.
In a function i need a parameter (ip address) so i’ve generated a dialog like a popup.
this is the call of the dialog:
hostto=self.dlgAgent.run()
print hostto
In the dialog there is a button with this code on click:
def selectIP(self):
if self.dlgAgent.textAgentIP.GetValue() == “”:
print “pippo”
return "[10.0.0.1](http://10.0.0.1)"
else:
print self.dlgAgent.textAgentIP.GetValue()
return self.dlgAgent.textAgentIP.GetValue()
On click i see the print of selectIP, but i don’t see the print of the returned value…
WHY???
i would that on click on Apply the dialg close himself and return the value to the “mother” function…
How can i do it???
the dialog has this code:
from wxPython.wx import *
class MyDialog(wxDialog):
def init(self, *args, **kwds):
# begin wxGlade: MyDialog.init
kwds["style"] = wxDEFAULT_DIALOG_STYLE
wxDialog.__init__(self, *args, **kwds)
self.label_1 = wxStaticText(self, -1, "Set the agent IP or hostname")
self.textAgentIP = wxTextCtrl(self, -1, "")
self.button_1 = wxButton(self, -1, "Apply")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __set_properties(self):
# begin wxGlade: MyDialog.__set_properties
self.SetTitle
(“Insert Agent IP”)
# end wxGlade
def __do_layout(self):
# begin wxGlade: MyDialog.__do_layout
sizer_1 = wxBoxSizer(wxVERTICAL)
sizer_1.Add(self.label_1, 0, wxALIGN_CENTER_HORIZONTAL|wxADJUST_MINSIZE, 0)
sizer_1.Add(self.textAgentIP
, 0, wxALIGN_CENTER_HORIZONTAL|wxADJUST_MINSIZE, 0)
sizer_1.Add((20, 20), 0, wxADJUST_MINSIZE, 0)
sizer_1.Add(self.button_1, 0, wxALIGN_CENTER_HORIZONTAL|wxADJUST_MINSIZE, 0)
self.SetAutoLayout(True)
self.SetSizer(sizer_1)
sizer_1.Fit(self)
sizer_1.SetSizeHints(self)
self.Layout()
# end wxGlade
end of class MyDialog
import wx
class AgentDialog(MyDialog):
def __init__(self):
self.app = wx.App(0)
MyDialog.__init__(self, None, -1, "")
def run(self):
# View = MainView(
# app.SetTopWindow(View)
self.CenterOnScreen()
self.Show()
self.app.MainLoop()
if name == “main”:
d=TheDialog()
d.run()
···
–
Sbaush