WXPYTHON push button call a frame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcpp

    #1

    WXPYTHON push button call a frame

    Hi I need to call a widget from a button in WXPYTHON. I've tried to
    this from a function like this, but when push the button, the program
    opens a window and do error.
    Any idea?

    ......
    def DialogRRHH(self ,event):
    prog = wx.PySimpleApp( 0)
    wx.InitAllImage Handlers()
    DialogRRHH = MTRRHH(None, -1, "")
    prog.SetTopWind ow(DialogRRHH)
    DialogRRHH.Show ()
    prog.MainLoop()

    class MTRRHH(wx.Frame ):
    ........
    if __name__ == "__main__":
    app = wx.PySimpleApp( 0)
    wx.InitAllImage Handlers()
    tasques = tasques(None, -1, "")
    app.SetTopWindo w(tasques)
    tasques.Show()
    app.MainLoop()

  • Steve Holden

    #2
    Re: WXPYTHON push button call a frame

    Marcpp wrote:
    Hi I need to call a widget from a button in WXPYTHON. I've tried to
    this from a function like this, but when push the button, the program
    opens a window and do error.
    Any idea?
    >
    Well, one *really* good idea would be to copy the error message and
    paste it into your message. The readers of this list have amazing
    psychic powers, but you can always help improve the answer quality by
    providing relevant information.
    .....
    def DialogRRHH(self ,event):
    prog = wx.PySimpleApp( 0)
    wx.InitAllImage Handlers()
    DialogRRHH = MTRRHH(None, -1, "")
    prog.SetTopWind ow(DialogRRHH)
    DialogRRHH.Show ()
    prog.MainLoop()
    >
    class MTRRHH(wx.Frame ):
    .......
    if __name__ == "__main__":
    app = wx.PySimpleApp( 0)
    wx.InitAllImage Handlers()
    tasques = tasques(None, -1, "")
    app.SetTopWindo w(tasques)
    tasques.Show()
    app.MainLoop()
    >
    Unfortunately your code extracts don't tell us what's going wrong, only
    how the program is constructed. While that *is* useful information, by
    itself it only paints half the picture.

    regards
    Steve
    --
    Steve Holden +1 571 484 6266 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    --------------- Asciimercial ------------------
    Get on the web: Blog, lens and tag the Internet
    Many services currently offer free registration
    ----------- Thank You for Reading -------------

    Comment

    • Marcpp

      #3
      Re: WXPYTHON push button call a frame

      On 5 jul, 14:51, Steve Holden <s...@holdenweb .comwrote:
      Marcpp wrote:
      Hi I need to call a widget from a button in WXPYTHON. I've tried to
      this from a function like this, but when push the button, the program
      opens a window and do error.
      Any idea?
      >
      Well, one *really* good idea would be to copy the error message and
      paste it into your message. The readers of this list have amazing
      psychic powers, but you can always help improve the answer quality by
      providing relevant information.
      >
      >
      >
      .....
      def DialogRRHH(self ,event):
      prog = wx.PySimpleApp( 0)
      wx.InitAllImage Handlers()
      DialogRRHH = MTRRHH(None, -1, "")
      prog.SetTopWind ow(DialogRRHH)
      DialogRRHH.Show ()
      prog.MainLoop()
      >
      class MTRRHH(wx.Frame ):
      .......
      if __name__ == "__main__":
      app = wx.PySimpleApp( 0)
      wx.InitAllImage Handlers()
      tasques = tasques(None, -1, "")
      app.SetTopWindo w(tasques)
      tasques.Show()
      app.MainLoop()
      >
      Unfortunately your code extracts don't tell us what's going wrong, only
      how the program is constructed. While that *is* useful information, by
      itself it only paints half the picture.
      >
      regards
      Steve
      --
      Steve Holden +1 571 484 6266 +1 800 494 3119
      Holden Web LLC/Ltd http://www.holdenweb.com
      Skype: holdenweb http://del.icio.us/steve.holden
      --------------- Asciimercial ------------------
      Get on the web: Blog, lens and tag the Internet
      Many services currently offer free registration
      ----------- Thank You for Reading -------------
      Hi, the problem is No Error message, but the program continues running
      after I closed it (by the X).

      Comment

      • kyosohma@gmail.com

        #4
        Re: WXPYTHON push button call a frame

        On Jul 5, 9:04 am, Marcpp <mar...@gmail.c omwrote:
        On 5 jul, 14:51, Steve Holden <s...@holdenweb .comwrote:
        >
        >
        >
        Marcpp wrote:
        Hi I need to call a widget from a button in WXPYTHON. I've tried to
        this from a function like this, but when push the button, the program
        opens a window and do error.
        Any idea?
        >
        Well, one *really* good idea would be to copy the error message and
        paste it into your message. The readers of this list have amazing
        psychic powers, but you can always help improve the answer quality by
        providing relevant information.
        >
        .....
        def DialogRRHH(self ,event):
        prog = wx.PySimpleApp( 0)
        wx.InitAllImage Handlers()
        DialogRRHH = MTRRHH(None, -1, "")
        prog.SetTopWind ow(DialogRRHH)
        DialogRRHH.Show ()
        prog.MainLoop()
        >
        class MTRRHH(wx.Frame ):
        .......
        if __name__ == "__main__":
        app = wx.PySimpleApp( 0)
        wx.InitAllImage Handlers()
        tasques = tasques(None, -1, "")
        app.SetTopWindo w(tasques)
        tasques.Show()
        app.MainLoop()
        >
        Unfortunately your code extracts don't tell us what's going wrong, only
        how the program is constructed. While that *is* useful information, by
        itself it only paints half the picture.
        >
        regards
        Steve
        --
        Steve Holden +1 571 484 6266 +1 800 494 3119
        Holden Web LLC/Ltd http://www.holdenweb.com
        Skype: holdenweb http://del.icio.us/steve.holden
        --------------- Asciimercial ------------------
        Get on the web: Blog, lens and tag the Internet
        Many services currently offer free registration
        ----------- Thank You for Reading -------------
        >
        Hi, the problem is No Error message, but the program continues running
        after I closed it (by the X).
        When I open a custom frame from one of my applications, I do something
        like this:


        <main app code>

        def BtnEventHandler (self, event):
        frame = myFrame()
        frame.Show()

        </main app code>


        <myframe code>

        class myFrame(wx.Fram e):
        def __init__(self, filename=None):
        wx.Frame.__init __(self, None, -1, 'Whatever', size=(570,295))
        # you can set the OnTop style here
        # lots of other code...

        def OnClose(self, event):
        # Close the frame
        self.Close()

        </myframe code>

        If you have additional problems, try mailing the wxPython group, which
        you can find here: www.wxpython.org

        Mike



        Comment

        • Roel Schroeven

          #5
          Re: WXPYTHON push button call a frame

          Marcpp schreef:
          Hi I need to call a widget from a button in WXPYTHON. I've tried to
          this from a function like this, but when push the button, the program
          opens a window and do error.
          Any idea?
          >
          .....
          def DialogRRHH(self ,event):
          prog = wx.PySimpleApp( 0)
          wx.InitAllImage Handlers()
          DialogRRHH = MTRRHH(None, -1, "")
          prog.SetTopWind ow(DialogRRHH)
          DialogRRHH.Show ()
          prog.MainLoop()
          >
          class MTRRHH(wx.Frame ):
          .......
          if __name__ == "__main__":
          app = wx.PySimpleApp( 0)
          wx.InitAllImage Handlers()
          tasques = tasques(None, -1, "")
          app.SetTopWindo w(tasques)
          tasques.Show()
          app.MainLoop()
          In DialogRRHH() you create a new application object with a new event
          loop, while you already have one running. wxPython should have only one
          application object though; otherwise there conflicts between the
          different event loops. Also you don't need to call
          wx.InitAllImage Handlers() again.

          It seems to me that in DialogRRHH() you want to create a dialog and wait
          until the user closes it. In that case, it should look more or less like
          this (beware, I'm not a wxPython expert myself):

          def DialogRRHH(self , event):
          DialogRRHH = MTRRHH(None, -1, "")
          DialogRRHH.Show Modal()

          Also, in that case MTRRHH should be a wxDialog, not a wxFrame.

          In case you want to show MTRRHH without waiting for the user to close
          it, use DialogRRHH.Show () instead of .ShowModal(). I think MTRRHH can be
          either a wxDialog or a wxForm in that case.



          --
          If I have been able to see further, it was only because I stood
          on the shoulders of giants. -- Isaac Newton

          Roel Schroeven

          Comment

          Working...