<s> """<STR_LIT>""" <EOL> import sys <EOL> try : <EOL> from PySide import QtCore , QtGui <EOL> except ImportError : <EOL> from PyQt4 import QtCore , QtGui <EOL> datas = [ <EOL> "<STR_LIT:a>" , <EOL> "<STR_LIT:b>" , <EOL> "<STR_LIT:c>" , <EOL> ] <EOL> class Demo ( QtGui . QWidget ) : <EOL> def __init__ ( self ) : <EOL> QtGui . QWidget . __init__ ( self ) <EOL> self . treeView = QtGui . QTreeView ( ) <EOL> self . model = QtGui . QStandardItemModel ( ) <EOL> for name in datas : <EOL> item = QtGui . QStandardItem ( name ) <EOL> self . model . appendRow ( item ) <EOL> self . treeView . setModel ( self . model ) <EOL> self . model . setHorizontalHeaderLabels ( [ self . tr ( "<STR_LIT>" ) ] ) <EOL> layout = QtGui . QVBoxLayout ( ) <EOL> layout . addWidget ( self . treeView ) <EOL> self . setLayout ( layout ) <EOL> self . treeView . setContextMenuPolicy ( QtCore . Qt . CustomContextMenu ) <EOL> self . treeView . customContextMenuRequested . connect ( self . _ctx_menu_cb ) <EOL> self . popup_menu = QtGui . QMenu ( self ) <EOL> self . item_add_act = QtGui . QAction ( "<STR_LIT>" , self ) <EOL> self . item_add_act . triggered . connect ( self . add_cb ) <EOL> self . popup_menu . addAction ( self . item_add_act ) <EOL> def add_cb ( self ) : <EOL> print "<STR_LIT>" <EOL> def _ctx_menu_cb ( self , pos ) : <EOL> print "<STR_LIT>" , pos <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>
