##
# This class is used to eliminate a standard Dock class' ability to detach and
# move (i.e. dragging this Dock will have no effect)
#
class MyDock(Dock):
def __init__(self, name, area=None, size=(10, 10), widget=None, hideTitle=False, autoOrientation=True):
# Initialize the baseclass
#
Dock.__init__(self, name, area, size, widget, hideTitle, autoOrientation)
# Override the label's double click event. Normally double clicking
# the dock's label will cause it to detach into it's own window.
#
self.label.mouseDoubleClickEvent=self.noopEvent
def dragEventEnter(self, ev):
pass
def dragMoveEvent(self, ev):
pass
def dragLeaveEvent(self, ev):
pass
def dragDropEvent(self, ev):
pass
def noopEvent(self,ev):
pass
class MyDockArea(DockArea):
def dragEventEnter(self, ev):
pass
def dragMoveEvent(self, ev):
pass
def dragLeaveEvent(self, ev):
pass
def dragDropEvent(self, ev):
pas
通过重写Dock类的方法,我成功地禁用了分离和拖动Dock的功能。在
拖动驳接会将其移动到另一个位置。所以我用什么都不做的方法重写了所有的“drag”事件处理程序(即无操作)。在
双击驳接标签将导致驳接分离。所以,我用no-op重写了dock标签的双击事件处理程序
在代码中用MyDock替换Dock。更新:我添加了代码来覆盖DockArea的drag方法,因为我仍然可以移动DockArea。在
代码如下:
相关问题 更多 >
编程相关推荐