tkinter popup

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

    tkinter popup

    Hi all

    I cant figure out how to disable resizing of my popup window?
    How to put this popup window to show in the middle of my text editor?
    It is writen with Toplevel.


    thx
  • Eric Brunel

    #2
    Re: tkinter popup

    On Tue, 27 Mar 2007 12:05:07 +0200, Gigs_ <gigs@hi.t-com.hrwrote:
    Hi all
    >
    I cant figure out how to disable resizing of my popup window?
    myPopupWindow.w m_resizable(0, 0)

    It may or may not make resize controls disappear depending on your
    platform and/or window manager. But the resizing will be impossible in any
    case.
    How to put this popup window to show in the middle of my text editor?
    It is writen with Toplevel.
    A bit trickier. For example (untested):

    myPopupWindow.a fter_idle(cente rPopupWindow)

    with:

    def centerPopupWind ow():
    x, y = editorWindow.wi nfo_rootx(), editorWindow.wi nfo_rooty()
    w, h = editorWindow.wi nfo_width(), editorWindow.wi nfo_height()
    ww, hh = myPopupWindow.w info_width(), myPopupWindow.w info_height()
    myPopupWindow.g eometry('%sx%s+ %s+%s', ww, hh, x + w/2 - ww/2, y + h/2-
    hh/2)

    The after_idle trick is needed since the dimensions for the popup window
    will only be known when the window is actually displayed. In theory,
    myPopupWindow.u pdate_idletasks () should update the display so that the
    window dimensions are known, but there are cases where it doesn't work. So
    the after_idle trick is surer.

    HTH
    --
    python -c "print ''.join([chr(154 - ord(c)) for c in
    'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"

    Comment

    • Gigs_

      #3
      Re: tkinter popup

      Eric Brunel wrote:
      On Tue, 27 Mar 2007 12:05:07 +0200, Gigs_ <gigs@hi.t-com.hrwrote:
      >
      >Hi all
      >>
      >I cant figure out how to disable resizing of my popup window?
      >
      myPopupWindow.w m_resizable(0, 0)
      >
      It may or may not make resize controls disappear depending on your
      platform and/or window manager. But the resizing will be impossible in
      any case.
      >
      >How to put this popup window to show in the middle of my text editor?
      >It is writen with Toplevel.
      >
      A bit trickier. For example (untested):
      >
      myPopupWindow.a fter_idle(cente rPopupWindow)
      >
      with:
      >
      def centerPopupWind ow():
      x, y = editorWindow.wi nfo_rootx(), editorWindow.wi nfo_rooty()
      w, h = editorWindow.wi nfo_width(), editorWindow.wi nfo_height()
      ww, hh = myPopupWindow.w info_width(), myPopupWindow.w info_height()
      myPopupWindow.g eometry('%sx%s+ %s+%s', ww, hh, x + w/2 - ww/2, y + h/2
      - hh/2)
      >
      The after_idle trick is needed since the dimensions for the popup window
      will only be known when the window is actually displayed. In theory,
      myPopupWindow.u pdate_idletasks () should update the display so that the
      window dimensions are known, but there are cases where it doesn't work.
      So the after_idle trick is surer.
      >
      HTH
      --python -c "print ''.join([chr(154 - ord(c)) for c in
      'U(17zX(%,5.zmz 5(17l8(%,5.Z*(9 3-965$l7+-'])"
      thanks for both replay, they are very helpful. specially this one, it
      will took some times for me to figure this. i was completely forgot that
      this can be done like that

      thx

      Comment

      Working...