<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> from PySide import QtCore <EOL> from PySide import QtGui <EOL> class DropArea ( QtGui . QLabel ) : <EOL> def __init__ ( self , parent ) : <EOL> super ( DropArea , self ) . __init__ ( parent ) <EOL> self . setMinimumSize ( <NUM_LIT:200> , <NUM_LIT:200> ) <EOL> self . setAcceptDrops ( True ) <EOL> self . setAutoFillBackground ( True ) <EOL> self . clear ( ) <EOL> def dragEnterEvent ( self , evt ) : <EOL> self . setText ( "<STR_LIT>" ) <EOL> self . setBackgroundRole ( QtGui . QPalette . Highlight ) <EOL> evt . acceptProposedAction ( ) <EOL> self . emit ( QtCore . SIGNAL ( "<STR_LIT>" ) , evt . mimeData ( ) ) <EOL> def dragMoveEvent ( self , evt ) : <EOL> evt . acceptProposedAction ( ) <EOL> def dropEvent ( self , evt ) : <EOL> mime_data = evt . mimeData ( ) <EOL> if mime_data . hasImage ( ) : <EOL> self . setPixmap ( mime_data . imageData ( ) ) <EOL> elif mime_data . hasHtml ( ) : <EOL> self . setText ( mime_data . html ( ) ) <EOL> self . setTextFormat ( QtCore . Qt . RichText ) <EOL> elif mime_data . hasText ( ) : <EOL> self . setText ( mime_data . text ( ) ) <EOL> self . setTextFormat ( QtCore . Qt . PlainText ) <EOL> elif mime_data . hasUrls ( ) : <EOL> urls = mime_data . urls ( ) <EOL> text = "<STR_LIT>" <EOL> for url in urls : <EOL> text += url + "<STR_LIT:U+0020>" <EOL> self . setText ( text ) <EOL> else : <EOL> self . setText ( "<STR_LIT>" ) <EOL> self . setBackgroundRole ( QtGui . QPalette . Dark ) <EOL> evt . acceptProposedAction ( ) <EOL> def dragLeaveEvent ( self , evt ) : <EOL> self . clear ( ) <EOL> evt . accept ( ) <EOL> def clear ( self ) : <EOL> self . setText ( "<STR_LIT>" ) <EOL> self . setBackgroundRole ( QtGui . QPalette . Dark ) <EOL> self . emit ( QtCore . SIGNAL ( "<STR_LIT>" ) ) <EOL> class Demo ( QtGui . QWidget ) : <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> buf = "<STR_LIT>" + "<STR_LIT>" <EOL> lab = QtGui . QLabel ( buf , self ) <EOL> lab . setWordWrap ( True ) <EOL> lab . adjustSize ( ) <EOL> dropArea = DropArea ( self ) <EOL> self . connect ( dropArea , QtCore . SIGNAL ( '<STR_LIT>' ) , self . updateFormatsTable ) <EOL> self . formatsTable = QtGui . QTableWidget ( self ) <EOL> self . formatsTable . setColumnCount ( <NUM_LIT:2> ) <EOL> self . formatsTable . setEditTriggers ( QtGui . QAbstractItemView . NoEditTriggers ) <EOL> labels = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . formatsTable . setHorizontalHeaderLabels ( labels ) <EOL> self . formatsTable . horizontalHeader ( ) . setStretchLastSection ( True ) <EOL> clearButton = QtGui . QPushButton ( "<STR_LIT>" ) <EOL> quitButton = QtGui . QPushButton ( "<STR_LIT>" ) <EOL> buttonBox = QtGui . QDialogButtonBox ( ) <EOL> buttonBox . addButton ( clearButton , QtGui . QDialogButtonBox . ActionRole ) <EOL> buttonBox . addButton ( quitButton , QtGui . QDialogButtonBox . RejectRole ) <EOL> quitButton . pressed . connect ( self . close ) <EOL> self . connect ( clearButton , QtCore . SIGNAL ( '<STR_LIT>' ) , dropArea , QtCore . SLOT ( '<STR_LIT>' ) ) <EOL> mainLayout = QtGui . QVBoxLayout ( self ) <EOL> mainLayout . addWidget ( lab ) <EOL> mainLayout . addWidget ( dropArea ) <EOL> mainLayout . addWidget ( self . formatsTable ) <EOL> mainLayout . addWidget ( buttonBox ) <EOL> self . setLayout ( mainLayout ) <EOL> self . setWindowTitle ( "<STR_LIT>" ) <EOL> self . setMinimumSize ( <NUM_LIT> , <NUM_LIT> ) <EOL> def updateFormatsTable ( self , mime_data ) : <EOL> self . formatsTable . setRowCount ( <NUM_LIT:0> ) <EOL> if not mime_data : <EOL> return <EOL> for format in mime_data . formats ( ) : <EOL> format_item = QtGui . QTableWidgetItem ( format ) <EOL> format_item . setFlags ( QtCore . Qt . ItemIsEnabled ) <EOL> format_item . setTextAlignment ( QtCore . Qt . AlignTop | QtCore . Qt . AlignLeft ) <EOL> if format == '<STR_LIT>' : <EOL> text = mime_data . text ( ) . simplified ( ) <EOL> elif format == '<STR_LIT>' : <EOL> text = mime_data . html ( ) . simplified ( ) <EOL> elif format == '<STR_LIT>' : <EOL> text = "<STR_LIT>" <EOL> for i in mime_data . urls ( ) : <EOL> text += '<STR_LIT:U+0020>' + i <EOL> else : <EOL> text = '<STR_LIT>' <EOL> row = self . formatsTable . rowCount ( ) <EOL> self . formatsTable . insertRow ( row ) <EOL> self . formatsTable . setItem ( row , <NUM_LIT:0> , QtGui . QTableWidgetItem ( format ) ) <EOL> self . formatsTable . setItem ( row , <NUM_LIT:1> , QtGui . QTableWidgetItem ( text ) ) <EOL> self . formatsTable . resizeColumnsToContents ( <NUM_LIT:0> ) <EOL> def show_and_raise ( self ) : <EOL> self . show ( ) <EOL> self . raise_ ( ) <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>
