help with getters

Hi !
I've an dialog build whit wxDesigner. I write the folowing clas for
the Dialog, but

class TerminalDlg(wxDialog):
    def __inti__(self, parent, id, title,pos=wxPyDefaultPosition,
                 size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
        wxDialog.__init__(self, parent, id, title, pos, size, style )

        FindWindowById(ID_INSTRUCCION_TEXTCTRL).SetValue("HOLA")

        self.CentreOnParent()

But when the dialog apears there is no "HOLA" text in the textctrl
idenitfyed with ID_INSTRUCCION_TEXTCTRL

Any idea?

Thanks in advance

Zunbeltz

Zunbeltz Izaola wrote:

Hi !
I've an dialog build whit wxDesigner. I write the folowing clas for
the Dialog, but

class TerminalDlg(wxDialog):
    def __inti__(self, parent, id, title,pos=wxPyDefaultPosition,
                 size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
        wxDialog.__init__(self, parent, id, title, pos, size, style )

        FindWindowById(ID_INSTRUCCION_TEXTCTRL).SetValue("HOLA")

        self.CentreOnParent()

But when the dialog apears there is no "HOLA" text in the textctrl
idenitfyed with ID_INSTRUCCION_TEXTCTRL

This isn't you actual source code is it? Where do you load the controls from wxDesigner onto the dialog? FindWindowById is not a standalone fucntion, you probably need a "self." in front of it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

This isn't you actual source code is it? Where do you load the controls
from wxDesigner onto the dialog? FindWindowById is not a standalone
fucntion, you probably need a "self." in front of it.

I have the folowing in TerminalDlg.py

from control_wdr import *

class TerminalDlg(wxDialog):
    def __inti__(self, parent, id, title,pos=wxPyDefaultPosition,
                 size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
        wxDialog.__init__(self, parent, id, title, pos, size, style )

        text = self.FindWindowById(ID_INSTRUCCION_TEXTCTRL)
        text.SetValue("HOLA")

    def GetInstruccionTextCtrl(self):
        return self.FindWindowById(ID_INSTRUCCION_TEXTCTRL)

    def GetCodigoTextCtrl(self):
        return self.FindWindowById(ID_CODIGO_TEXTCTRL)

    def GetHandleTextCtrl(self):
        return wxPyTypeCast(self.FindWindowById(ID_HANDLE_TEXTCTRL),
                        "wxTextCtrl")

    def GetParametros0TextCtrl(self):
        return self.FindWindowById(ID_PARAMETROS0_TEXTCTRL)

    def GetParametros1TextCtrl(self):
        return self.FindWindowById(ID_PARAMETROS1_TEXTCTRL)

    def GetComandoTextCtrl(self):
        return self.FindWindowById(ID_COMANDO_TEXTCTRL)

    def GetRespuestaTextCtrl(self):
        return wxPyTypeCast(self.FindWindowById(ID_RESPUESTA_TEXTCTRL),
                            "wxTextCtrl")

control_wdr.py is the file generated by wxDesigner with the control.
The main program is the followwing:

from wxPython.wx import *
from control_wdr import *
from TerminalDlg import *

class MyFrame(wxFrame):
    def __init__(self, parent, id, title,
        pos = wxPyDefaultPosition, size = (600,600),
        style = wxDEFAULT_FRAME_STYLE):
        wxFrame.__init__(self, parent, id, title, pos, size, style)

        self.CreateMyMenuBar()
        self.CreateMyToolBar()
        self.CreateStatusBar(1)
        self.SetStatusText("Control difractmetro")

        # insert main window here

        # WDR: handler declarations for MyFrame
        EVT_MENU(self, ID_ABOUT, self.OnAbout)
        EVT_MENU(self, ID_QUIT, self.OnQuit)
        EVT_MENU(self, ID_ABRIR, self.OnMenuArchivoAbrir)
        EVT_MENU(self, ID_TERMINAL, self.OnMenuEjecutarTerminal)
        EVT_MENU(self, ID_ALINEAMIENTO, self.OnMenuTerminalAlineamiento)
        EVT_CLOSE(self, self.OnCloseWindow)

    # WDR: methods for MyFrame

    def CreateMyMenuBar(self):
        self.SetMenuBar(CreateMyMenuBarFunc())

    def CreateMyToolBar(self):
        tb = self.CreateToolBar(wxTB_HORIZONTAL|wxNO_BORDER)
        MyToolBarFunc(tb)

    # WDR: handler implementations for MyFrame

    def OnAbout(self, event):
        dialog = wxMessageDialog(self, "Copyright 2002\n"
                                       "Zunbeltz Izaola\n"
                                       "wmbizazz@lg.ehu.es","About
Control",
                                 wxOK>wxICON_INFORMATION)
        dialog.CentreOnParent()
        dialog.ShowModal()

    def OnQuit(self, event):
        self.Close(true)

    def OnCloseWindow(self, event):
        self.Destroy()

    def OnMenuArchivoAbrir(event):
        dlg = wxFileDialog(self, "Abrir Archivo", "", "","Todos(*.*)|*.*",
                           wxOPEN,wxDefault)
        if dlg.ShowModal() == wxID_OK:
            self.project_open(dlg.GetPath())
            dlg.Destroy()

    def OnMenuEjecutarTerminal(self, event):
        dialog = TerminalDlg(self, -1, "Terminal")
        TerminalDialogFunc(dialog, true)
        dialog.ShowModal()
        dialog.Destroy()

    def OnMenuTerminalAlineamiento(self, event):
        pass

···

#------------------------------------------------------------

class MyApp(wxApp):
    def OnInit(self):
        frame = MyFrame(NULL, -1, "control")
        frame.Show(true)
        self.SetTopWindow(frame)
        return true

#------------------------------------------------------------

app = MyApp(0)
app.MainLoop()

The problem is that when the TerminalDlg dialog aperar, I thik the HOLA,
text should aperar in the TextCtrl identifaied with
ID_INSTRUCCION_TEXTCTRL, but there is no text at all. Any idea?

Zunbeltz

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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

Zunbeltz Izaola wrote:

This isn't you actual source code is it? Where do you load the controls
from wxDesigner onto the dialog? FindWindowById is not a standalone
fucntion, you probably need a "self." in front of it.

I have the folowing in TerminalDlg.py

from control_wdr import *

class TerminalDlg(wxDialog):
    def __init__(self, parent, id, title,pos=wxPyDefaultPosition,
                 size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
        wxDialog.__init__(self, parent, id, title, pos, size, style )

        text = self.FindWindowById(ID_INSTRUCCION_TEXTCTRL)
        text.SetValue("HOLA")

At this point in time you have not yet called TerminalDialogFunc (it is called after __init__ returns) so there is no subwindow with an ID of ID_INSTRUCCION_TEXTCTRL on the dialog yet. So yes it is going to fail.

You could move the call to TerminalDialogFunc here and call it right after the call to wxDialog.__init__, then you FindWIndowById will work.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Zunbeltz Izaola wrote:
>>This isn't you actual source code is it? Where do you load the controls
>>from wxDesigner onto the dialog? FindWindowById is not a standalone
>>fucntion, you probably need a "self." in front of it.
>>
>
> I have the folowing in TerminalDlg.py
>
> from control_wdr import *
>
>
> class TerminalDlg(wxDialog):
> def __init__(self, parent, id, title,pos=wxPyDefaultPosition,
> size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
> wxDialog.__init__(self, parent, id, title, pos, size, style )
>
> text = self.FindWindowById(ID_INSTRUCCION_TEXTCTRL)
> text.SetValue("HOLA")

At this point in time you have not yet called TerminalDialogFunc (it is
called after __init__ returns) so there is no subwindow with an ID of
ID_INSTRUCCION_TEXTCTRL on the dialog yet. So yes it is going to fail.

You could move the call to TerminalDialogFunc here and call it right
after the call to wxDialog.__init__, then you FindWIndowById will work.

I think that i'va to do the call to TerminalDialogFunc, in the point you
said, by if i put there dialog that appears is a small window with nothing
insise

To get the dialog appear i put TerminalDialogFunc in the main program like
this:

    def OnMenuEjecutarTerminal(self, event):
        dialog = TerminalDlg(self, -1, "Terminal")
        TerminalDialogFunc(dialog, True)
        dialog.ShowModal()
        dialog.Destroy()

(I'm my porting my littel application from c++, so it think this was a
correct place to do the call.)

I don't know wy i cant put TerminalDialogFunc in the place you mentioned.
Any hint?

Zunbeltz

···

On Mon, 27 Oct 2003, Robin Dunn wrote:

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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

Zunbeltz Izaola wrote:

I don't know wy i cant put TerminalDialogFunc in the place you mentioned.
Any hint?

I don't know either, this should work, (note that I fixed the spelling of __init__):

class TerminalDlg(wxDialog):
     def __init__(self, parent, id, title,pos=wxPyDefaultPosition,
                  size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
         wxDialog.__init__(self, parent, id, title, pos, size, style )
  TerminalDialogFunc(self, True)
         text = self.FindWindowById(ID_INSTRUCCION_TEXTCTRL)
         text.SetValue("HOLA")

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks! I get it working. I don't know how such a stupid mistake can drive
my crazy!

Zunbeltz

···

On Tue, 28 Oct 2003, Robin Dunn wrote:

Zunbeltz Izaola wrote:
> I don't know wy i cant put TerminalDialogFunc in the place you mentioned.
> Any hint?

I don't know either, this should work, (note that I fixed the spelling
of __init__):

class TerminalDlg(wxDialog):
     def __init__(self, parent, id, title,pos=wxPyDefaultPosition,
                  size=wxPyDefaultSize, style=wxDEFAULT_DIALOG_STYLE ):
         wxDialog.__init__(self, parent, id, title, pos, size, style )
  TerminalDialogFunc(self, True)
         text = self.FindWindowById(ID_INSTRUCCION_TEXTCTRL)
         text.SetValue("HOLA")

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

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