Menu

Is Tk::tk_messageBox() function completed?

Help
2006-04-15
2013-04-15
  • Mateusz Loskot

    Mateusz Loskot - 2006-04-15

    Hi,
    How should I use tk_messageBox() function to display simple info dialog box with title + message + one button?

    As I read Tk reference using this function should be
    straightforward:
    http://www.tcl.tk/man/tcl8.3/TkCmd/messageBox.htm

    I suppose its implementation in C++/Tk is not completed. It only displays blank dialog box:

    Expr Tk::tk_messageBox()
    {
         return Expr("tk_messageBox");
    }

    So, how should I play with tk_messageBox() ?

    Thanks in advance
    Mateusz Loskot

     
    • Mateusz Loskot

      Mateusz Loskot - 2006-04-15

      Stupid me!
      Excuse me, but I did a few mistakes.
      Frist, I checked only Tk docs on
      http://www.tcl.tk/man/tcl8.3/TkCmd/messageBox.htm#M5
      but C++/Tk uses a bit different symbols like -messagetype instead of -type.

      Second, I didn't check C++/Tk docs where is some example of tk_messageBox() usage.

      So, using command like:

      Tk::tk_messageBox() -defaultbutton("ok") -icon(Tk::info) -title("Test") -messagetype(ok) -messagetext("some text");

      message box displays correctly, so it works.
      exmaple in C++/Tk docs:
      (http://cpptk.sourceforge.net/doc.html#commands)

      There is following sample command presented:
      k_messageBox() -defaultbutton("OK") -icon(question) -messagetext("some text") -messagetype(okcancel);

      But it causes error with message:
      bad -default value "OK": must be abort, retry, ignore, ok, cancel, no, or yes

      So, "OK" symbolic name of default button should be given in lower-case (as in my first command above):
      -defaultbutton("ok") but that's obviously a small typo.

      So, I'm back to C++/Tk having huge fan!

      Cheers
      Mateusz Loskot

       
    • Maciej Sobczak

      Maciej Sobczak - 2006-04-24

      Yes, there is the messagetype option instead of type, because is a more general "token" (it is a command of the canvas object) and there would be a naming conflict (if you dig deep enough, you will see that type and messagetype have *slightly* different behaviour).

      And yes, there was a typo in the example. The names given to defaultbutton should be lowercase. It's already corrected.
      Thanks for spotting this out! :)

      Maciej

       
      • Mateusz Loskot

        Mateusz Loskot - 2006-04-27

        Hi,

        > Yes, there is the messagetype option
        > instead of type, because is a more general "token"

        This seems to be a good reason for using messagetype :-)

        Mateusz

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.