#------------------------------------------------------------------------------
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
from .qt.QtGui import QPushButton
from .qt_abstract_button import QtAbstractButton
from .qt_menu import QtMenu
[docs]class QtPushButton(QtAbstractButton):
""" A Qt implementation of an Enaml PushButton.
"""
[docs] def create_widget(self, parent, tree):
""" Create the underlying QPushButton widget.
"""
return QPushButton(parent)
[docs] def init_layout(self):
""" Handle layout initialization for the push button.
"""
super(QtPushButton, self).init_layout()
self.widget().setMenu(self.menu())
#--------------------------------------------------------------------------
# Utility Methods
#--------------------------------------------------------------------------
[docs] def child_removed(self, child):
""" Handle the child removed event for a QtPushButton.
"""
if isinstance(child, QtMenu):
self.widget().setMenu(self.menu())
[docs] def child_added(self, child):
""" Handle the child added event for a QtPushButton.
"""
if isinstance(child, QtMenu):
self.widget().setMenu(self.menu())