Python equivilant to msgbox()

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

    Python equivilant to msgbox()

    Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I would like to call this instead of print (to the screen) . I would like to write a simple script that is not an event drive gui but calls input boxes, message boxes, or maybe even a file open browser box as well?
  • Kent Johnson

    #2
    Re: Python equivilant to msgbox()

    LittlePython wrote:[color=blue]
    > Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
    > would like to call this instead of print (to the screen) . I would like
    > to write a simple script that is not an event drive gui but calls input
    > boxes, message boxes, or maybe even a file open browser box as well?[/color]

    Take a look at EasyGUI:


    Kent

    Comment

    • LittlePython

      #3
      Re: Python equivilant to msgbox()

      That is exactly what I was look for .. thx


      "Kent Johnson" <kent@kentsjohn son.com> wrote in message
      news:43efd40a$1 _2@newspeer2.td s.net...[color=blue]
      > LittlePython wrote:[color=green]
      > > Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
      > > would like to call this instead of print (to the screen) . I would like
      > > to write a simple script that is not an event drive gui but calls input
      > > boxes, message boxes, or maybe even a file open browser box as well?[/color]
      >
      > Take a look at EasyGUI:
      > http://www.ferg.org/easygui/
      >
      > Kent[/color]


      Comment

      • André

        #4
        Re: Python equivilant to msgbox()

        Kent Johnson wrote:[color=blue]
        > LittlePython wrote:[color=green]
        > > Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
        > > would like to call this instead of print (to the screen) . I would like
        > > to write a simple script that is not an event drive gui but calls input
        > > boxes, message boxes, or maybe even a file open browser box as well?[/color]
        >
        > Take a look at EasyGUI:
        > http://www.ferg.org/easygui/
        >
        > Kent[/color]
        It's also possible to something like that with wxPython. Try:
        import wx
        app = wx.PySimpleApp( )
        dlg = wx.TextEntryDia log(None, 'Enter value', 'Title', '')
        if dlg.ShowModal() == wx.ID_OK:
        val = dlg.GetValue() # this line should be indented
        dlg.Destroy()
        print "you have entered %s" % val

        Comment

        • Peter Decker

          #5
          Re: Python equivilant to msgbox()

          On 12 Feb 2006 17:27:56 -0800, André <andre.roberge@ gmail.com> wrote:
          [color=blue]
          > It's also possible to something like that with wxPython. Try:
          > import wx
          > app = wx.PySimpleApp( )
          > dlg = wx.TextEntryDia log(None, 'Enter value', 'Title', '')
          > if dlg.ShowModal() == wx.ID_OK:
          > val = dlg.GetValue() # this line should be indented
          > dlg.Destroy()
          > print "you have entered %s" % val[/color]

          That's the sort of butt-ugly code that got me convinced that Dabo is
          the way to go. To get a simple message box, you have to create it,
          show it, check a return value against an ugly constant (make sure you
          don't forget an use wx.OK instead!), and then remember to destroy it
          or your app will hang.

          The same code in Dabo is:

          val = dabo.ui.getStri ng("Enter value", "Some Title")
          if val in None:
          print "You canceled"
          else:
          print "You entered %s" % val

          Look at both examples, and tell me which looks more Pythonic to you.

          --

          # p.d.

          Comment

          • Fredrik Lundh

            #6
            Re: Python equivilant to msgbox()

            Peter Decker wrote:
            [color=blue][color=green]
            > > It's also possible to something like that with wxPython. Try:
            > > import wx
            > > app = wx.PySimpleApp( )
            > > dlg = wx.TextEntryDia log(None, 'Enter value', 'Title', '')
            > > if dlg.ShowModal() == wx.ID_OK:
            > > val = dlg.GetValue() # this line should be indented
            > > dlg.Destroy()
            > > print "you have entered %s" % val[/color]
            >
            > That's the sort of butt-ugly code that got me convinced that Dabo is
            > the way to go. To get a simple message box, you have to create it,
            > show it, check a return value against an ugly constant (make sure you
            > don't forget an use wx.OK instead!), and then remember to destroy it
            > or your app will hang.[/color]

            if you're using a Python version without a "def" statement, it's time to upgrade.

            </F>



            Comment

            • Andre Roberge

              #7
              Re: Python equivilant to msgbox()

              On 2/13/06, Peter Decker <pydecker@gmail .com> wrote:[color=blue]
              > On 12 Feb 2006 17:27:56 -0800, André <andre.roberge@ gmail.com> wrote:
              >[color=green]
              > > It's also possible to something like that with wxPython. Try:
              > > import wx
              > > app = wx.PySimpleApp( )
              > > dlg = wx.TextEntryDia log(None, 'Enter value', 'Title', '')
              > > if dlg.ShowModal() == wx.ID_OK:
              > > val = dlg.GetValue() # this line should be indented
              > > dlg.Destroy()
              > > print "you have entered %s" % val[/color]
              >
              > That's the sort of butt-ugly code that got me convinced that Dabo is
              > the way to go. To get a simple message box, you have to create it,
              > show it, check a return value against an ugly constant (make sure you
              > don't forget an use wx.OK instead!), and then remember to destroy it
              > or your app will hang.
              >
              > The same code in Dabo is:
              >
              > val = dabo.ui.getStri ng("Enter value", "Some Title")
              > if val in None:
              > print "You canceled"
              > else:
              > print "You entered %s" % val
              >
              > Look at both examples, and tell me which looks more Pythonic to you.[/color]

              While I agree that dabo's version is more Pythonic than wxPython, my
              understanding is that dabo is built on top of wxPython. There are
              other framework (wax, anygui) that also aim to make the coding "more
              pythonic", hiding "ugly" wxPython details. Personnally, I am hesitant
              to start using an extra layer on top of wxPython, with no guarantee
              that it will be always updated. Ideally, something like dabo+wxPython
              would become part of the standard Python distribution.

              The original post was asking if it was possible to have such message
              dialogs using Python, without having a full gui app. I'd say that the
              answer is yes... and that one has a lot of options, depending on how
              many packages one is ready to download.

              André

              Comment

              • Peter Decker

                #8
                Re: Python equivilant to msgbox()

                On 2/13/06, Andre Roberge <andre.roberge@ gmail.com> wrote:
                [color=blue]
                > While I agree that dabo's version is more Pythonic than wxPython, my
                > understanding is that dabo is built on top of wxPython.[/color]

                Yes. You get all the power of wxPython without having to deal with the
                C++ style of coding.
                [color=blue]
                > There are
                > other framework (wax, anygui) that also aim to make the coding "more
                > pythonic", hiding "ugly" wxPython details. Personnally, I am hesitant
                > to start using an extra layer on top of wxPython, with no guarantee
                > that it will be always updated. Ideally, something like dabo+wxPython
                > would become part of the standard Python distribution.[/color]

                I think the chances of Dabo not getting updated are about the same as
                wxPython not getting updated. The authors have been highly active and
                involved for a few years now, unlike Wax or anygui. Bugs get fixed in
                hours usually, and enhancements to the tools are always being
                released.

                It would be way cool if the Powers that Be would adopt Dabo/wxPython
                as part of the language. The combination is so much more powerful and
                much better looking than Tkinter.
                [color=blue]
                > The original post was asking if it was possible to have such message
                > dialogs using Python, without having a full gui app. I'd say that the
                > answer is yes... and that one has a lot of options, depending on how
                > many packages one is ready to download.[/color]

                Oh, I understand your response. But I know that when people who are
                familiar with Python first see wxPython code, their first reaction is
                usually not positive. I was just trying to show that you can create
                UIs easily and Pythonically.

                --

                # p.d.

                Comment

                • Claudio Grondi

                  #9
                  Re: Python equivilant to msgbox()

                  LittlePython wrote:[color=blue]
                  > That is exactly what I was look for .. thx[/color]
                  Surprised to hear that.

                  As VisualBasic programmer I would expect you to have experience with
                  ActiveX on Windows, where the best way to go with Python is to reuse all
                  the ActiveX components and their known user interfaces (i.e. constants
                  to use as parameter and constants for interpretation of return values)
                  directly from within Python.

                  A message box goes e.g. this way:
                  [color=blue][color=green][color=darkred]
                  >>> import win32com.client
                  >>> axWshShell = win32com.client .Dispatch("WScr ipt.Shell")
                  >>> axWshShell.Popu p(u"(MsgText)Th is axWshShell.Popu p closes itself[/color][/color][/color]
                  after 45 seconds", 45, u"(MsgTitle)Tes ting WScript.Shell object:", 1)

                  By the way: is there a ready for direct use timed self closing Ok/Cancel
                  message box in any of the proposed GUI packages?

                  Claudio[color=blue]
                  >
                  >
                  > "Kent Johnson" <kent@kentsjohn son.com> wrote in message
                  > news:43efd40a$1 _2@newspeer2.td s.net...
                  >[color=green]
                  >>LittlePytho n wrote:
                  >>[color=darkred]
                  >>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
                  >>>would like to call this instead of print (to the screen) . I would like
                  >>>to write a simple script that is not an event drive gui but calls input
                  >>>boxes, message boxes, or maybe even a file open browser box as well?[/color]
                  >>
                  >>Take a look at EasyGUI:
                  >>http://www.ferg.org/easygui/
                  >>
                  >>Kent[/color]
                  >
                  >
                  >[/color]

                  Comment

                  • mtallen@gmail.com

                    #10
                    Re: Python equivilant to msgbox()

                    Or just do the message box.
                    [color=blue][color=green][color=darkred]
                    >>> import CLR.System.Wind ows.Forms as Forms
                    >>> Forms.MessageBo x.Show("message goes here", "Window title goes here")[/color][/color][/color]



                    In theory this will also work on a linux system with Mono installed

                    Comment

                    • LittlePython

                      #11
                      Re: Python equivilant to msgbox()

                      I am no VB programmer just dabble in vbscripting abit. The only one I am
                      aware of is the popup as self closing. I never thought of using com.

                      Do you know of any thing for a busy box in the same vain as easygui


                      "Claudio Grondi" <claudio.grondi @freenet.de> wrote in message
                      news:dsq6oc$lb8 $1@newsreader3. netcologne.de.. .[color=blue]
                      > LittlePython wrote:[color=green]
                      > > That is exactly what I was look for .. thx[/color]
                      > Surprised to hear that.
                      >
                      > As VisualBasic programmer I would expect you to have experience with
                      > ActiveX on Windows, where the best way to go with Python is to reuse all
                      > the ActiveX components and their known user interfaces (i.e. constants
                      > to use as parameter and constants for interpretation of return values)
                      > directly from within Python.
                      >
                      > A message box goes e.g. this way:
                      >[color=green][color=darkred]
                      > >>> import win32com.client
                      > >>> axWshShell = win32com.client .Dispatch("WScr ipt.Shell")
                      > >>> axWshShell.Popu p(u"(MsgText)Th is axWshShell.Popu p closes itself[/color][/color]
                      > after 45 seconds", 45, u"(MsgTitle)Tes ting WScript.Shell object:", 1)
                      >
                      > By the way: is there a ready for direct use timed self closing Ok/Cancel
                      > message box in any of the proposed GUI packages?
                      >
                      > Claudio[color=green]
                      > >
                      > >
                      > > "Kent Johnson" <kent@kentsjohn son.com> wrote in message
                      > > news:43efd40a$1 _2@newspeer2.td s.net...
                      > >[color=darkred]
                      > >>LittlePytho n wrote:
                      > >>
                      > >>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
                      > >>>would like to call this instead of print (to the screen) . I would like
                      > >>>to write a simple script that is not an event drive gui but calls input
                      > >>>boxes, message boxes, or maybe even a file open browser box as well?
                      > >>
                      > >>Take a look at EasyGUI:
                      > >>http://www.ferg.org/easygui/
                      > >>
                      > >>Kent[/color]
                      > >
                      > >
                      > >[/color][/color]


                      Comment

                      • Claudio Grondi

                        #12
                        Re: Python equivilant to msgbox()

                        LittlePython wrote:[color=blue]
                        > I am no VB programmer just dabble in vbscripting abit. The only one I am
                        > aware of is the popup as self closing. I never thought of using com.[/color]
                        Ok, so my remarks about COM were not for you.[color=blue]
                        >
                        > Do you know of any thing for a busy box in the same vain as easygui[/color]
                        No, I don't, but it doesn't mean, that there is none considering myriads
                        of various available COM components. My idea was to make you aware, that
                        you can use your VB compiler for creating any ActiveX/COM components for
                        usage with Python the way I have described, but as you write it seems
                        not to be an option for you.

                        So I have to admit, that EasyGUI is in your case apparently[color=blue][color=green][color=darkred]
                        >>> exactly what you was looking for ...[/color][/color][/color]

                        :-)

                        Claudio[color=blue]
                        >
                        >
                        > "Claudio Grondi" <claudio.grondi @freenet.de> wrote in message
                        > news:dsq6oc$lb8 $1@newsreader3. netcologne.de.. .
                        >[color=green]
                        >>LittlePytho n wrote:
                        >>[color=darkred]
                        >>>That is exactly what I was look for .. thx[/color]
                        >>
                        >>Surprised to hear that.
                        >>
                        >>As VisualBasic programmer I would expect you to have experience with
                        >>ActiveX on Windows, where the best way to go with Python is to reuse all
                        >>the ActiveX components and their known user interfaces (i.e. constants
                        >>to use as parameter and constants for interpretation of return values)
                        >>directly from within Python.
                        >>
                        >>A message box goes e.g. this way:
                        >>[color=darkred]
                        >> >>> import win32com.client
                        >> >>> axWshShell = win32com.client .Dispatch("WScr ipt.Shell")
                        >> >>> axWshShell.Popu p(u"(MsgText)Th is axWshShell.Popu p closes itself[/color]
                        >>after 45 seconds", 45, u"(MsgTitle)Tes ting WScript.Shell object:", 1)
                        >>
                        >>By the way: is there a ready for direct use timed self closing Ok/Cancel
                        >>message box in any of the proposed GUI packages?
                        >>
                        >>Claudio
                        >>[color=darkred]
                        >>>
                        >>>"Kent Johnson" <kent@kentsjohn son.com> wrote in message
                        >>>news:43efd40 a$1_2@newspeer2 .tds.net...
                        >>>
                        >>>
                        >>>>LittlePytho n wrote:
                        >>>>
                        >>>>
                        >>>>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) . I
                        >>>>>would like to call this instead of print (to the screen) . I would like
                        >>>>>to write a simple script that is not an event drive gui but calls input
                        >>>>>boxes, message boxes, or maybe even a file open browser box as well?
                        >>>>
                        >>>>Take a look at EasyGUI:
                        >>>>http://www.ferg.org/easygui/
                        >>>>
                        >>>>Kent
                        >>>
                        >>>
                        >>>[/color][/color]
                        >
                        >[/color]

                        Comment

                        • LittlePython

                          #13
                          Re: Python equivilant to msgbox()

                          I am glad you did remind me of WScript.Shell ... I have to keep in mind
                          that most if not all of what I have been using in VBS is avail to me.
                          Thx

                          "Claudio Grondi" <claudio.grondi @freenet.de> wrote in message
                          news:dstup1$rm$ 1@newsreader3.n etcologne.de...[color=blue]
                          > LittlePython wrote:[color=green]
                          > > I am no VB programmer just dabble in vbscripting abit. The only one I am
                          > > aware of is the popup as self closing. I never thought of using com.[/color]
                          > Ok, so my remarks about COM were not for you.[color=green]
                          > >
                          > > Do you know of any thing for a busy box in the same vain as easygui[/color]
                          > No, I don't, but it doesn't mean, that there is none considering myriads
                          > of various available COM components. My idea was to make you aware, that
                          > you can use your VB compiler for creating any ActiveX/COM components for
                          > usage with Python the way I have described, but as you write it seems
                          > not to be an option for you.
                          >
                          > So I have to admit, that EasyGUI is in your case apparently[color=green][color=darkred]
                          > >>> exactly what you was looking for ...[/color][/color]
                          >
                          > :-)
                          >
                          > Claudio[color=green]
                          > >
                          > >
                          > > "Claudio Grondi" <claudio.grondi @freenet.de> wrote in message
                          > > news:dsq6oc$lb8 $1@newsreader3. netcologne.de.. .
                          > >[color=darkred]
                          > >>LittlePytho n wrote:
                          > >>
                          > >>>That is exactly what I was look for .. thx
                          > >>
                          > >>Surprised to hear that.
                          > >>
                          > >>As VisualBasic programmer I would expect you to have experience with
                          > >>ActiveX on Windows, where the best way to go with Python is to reuse all
                          > >>the ActiveX components and their known user interfaces (i.e. constants
                          > >>to use as parameter and constants for interpretation of return values)
                          > >>directly from within Python.
                          > >>
                          > >>A message box goes e.g. this way:
                          > >>
                          > >> >>> import win32com.client
                          > >> >>> axWshShell = win32com.client .Dispatch("WScr ipt.Shell")
                          > >> >>> axWshShell.Popu p(u"(MsgText)Th is axWshShell.Popu p closes itself
                          > >>after 45 seconds", 45, u"(MsgTitle)Tes ting WScript.Shell object:", 1)
                          > >>
                          > >>By the way: is there a ready for direct use timed self closing Ok/Cancel
                          > >>message box in any of the proposed GUI packages?
                          > >>
                          > >>Claudio
                          > >>
                          > >>>
                          > >>>"Kent Johnson" <kent@kentsjohn son.com> wrote in message
                          > >>>news:43efd40 a$1_2@newspeer2 .tds.net...
                          > >>>
                          > >>>
                          > >>>>LittlePytho n wrote:
                          > >>>>
                          > >>>>
                          > >>>>>Is there an equivalent to a msgbox() or wscript.echo (via wcsript) .[/color][/color][/color]
                          I[color=blue][color=green][color=darkred]
                          > >>>>>would like to call this instead of print (to the screen) . I would[/color][/color][/color]
                          like[color=blue][color=green][color=darkred]
                          > >>>>>to write a simple script that is not an event drive gui but calls[/color][/color][/color]
                          input[color=blue][color=green][color=darkred]
                          > >>>>>boxes, message boxes, or maybe even a file open browser box as well?
                          > >>>>
                          > >>>>Take a look at EasyGUI:
                          > >>>>http://www.ferg.org/easygui/
                          > >>>>
                          > >>>>Kent
                          > >>>
                          > >>>
                          > >>>[/color]
                          > >
                          > >[/color][/color]


                          Comment

                          • Claudio Grondi

                            #14
                            Re: Python equivilant to msgbox()

                            LittlePython wrote:[color=blue]
                            > I am glad you did remind me of WScript.Shell ... I have to keep in mind
                            > that most if not all of what I have been using in VBS is avail to me.
                            > Thx[/color]
                            Maybe in this context it could be also worth for you to know, that on
                            Windows you can use Python as a scripting language embedded in HTML
                            <script> blocks same way as you can use JScript and VBScript. This makes
                            the Internet browser a very good GUI alternative for anyone able to
                            write HTML code utilizing the appropriate scripting interface to the
                            interactive HTML page elements.

                            Claudio

                            Comment

                            Working...