<s> from qtshim import QtGui , QtCore , Signal <EOL> def version1 ( ) : <EOL> """<STR_LIT>""" <EOL> def create_window ( ) : <EOL> win = QtGui . QMainWindow ( ) <EOL> return win <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app = QtGui . QApplication ( [ ] ) <EOL> win = create_window ( ) <EOL> win . show ( ) <EOL> app . exec_ ( ) <EOL> def version2 ( ) : <EOL> """<STR_LIT>""" <EOL> def create_window ( ) : <EOL> window = QtGui . QMainWindow ( ) <EOL> container = QtGui . QWidget ( window ) <EOL> textbox = QtGui . QLineEdit ( container ) <EOL> layout = QtGui . QHBoxLayout ( container ) <EOL> container . setLayout ( layout ) <EOL> layout . addWidget ( textbox ) <EOL> window . setCentralWidget ( container ) <EOL> return window <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app = QtGui . QApplication ( [ ] ) <EOL> win = create_window ( ) <EOL> win . show ( ) <EOL> app . exec_ ( ) <EOL> def version3 ( ) : <EOL> """<STR_LIT>""" <EOL> def create_window ( ) : <EOL> window = QtGui . QMainWindow ( ) <EOL> window . setWindowTitle ( '<STR_LIT>' ) <EOL> container = QtGui . QWidget ( window ) <EOL> label = QtGui . QLabel ( '<STR_LIT>' , container ) <EOL> textbox = QtGui . QLineEdit ( container ) <EOL> button = QtGui . QPushButton ( '<STR_LIT>' , container ) <EOL> layout = QtGui . QHBoxLayout ( container ) <EOL> container . setLayout ( layout ) <EOL> layout . addWidget ( label ) <EOL> layout . addWidget ( textbox ) <EOL> layout . addWidget ( button ) <EOL> window . setCentralWidget ( container ) <EOL> return window <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app = QtGui . QApplication ( [ ] ) <EOL> win = create_window ( ) <EOL> win . show ( ) <EOL> app . exec_ ( ) <EOL> def version4 ( ) : <EOL> """<STR_LIT>""" <EOL> class ConverterWindow ( QtGui . QMainWindow ) : <EOL> convertClicked = Signal ( str ) <EOL> def create_window ( ) : <EOL> window = ConverterWindow ( ) <EOL> window . setWindowTitle ( '<STR_LIT>' ) <EOL> container = QtGui . QWidget ( window ) <EOL> label = QtGui . QLabel ( '<STR_LIT>' , container ) <EOL> textbox = QtGui . QLineEdit ( container ) <EOL> button = QtGui . QPushButton ( '<STR_LIT>' , container ) <EOL> def onclick ( ) : <EOL> window . convertClicked . emit ( textbox . text ( ) ) <EOL> button . clicked . connect ( onclick ) <EOL> layout = QtGui . QHBoxLayout ( container ) <EOL> container . setLayout ( layout ) <EOL> layout . addWidget ( label ) <EOL> layout . addWidget ( textbox ) <EOL> layout . addWidget ( button ) <EOL> window . setCentralWidget ( container ) <EOL> return window <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> def onconvert ( prefix ) : <EOL> print '<STR_LIT>' , prefix <EOL> app = QtGui . QApplication ( [ ] ) <EOL> win = create_window ( ) <EOL> win . convertClicked . connect ( onconvert ) <EOL> win . show ( ) <EOL> app . exec_ ( ) <EOL> def version5 ( ) : <EOL> """<STR_LIT>""" <EOL> class HierarchyConverterController ( QtCore . QObject ) : <EOL> selectionChanged = Signal ( list ) <EOL> class ConverterWindow ( QtGui . QMainWindow ) : <EOL> convertClicked = Signal ( str ) <EOL> def create_window ( controller ) : <EOL> window = ConverterWindow ( ) <EOL> window . setWindowTitle ( '<STR_LIT>' ) <EOL> statusbar = window . statusBar ( ) <EOL> container = QtGui . QWidget ( window ) <EOL> label = QtGui . QLabel ( '<STR_LIT>' , container ) <EOL> textbox = QtGui . QLineEdit ( container ) <EOL> button = QtGui . QPushButton ( '<STR_LIT>' , container ) <EOL> def onclick ( ) : <EOL> window . convertClicked . emit ( textbox . text ( ) ) <EOL> button . clicked . connect ( onclick ) <EOL> def update_statusbar ( newsel ) : <EOL> if not newsel : <EOL> txt = '<STR_LIT>' <EOL> elif len ( newsel ) == <NUM_LIT:1> : <EOL> txt = '<STR_LIT>' % newsel [ <NUM_LIT:0> ] <EOL> else : <EOL> txt = '<STR_LIT>' % len ( newsel ) <EOL> statusbar . showMessage ( txt ) <EOL> controller . selectionChanged . connect ( update_statusbar ) <EOL> layout = QtGui . QHBoxLayout ( container ) <EOL> container . setLayout ( layout ) <EOL> layout . addWidget ( label ) <EOL> layout . addWidget ( textbox ) <EOL> layout . addWidget ( button ) <EOL> window . setCentralWidget ( container ) <EOL> return window <EOL> def _pytest ( ) : <EOL> import random <EOL> controller = HierarchyConverterController ( ) <EOL> def nextsel ( ) : <EOL> return random . choice ( [ <EOL> [ ] , <EOL> [ '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ] ) <EOL> def onconvert ( prefix ) : <EOL> print '<STR_LIT>' , prefix <EOL> controller . selectionChanged . emit ( nextsel ( ) ) <EOL> app = QtGui . QApplication ( [ ] ) <EOL> win = create_window ( controller ) <EOL> win . convertClicked . connect ( onconvert ) <EOL> win . show ( ) <EOL> app . exec_ ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _pytest ( ) <EOL> def version6 ( ) : <EOL> """<STR_LIT>""" <EOL> class HierarchyConverterController ( QtCore . QObject ) : <EOL> selectionChanged = Signal ( list ) <EOL> class ConverterWindow ( QtGui . QMainWindow ) : <EOL> convertClicked = Signal ( str ) <EOL> def create_window ( controller , parent = None ) : <EOL> window = ConverterWindow ( parent ) <EOL> window . setWindowTitle ( '<STR_LIT>' ) <EOL> statusbar = window . statusBar ( ) <EOL> container = QtGui . QWidget ( window ) <EOL> label = QtGui . QLabel ( '<STR_LIT>' , container ) <EOL> textbox = QtGui . QLineEdit ( container ) <EOL> button = QtGui . QPushButton ( '<STR_LIT>' , container ) <EOL> def onclick ( ) : <EOL> window . convertClicked . emit ( textbox . text ( ) ) <EOL> button . clicked . connect ( onclick ) <EOL> def update_statusbar ( newsel ) : <EOL> if not newsel : <EOL> txt = '<STR_LIT>' <EOL> elif len ( newsel ) == <NUM_LIT:1> : <EOL> txt = '<STR_LIT>' % newsel [ <NUM_LIT:0> ] <EOL> else : <EOL> txt = '<STR_LIT>' % len ( newsel ) <EOL> statusbar . showMessage ( txt ) <EOL> controller . selectionChanged . connect ( update_statusbar ) <EOL> layout = QtGui . QHBoxLayout ( container ) <EOL> container . setLayout ( layout ) <EOL> layout . addWidget ( label ) <EOL> layout . addWidget ( textbox ) <EOL> layout . addWidget ( button ) <EOL> window . setCentralWidget ( container ) <EOL> return window <EOL> def _pytest ( ) : <EOL> import random <EOL> controller = HierarchyConverterController ( ) <EOL> def nextsel ( ) : <EOL> return random . choice ( [ <EOL> [ ] , <EOL> [ '<STR_LIT>' ] , <EOL> [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> ] ) <EOL> def onconvert ( prefix ) : <EOL> print '<STR_LIT>' , prefix <EOL> controller . selectionChanged . emit ( nextsel ( ) ) <EOL> app = QtGui . QApplication ( [ ] ) <EOL> win = create_window ( controller ) <EOL> win . convertClicked . connect ( onconvert ) <EOL> win . show ( ) <EOL> app . exec_ ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _pytest ( ) <EOL> version6 ( ) </s>
