Find the answer to your Linux question:
Results 1 to 6 of 6
How would you make a window drag'n'drop? I have hidden the titlebar using: Code: self.window.set_decorated(False) But I still want this window to be moveable, by clicking and dragging anywhere within ...
  1. #1
    tcb
    tcb is offline
    Just Joined!
    Join Date
    Apr 2010
    Posts
    6

    Drag'n'Droping Windows in pyGTK

    How would you make a window drag'n'drop? I have hidden the titlebar using:
    Code:
    self.window.set_decorated(False)
    But I still want this window to be moveable, by clicking and dragging anywhere within the window.

    I would rather just use pyGTK, but Xlib is fine with me aswell.

    thx in advance,
    tcb

  2. #2
    Linux Newbie JosePF's Avatar
    Join Date
    Jun 2010
    Posts
    225
    hi,

    set_resizable(resizable)?

    Regards

  3. #3
    tcb
    tcb is offline
    Just Joined!
    Join Date
    Apr 2010
    Posts
    6
    This isn't working, and even if it was it would have only been resizable.

    You see, i want there to be no decoration from the WM, so i've hidden its decoration. But it has also got to be moveable. Its not that I don't want to resize, I want it to be movable by Drag'n'Drop anywhere in the window

  4. #4
    Linux Newbie JosePF's Avatar
    Join Date
    Jun 2010
    Posts
    225
    sorry,
    I have not understood
    what you want I think is this:

    #!/usr/bin/env python

    import pygtk
    pygtk.require('2.0')
    import gtk
    from gtk import gdk

    class Base:
    def __init__(self):
    self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
    self.window.set_decorated(False)
    self.window.add_events ( gdk.BUTTON_PRESS_MASK )
    self.window.connect ('button-press-event', self.clicked)
    self.window.show()

    def clicked(self, widget, event):
    self.window.begin_move_drag(event.button, int(event.x_root), int(event.y_root), event.time)

    def main(self):
    gtk.main()

    if __name__ == "__main__":
    base = Base()
    base.main()

  5. #5
    tcb
    tcb is offline
    Just Joined!
    Join Date
    Apr 2010
    Posts
    6
    Looks good... will try it when I get onto my ubuntu PC

  6. #6
    tcb
    tcb is offline
    Just Joined!
    Join Date
    Apr 2010
    Posts
    6
    this script detects mousedown anywhere within the window? This fixes another problem of mine.

    Worked like a charm...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...