<s> import sys <EOL> from atom . api import Typed <EOL> from enaml . widgets . menu_bar import ProxyMenuBar <EOL> from . QtGui import QMainWindow , QMenuBar <EOL> from . qt_menu import QtMenu <EOL> from . qt_toolkit_object import QtToolkitObject <EOL> class QtMenuBar ( QtToolkitObject , ProxyMenuBar ) : <EOL> """<STR_LIT>""" <EOL> widget = Typed ( QMenuBar ) <EOL> def create_widget ( self ) : <EOL> """<STR_LIT>""" <EOL> self . widget = QMenuBar ( ) <EOL> def init_layout ( self ) : <EOL> """<STR_LIT>""" <EOL> super ( QtMenuBar , self ) . init_layout ( ) <EOL> widget = self . widget <EOL> for child in self . children ( ) : <EOL> if isinstance ( child , QtMenu ) : <EOL> widget . addMenu ( child . widget ) <EOL> def destroy ( self ) : <EOL> """<STR_LIT>""" <EOL> del self . declaration <EOL> def find_next_action ( self , child ) : <EOL> """<STR_LIT>""" <EOL> found = False <EOL> for dchild in self . children ( ) : <EOL> if found : <EOL> if isinstance ( dchild , QtMenu ) : <EOL> return dchild . widget . menuAction ( ) <EOL> else : <EOL> found = dchild is child <EOL> def child_added ( self , child ) : <EOL> """<STR_LIT>""" <EOL> super ( QtMenuBar , self ) . child_added ( child ) <EOL> if isinstance ( child , QtMenu ) : <EOL> before = self . find_next_action ( child ) <EOL> self . widget . insertMenu ( before , child . widget ) <EOL> def child_removed ( self , child ) : <EOL> """<STR_LIT>""" <EOL> super ( QtMenuBar , self ) . child_removed ( child ) <EOL> if isinstance ( child , QtMenu ) : <EOL> self . widget . removeAction ( child . widget . menuAction ( ) ) </s>
