simple GUI question

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

    #1

    simple GUI question

    I have been writing only command line programs in python, and I need a way
    to simply pop up a GUI dialog box, with an "OK" box. Simple huh?

    I have used tkMessageBox.sh owwarning. This works OK but it also pops up an
    empty frame -- i.e. it pops up 2 things. Is there a way to disable this, or
    is there an alternate way of doing things? OK call me anal, but it bothers
    me.

    Another thing I would *like* but is not strictly necessary would be to
    change the font size and color of the text within the box. Is there a good
    way of doing that? I have googled around but can't find any decent example
    code for some reason.

    I can use Python 2.3 only, and only stuff that is included in the standard
    install. For something so trivial I can't roll out a new version of Python
    or any additional software.

    So I assume Tkinter is pretty much my only option, or is that not the case?

    Thanks for any help.

    Roose


  • vincent wehren

    #2
    Re: simple GUI question

    Roose wrote:[color=blue]
    > I have been writing only command line programs in python, and I need a way
    > to simply pop up a GUI dialog box, with an "OK" box. Simple huh?
    >
    > I have used tkMessageBox.sh owwarning. This works OK but it also pops up an
    > empty frame -- i.e. it pops up 2 things. Is there a way to disable this, or
    > is there an alternate way of doing things? OK call me anal, but it bothers
    > me.[/color]

    You want somthing like:

    root = Tkinter.Tk()
    root.withdraw()
    msg = tkMessageBox.sh owwarning("Ooop s", "Some warning")


    --
    Vincent Wehren
    [color=blue]
    >
    > Another thing I would *like* but is not strictly necessary would be to
    > change the font size and color of the text within the box. Is there a good
    > way of doing that?[/color]
    I have googled around but can't find any decent example[color=blue]
    > code for some reason.
    > I can use Python 2.3 only, and only stuff that is included in the standard
    > install. For something so trivial I can't roll out a new version of Python
    > or any additional software.
    >
    > So I assume Tkinter is pretty much my only option, or is that not the case?
    >
    > Thanks for any help.
    >
    > Roose
    >
    >[/color]

    Comment

    • Roose

      #3
      Re: simple GUI question

      > You want somthing like:[color=blue]
      >
      > root = Tkinter.Tk()
      > root.withdraw()
      > msg = tkMessageBox.sh owwarning("Ooop s", "Some warning")[/color]

      Awesome thanks! Any chance you know about the font thing : )

      Nah I'll stop being lazy and hack it... but for some reason Tkinter doesn't
      jive with the way I think at all. It seems very different from the rest of
      Python, which makes sense obviously since it was around before Python...




      Comment

      • Brian van den Broek

        #4
        Re: simple GUI question

        Roose said unto the world upon 2004-12-08 02:23:[color=blue][color=green]
        >>You want somthing like:
        >>
        >>root = Tkinter.Tk()
        >>root.withdraw ()
        >>msg = tkMessageBox.sh owwarning("Ooop s", "Some warning")[/color]
        >
        >
        > Awesome thanks! Any chance you know about the font thing : )
        >
        > Nah I'll stop being lazy and hack it... but for some reason Tkinter doesn't
        > jive with the way I think at all. It seems very different from the rest of
        > Python, which makes sense obviously since it was around before Python...[/color]

        Hi,

        I don't know Tkinter past a hour of playing, so I cannot show you how. I
        can, however, show you a good place to start looking:
        <http://www.google.com/search?num=50&h l=en&q=Tkinter+ Python+font+wid get&btnG=Search &meta=>

        Best,

        Brian vdB

        Comment

        • Brian van den Broek

          #5
          Re: simple GUI question

          Brian van den Broek said unto the world upon 2004-12-08 03:16:

          <SNIP>
          [color=blue]
          > Hi,
          >
          > I don't know Tkinter past a hour of playing, so I cannot show you how. I
          > can, however, show you a good place to start looking:
          > <http://www.google.com/search?num=50&h l=en&q=Tkinter+ Python+font+wid get&btnG=Search &meta=>
          >
          >
          > Best,
          >
          > Brian vdB[/color]

          Hi,

          I didn't mean that in a grouchy way. I just took a quick look at some of
          the links and
          <http://www.cs.sfu.ca/CC/120/ggbaker/ref/tkinter/ar01s17.html> looked
          promising.

          Best,

          Brian vdB

          Comment

          • Eric Brunel

            #6
            Re: simple GUI question

            Roose wrote:
            [snip][color=blue]
            > Another thing I would *like* but is not strictly necessary would be to
            > change the font size and color of the text within the box. Is there a good
            > way of doing that? I have googled around but can't find any decent example
            > code for some reason.[/color]

            Short answer: you can't. The tkMessageBox functions use "native" dialogs, which
            cannot be configured.

            The long answer depends on which platform you're on. If you are on Windows...,
            see short answer ;-) : the dialogs used are actually the native ones, and apart
            from abandonning the tkMessageBox module and designing your own dialogs, there
            is no way to alter their appearence (not that I know of).

            If you're on Unix, it's a bit better but not much: since there's no such thing
            as "native" dialogs, the dialogs are actually tcl code that is in the tcl/tk
            distro, that you can hack anyway you want. This is however not recommended (not
            by me, anyway...), because it has many drawbacks (modify the tcl code will
            modify *all* your dialogs and you won't be able to simply distribute your script
            with the appearence changes: you'll have to distribute the new tcl code for the
            dialogs too...)

            So if you really want to do that, the simplest way is definetely to avoid using
            the tkMessageBox module and to design your own dialogs.

            HTH
            --
            - Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
            PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com

            Comment

            Working...