<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> default_settings = { <EOL> "<STR_LIT>" : True , <EOL> "<STR_LIT>" : <NUM_LIT:0> , <EOL> } <EOL> class QuitConfirmDlg ( QtGui . QDialog ) : <EOL> def __init__ ( self , parent , settings ) : <EOL> super ( QuitConfirmDlg , self ) . __init__ ( parent ) <EOL> self . resize ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . _settings = settings <EOL> self . setModal ( True ) <EOL> self . tips_label = QtGui . QLabel ( "<STR_LIT>" , self ) <EOL> self . tips_label . setGeometry ( QtCore . QRect ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:15> ) ) <EOL> self . minimize_rbtn = QtGui . QRadioButton ( "<STR_LIT>" , self ) <EOL> self . minimize_rbtn . setGeometry ( QtCore . QRect ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> ) ) <EOL> self . exit_rbtn = QtGui . QRadioButton ( "<STR_LIT>" , self ) <EOL> self . exit_rbtn . setGeometry ( QtCore . QRect ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> ) ) <EOL> self . no_confirm_cbox = QtGui . QCheckBox ( "<STR_LIT>" , self ) <EOL> self . no_confirm_cbox . setGeometry ( QtCore . QRect ( <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:20> ) ) <EOL> self . minimize_rbtn . setChecked ( not self . _settings [ '<STR_LIT>' ] ) <EOL> self . exit_rbtn . setChecked ( self . _settings [ '<STR_LIT>' ] ) <EOL> self . no_confirm_cbox . setChecked ( not self . _settings [ '<STR_LIT>' ] ) <EOL> def keyPressEvent ( self , evt ) : <EOL> close_win_cmd_w = ( evt . key ( ) == QtCore . Qt . Key_W and evt . modifiers ( ) == QtCore . Qt . ControlModifier ) <EOL> close_win_esc = ( evt . key ( ) == QtCore . Qt . Key_Escape ) <EOL> if close_win_cmd_w or close_win_esc : <EOL> self . close ( ) <EOL> return self . _settings <EOL> def get_inputs ( self ) : <EOL> self . _settings [ "<STR_LIT>" ] = self . exit_rbtn . isChecked ( ) <EOL> self . _settings [ "<STR_LIT>" ] = not self . no_confirm_cbox . isChecked ( ) <EOL> return self . _settings <EOL> @ staticmethod <EOL> def popup_and_get_inputs ( parent , settings ) : <EOL> dlg = QuitConfirmDlg ( parent , settings ) <EOL> dlg . show ( ) <EOL> result = dlg . exec_ ( ) <EOL> assert result in ( QtGui . QDialog . Accepted , QtGui . QDialog . Rejected ) <EOL> return dlg . get_inputs ( ) <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> self . settings_btn = QtGui . QPushButton ( "<STR_LIT>" , self ) <EOL> self . settings_btn . clicked . connect ( self . _settings_btn_clicked ) <EOL> def _settings_btn_clicked ( self ) : <EOL> global default_settings <EOL> settings = default_settings <EOL> default_settings = QuitConfirmDlg . popup_and_get_inputs ( self , settings ) <EOL> print "<STR_LIT>" , default_settings <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>
