Another Question

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

    Another Question

    How can i bind function that handle the mouse clicking window X event
    or clicking alt+F4


    thanks
  • Mike Driscoll

    #2
    Re: Another Question

    On May 23, 10:45 am, Gandalf <goldn...@gmail .comwrote:
    How can i bind function that handle the mouse clicking  window X event
    or clicking alt+F4
    >
    thanks
    You really need to learn to ask good questions. Unless people dive
    into your previous posts, they won't know what Python GUI toolkit you
    are using, which version of said toolkit, which Python or which OS.

    Here's a good place to read about events in general:



    If you use Google, you can look for the close event, which gives you
    this:



    So you'll want to bind your frame to EVT_CLOSE. You can disable the
    "X" in your frame's window by using non-standard style parameters.

    Mike

    Comment

    • Gandalf

      #3
      Re: Another Question

      On May 23, 6:25 pm, Mike Driscoll <kyoso...@gmail .comwrote:
      On May 23, 10:45 am, Gandalf <goldn...@gmail .comwrote:
      >
      How can i bind function that handle the mouse clicking window X event
      or clicking alt+F4
      >
      thanks
      >
      You really need to learn to ask good questions. Unless people dive
      into your previous posts, they won't know what Python GUI toolkit you
      are using, which version of said toolkit, which Python or which OS.
      >
      Here's a good place to read about events in general:
      >

      >
      If you use Google, you can look for the close event, which gives you
      this:
      >

      >
      So you'll want to bind your frame to EVT_CLOSE. You can disable the
      "X" in your frame's window by using non-standard style parameters.
      >
      Mike
      OK you right. I use WX on windows XP.
      I didn't understood how to use this wx.CloseEvent function.

      i really struggle with my poor english to understand this language, so
      your help is crucial for my progress and i appreciate it

      Thanks

      Comment

      • Mike Driscoll

        #4
        Re: Another Question

        On May 23, 12:02 pm, Gandalf <goldn...@gmail .comwrote:
        On May 23, 6:25 pm, Mike Driscoll <kyoso...@gmail .comwrote:
        >
        >
        >
        On May 23, 10:45 am, Gandalf <goldn...@gmail .comwrote:
        >
        How can i bind function that handle the mouse clicking  window X event
        or clicking alt+F4
        >
        thanks
        >
        You really need to learn to ask good questions. Unless people dive
        into your previous posts, they won't know what Python GUI toolkit you
        are using, which version of said toolkit, which Python or which OS.
        >
        Here's a good place to read about events in general:
        >>
        If you use Google, you can look for the close event, which gives you
        this:
        >>
        So you'll want to bind your frame to EVT_CLOSE. You can disable the
        "X" in your frame's window by using non-standard style parameters.
        >
        Mike
        >
        OK you right. I use WX on windows XP.
        I didn't understood how to use this wx.CloseEvent function.
        >
        i really struggle with my poor english to understand this language, so
        your help is crucial for my progress and i appreciate it
        >
        Thanks
        No problem. It just makes it much harder to help if we don't know what
        you're doing. I forget to mention stuff when I post too.

        Just in case you still don't get it, here's some generic code:

        <code>

        self.frame.Bind (wx.EVT_CLOSE, self.onClose)

        def onClose(self, event):
        self.frame.Dest roy()

        </code>

        Note that I called the frame's Destroy() method instead of its Close()
        method. If you call Close() then the EVT_CLOSE event gets fired again
        and you basically end up in a loop.

        Mike

        Comment

        • Gandalf

          #5
          Re: Another Question

          you've been very helpful but still i have only one problem. I wont the
          window not to be close after clicking the X button.
          I wont the program to stay on the toolbar

          thanks!

          Comment

          • Mike Driscoll

            #6
            Re: Another Question

            On May 23, 1:44 pm, Gandalf <goldn...@gmail .comwrote:
            you've been very helpful but still i have only one problem. I wont the
            window not to be close after clicking the X button.
            I wont the program to stay on the toolbar
            >
            thanks!
            Well then, in your event handler, just don't do anything.

            def onClose(self, event):
            pass

            or maybe you want to hide the frame?

            def onClose(self, event):
            self.frame.Hide ()

            Just make sure you give the user some other way to close it and in
            that handler, you'll need to call self.frame.Dest roy().

            Alternatively, you can just tell the frame not to create the "X"
            button:

            self.frame = wx.Frame(None, -1, title="My Frame",
            style=wx.SYSTEM _MENU)

            However, that makes it pretty annoying to close.

            Mike

            Comment

            • Gandalf

              #7
              Re: Another Question

              On May 23, 10:47 pm, Mike Driscoll <kyoso...@gmail .comwrote:
              On May 23, 1:44 pm, Gandalf <goldn...@gmail .comwrote:
              >
              you've been very helpful but still i have only one problem. I wont the
              window not to be close after clicking the X button.
              I wont the program to stay on the toolbar
              >
              thanks!
              >
              Well then, in your event handler, just don't do anything.
              >
              def onClose(self, event):
              pass
              >
              or maybe you want to hide the frame?
              >
              def onClose(self, event):
              self.frame.Hide ()
              >
              Just make sure you give the user some other way to close it and in
              that handler, you'll need to call self.frame.Dest roy().
              >
              Alternatively, you can just tell the frame not to create the "X"
              button:
              >
              self.frame = wx.Frame(None, -1, title="My Frame",
              style=wx.SYSTEM _MENU)
              >
              However, that makes it pretty annoying to close.
              >
              Mike
              OK the first method still didn't work. no matter what i do the window
              keep closing but the last one worked nice and all the top menu
              disappear

              thanks!

              Comment

              Working...