#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Champaign - Urbana, IL
    Posts
    54
    Rep Power
    11

    tkMessageBox Location


    So, in a python program I wrote, the whole interface is in a window only 200x230 pixels. Thus, when I open a tkMessageBox on errors, the dialog opened is dead center on the screen, which is not necessarily where the original progam window is. Is there a way to move the dialog opened so that it's always centered over the program window? I'd just open the program window in the dead center of the screen, too, but the user can move that window around before creating an error.

    Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    52
    Hi!

    I just wrote a little snippet, and my tkMessageBox is always centered over the root-window, even if I move it around. You could try the parent-option like tkMessageBox.showerror("Error","Error",parent=root_window), but I don't know if that has the effect you want.

    Regards, mawe
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Champaign - Urbana, IL
    Posts
    54
    Rep Power
    11
    Nope, that didn't seem to do anything at all, unfortunately. What system are you using?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    52
    Linux (Ubuntu Hoary).

    One thing you could do is to write your own dialog box, get the coordinates of the mainwindow with
    Code:
    x,y = mainwindow.winfo_rootx(), mainwindow.winfo_rooty()
    and place your dialog with
    Code:
    my_dialog.geometry("+%d+%d" % (x,y))
    Regards, mawe
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Champaign - Urbana, IL
    Posts
    54
    Rep Power
    11
    I might try that. I hadn't actually be saving the dialog and configuring it, just using the helper functions. Might just ignore it, too. Windows XP SP2 seems to insist on having the message boxes appear on the dead center of the screen regardless of the box's parent.

IMN logo majestic logo threadwatch logo seochat tools logo