<s> """<STR_LIT>""" <EOL> import sys <EOL> try : <EOL> from PySide import QtCore <EOL> from PySide import QtGui <EOL> except ImportError : <EOL> from PyQt4 import QtCore <EOL> from PyQt4 import QtGui <EOL> class DragWidget ( QtGui . QPushButton ) : <EOL> def __init__ ( self , parent = None ) : <EOL> super ( DragWidget , self ) . __init__ ( '<STR_LIT>' , parent ) <EOL> def mousePressEvent ( self , evt ) : <EOL> if evt . button ( ) == QtCore . Qt . MouseButton . LeftButton : <EOL> mime_data = QtCore . QMimeData ( ) <EOL> mime_data . setText ( self . text ( ) ) <EOL> drag = QtGui . QDrag ( self ) <EOL> drag . setMimeData ( mime_data ) <EOL> drag . exec_ ( QtCore . Qt . MoveAction ) <EOL> class Demo ( QtGui . QMainWindow ) : <EOL> def __init__ ( self ) : <EOL> super ( Demo , self ) . __init__ ( ) <EOL> x , y , w , h = <NUM_LIT> , <NUM_LIT:200> , <NUM_LIT> , <NUM_LIT> <EOL> self . setGeometry ( x , y , w , h ) <EOL> self . btn = DragWidget ( self ) <EOL> self . btn . move ( <NUM_LIT:10> , <NUM_LIT:10> ) <EOL> self . setAcceptDrops ( True ) <EOL> def show_and_raise ( self ) : <EOL> self . show ( ) <EOL> self . raise_ ( ) <EOL> def dragEnterEvent ( self , drag_enter_evt ) : <EOL> mime_data = drag_enter_evt . mimeData ( ) <EOL> if mime_data . hasFormat ( '<STR_LIT>' ) : <EOL> drag_enter_evt . acceptProposedAction ( ) <EOL> def dragMoveEvent ( self , evt ) : <EOL> print '<STR_LIT>' , evt . pos ( ) <EOL> self . btn . move ( evt . pos ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> app = QtGui . QApplication ( sys . argv ) <EOL> demo = Demo ( ) <EOL> demo . show_and_raise ( ) <EOL> sys . exit ( app . exec_ ( ) ) </s>
