BIG problem using Dialog

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

print function is used for printing onto stdout - if you close your app, than you'll see that ip_addr, typed in dialog window, appeared in console. for "printing" onto wxPython's widget, you have to use corresponding method.

Sbaush wrote:

···

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"
        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

ok, but the printing was for example.
i would that my dialog return the ip value and close itself, so can continue the function that called the dialog.
Have you understand?

···

2006/2/3, Vyacheslav Sotnikov < bsdforfree@rambler.ru>:

print function is used for printing onto stdout - if you close your app,

than you’ll see that ip_addr, typed in dialog window, appeared in
console. for “printing” onto wxPython’s widget, you have to use
corresponding method.

Sbaush wrote:

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


To unsubscribe, e-mail:
wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org


Sbaush

Sbaush wrote:

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"
        else:
            print self.dlgAgent.textAgentIP.GetValue()
            return self.dlgAgent.textAgentIP.GetValue()

I think, that you have to grab just self.dlgAgent.textAgentIP.GetValue() instead return, like:

hostto = 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???