def __init__(self, seat=None, stat_dict=None, win=None, pop=None, hand_instance=None, config=None, parent_popup=None): super(Popup, self).__init__( parent_popup or win, Qt.Window | Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus) self.seat = seat self.stat_dict = stat_dict self.win = win self.pop = pop self.hand_instance = hand_instance self.config = config self.parent_popup = parent_popup #parent's instance only used if this popup is a child of another popup self.submenu_count = 0 #used to keep track of active submenus - only one at once allowed self.create() self.show() #child popups are positioned at the mouse pointer and must be killed if # the parent is killed parent = parent_popup or win if config.os_family == 'Mac' and NSView is not None: selfwinid = self.effectiveWinId() selfcvp = ctypes.c_void_p(int(selfwinid)) selfview = NSView(c_void_p=selfcvp) parentwinid = parent.effectiveWinId() parentcvp = ctypes.c_void_p(int(parentwinid)) parentview = NSView(c_void_p=parentcvp) parentview.window().addChildWindow_ordered_( selfview.window(), NSWindowAbove) else: self.windowHandle().setTransientParent( self.parent().windowHandle()) parent.destroyed.connect(self.destroy) self.move(QCursor.pos())
def topify(self, window): winid = window.effectiveWinId() cvp = ctypes.c_void_p(int(winid)) view = NSView(c_void_p=cvp) if window.isVisible(): view.window().orderWindow_relativeTo_(NSWindowAbove, self.number)