Beispiel #1
0
 def embed_plug(self, WID):
     self.haveContainer = True
     subWindow = QWindow.fromWinId(WID)
     container = self.createWindowContainer(subWindow)
     container.setParent(self)
     container.show()
     container.resize(330,360)
    def run_op_screen(self, exer, view):
        if self.start_control is 1:
            return

        # clear op_layout
        self.start_control = 1
        for i in reversed(range(self.op_layout.count())):
            self.op_layout.itemAt(i).widget().setParent(None)

        # run OpenPose
        for f in os.listdir(json_dir):
            os.remove(os.path.join(json_dir, f))

        self.op_handler = subprocess.Popen([openpose_demo_path, "--camera=" + str(camera_offset), "--net_resolution=128x128", "--write_json=" + json_dir, "--model_folder=" + model_dir, "--number_people_max=1"], shell=False)

        # add widget!
        winid = self.get_op_winid()
        while winid is -1:
            winid = self.get_op_winid() 
        op_window = QWindow.fromWinId(winid)
        op_window.setFlags(Qt.FramelessWindowHint)
        op_widget = QWidget.createWindowContainer(op_window)
        self.op_layout.addWidget(op_widget)

        for i in reversed(range(self.sub2_layout.count())):
            self.sub2_layout.itemAt(i).widget().setParent(None)
        
        ready_img = QLabel()
        ready_img.setPixmap(QPixmap("../pictures/ready.JPG").scaledToWidth(320))
        ready_img.setAlignment(Qt.AlignCenter)
        self.sub2_layout.addWidget(ready_img)
    def reparent(self):
        qwindow = self.windowHandle()

        if platform.system() != "Darwin":
            qwindow.setParent(QWindow.fromWinId(self.emacs_xid))

        qwindow.setPosition(QPoint(self.x, self.y))
Beispiel #4
0
 def embed_plug(self, WID):
     self.haveContainer = True
     subWindow = QWindow.fromWinId(WID)
     container = self.createWindowContainer(subWindow)
     container.setParent(self)
     container.show()
     container.resize(330, 360)
Beispiel #5
0
    def onItemDoubleClicked(self, item):
        """列表双击选择事件"""
        # 先移除掉item
        self.windowList.takeItem(self.windowList.indexFromItem(item).row())
        hwnd, phwnd, _, _ = item.text().split('|')
        # 开始嵌入
        self.releaseWidget()
        hwnd, phwnd = int(hwnd), int(phwnd)
        # 嵌入之前的属性
        style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
        exstyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        wrect = win32gui.GetWindowRect(hwnd)[:2] + win32gui.GetClientRect(
            hwnd)[2:]
        print('save', hwnd, style, exstyle, wrect)

        widget = QWidget.createWindowContainer(QWindow.fromWinId(hwnd))
        widget.hwnd = hwnd  # 窗口句柄
        widget.phwnd = phwnd  # 父窗口句柄
        widget.style = style  # 窗口样式
        widget.exstyle = exstyle  # 窗口额外样式
        widget.wrect = wrect  # 窗口位置
        self.layout().addWidget(widget)

        widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
        win32gui.SetParent(hwnd, int(self.winId()))
Beispiel #6
0
    def find_table_parameters(self):
        """Finds poker client window with the given table name."""
        titles = {}
        win32gui.EnumWindows(win_enum_handler, titles)
        for hwnd in titles:
            if titles[hwnd] == "":
                continue
            # if window not visible, probably not a table
            if not win32gui.IsWindowVisible(hwnd):
                continue
            # if window is a child of another window, probably not a table
            if win32gui.GetParent(hwnd) != 0:
                continue
            HasNoOwner = win32gui.GetWindow(hwnd, win32con.GW_OWNER) == 0
            WindowStyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
            if HasNoOwner and WindowStyle & win32con.WS_EX_TOOLWINDOW != 0:
                continue
            if not HasNoOwner and WindowStyle & win32con.WS_EX_APPWINDOW == 0:
                continue

            if re.search(self.search_string, titles[hwnd], re.I):
                if self.check_bad_words(titles[hwnd]):
                    continue

                self.number = hwnd
                break

        if self.number is None:
            log.error(_("Window %s not found. Skipping."), self.search_string)
            return

        self.title = titles[self.number]
        self.hud = None
        self.gdkhandle = QWindow.fromWinId(self.number)
    def reparent(self):
        # print("Reparent: ", self.buffer.url)
        qwindow = self.windowHandle()

        if not get_emacs_func_result("eaf-emacs-not-use-reparent-technology",
                                     []):
            qwindow.setParent(QWindow.fromWinId(int(self.emacs_xid)))

        qwindow.setPosition(QPoint(self.x, self.y))
Beispiel #8
0
 def embed(self, command):
     try:
         self.external_id = self.launch_xid(command)
         window = QWindow.fromWinId(self.external_id)
         self.container = QWidget.createWindowContainer(window, self)
         self.show()
         return True
     except Exception, e:
         print 'Error Embedding program: ', command
         print e
         return False
Beispiel #9
0
 def embed(self, command):
     try:
         self.external_id = self.launch_xid(command)
         window = QWindow.fromWinId(self.external_id)
         self.container = QWidget.createWindowContainer(window, self)
         self.show()
         return True
     except  Exception,e:
         print 'Error Embedding program: ',command
         print e
         return False
Beispiel #10
0
    def topify(self, window):
        """Set the specified Qt window to stayontop in MS Windows."""

        # self.number is the windows handle
        # self.gdkhandle is a foreign QWindow associated with the poker client
        # window is a seat_window object from Mucked (a Qt QWidget)
        # window.windowHandle() is a QWindow object

        if self.gdkhandle is None:
            self.gdkhandle = QWindow.fromWinId(int(self.number))
        window.windowHandle().setTransientParent(self.gdkhandle)
Beispiel #11
0
 def embed(self, command):
     try:
         self.external_id = self.launch_xid(command)
         window = QWindow.fromWinId(self.external_id)
         self.container = QWidget.createWindowContainer(window, self)
         self.show()
         return True
     except  Exception, e:
         LOG.warning('Exception:{}'.format(command))
         LOG.warning('Exception:{}'.format( e))
         raise Exception(e)
         return False
Beispiel #12
0
 def embeddedWindow(self):
     while win32gui.FindWindow("StarCraft II", None) == 0:
         pass
     hwnd = win32gui.FindWindow("StarCraft II", None)
     hwnd_qwindow = QWindow.fromWinId(hwnd)
     # hwnd_qwindow.setFlags(Qt.FramelessWindowHint)
     # self.game_widget.createWindowContainer(hwnd_qwindow, self.game_widget)
     # self.game_widget.show()
     phwnd = win32gui.FindWindow('FightView', None)
     print('hwnd: ', hwnd, ' phwnd: ', phwnd)
     win32gui.SetParent(hwnd, phwnd)
     # self.main_layout.addWidget(hwnd_widget)
     QApplication.processEvents()
Beispiel #13
0
 def embed_program(self, command):
     try:
         self.external_id = self.launch_xid(command)
         window = QWindow.fromWinId(self.external_id)
         self.container = QWidget.createWindowContainer(window, self)
         self.show()
         # there seems to be a race - sometimes the foreign window doesn't embed
         time.sleep(.2)
         return True
     except Exception as e:
         LOG.warning('Exception:{}'.format(command))
         LOG.warning('Exception:{}'.format(e))
         raise Exception(e)
         return False
Beispiel #14
0
    def topify(self, window):
        #    The idea here is to call setTransientParent on the HUD window, with the table window
        #    as the argument. This should keep the HUD window on top of the table window, as if
        #    the hud window was a dialog belonging to the table.

        #    X doesn't like calling the foreign_new function in XTables.
        #    Nope don't know why. Moving it here seems to make X happy.
        if self.gdkhandle is None:
            self.gdkhandle = QWindow.fromWinId(int(self.number))

#   This is the gdkhandle for the HUD window
        gdkwindow = (window.windowHandle())

        gdkwindow.setTransientParent(self.gdkhandle)
Beispiel #15
0
 def initUI(self):
     hwnd = win32gui.FindWindowEx(0, 0, self.class_name, self.window_name)
     start = time.time()
     while hwnd == 0:
         time.sleep(0.01)
         hwnd = win32gui.FindWindowEx(0, 0, self.class_name,
                                      self.window_name)
         end = time.time()
         if end - start > 5:
             return
     self.window = QWindow.fromWinId(hwnd)
     self.container = self.createWindowContainer(self.window, self)
     window_x, window_y = self.window.width(), self.window.height()
     self.container.resize(window_x, window_y)
     self.resize(window_x, window_y)
     self.setWindowTitle('catchWindow')
     self.show()
Beispiel #16
0
def run_app(window_id):
    from PyQt5.QtGui import QWindow
    from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QPushButton

    app = QApplication([])
    main_widget = QWidget()
    layout = QVBoxLayout(main_widget)

    window = QWindow.fromWinId(window_id)
    widget = QWidget.createWindowContainer(window)
    layout.addWidget(widget)

    button = QPushButton('Close')
    button.clicked.connect(main_widget.close)
    layout.addWidget(button)

    main_widget.show()
    app.exec_()
Beispiel #17
0
    def initUI(self):
        import threading
        t = threading.Thread(target=self.runExe)
        t.start()

        hwnd1 = win32gui.FindWindowEx(0, 0, "CalcFrame", "计算器")
        start = time.time()
        while hwnd1 == 0:
            time.sleep(0.01)
            hwnd1 = win32gui.FindWindowEx(0, 0, "CalcFrame", "计算器")
            end = time.time()
            if end - start > 5:
                return
        window = QWindow.fromWinId(hwnd1)

        self.createWindowContainer(window, self)
        self.setGeometry(100, 500, 200, 200)
        self.show()
 def set_to_window(self, window_id):
     print("@ wm : set_to_window : " + str(window_id))
     if self.widgets_active:
         self.winManagerLayout.removeWidget(self.appSearchBox)
         self.appSearchBox.deleteLater()
         self.winManagerLayout.removeWidget(self.availableApps)
         self.availableApps.deleteLater()
         self.widgets_active = False
     try:
         self.app_window = QWindow.fromWinId(window_id)
     except RuntimeError:
         print("Sorry, Run Time Error ;_;")
     except OSError:
         print("Sorry, OS Error ;_;")
     else:
         self.app_window.setFlag(Qt.FramelessWindowHint, True)
         # win32gui.SetForegroundWindow(self.app_window)
         self.app_widget = QWidget.createWindowContainer(self.app_window, self, Qt.FramelessWindowHint)
         self.winManagerLayout.addWidget(self.app_widget, 0, 0)
         self.app_widget.show()
Beispiel #19
0
    def onItemDoubleClicked(self, item):
        """列表双击选择事件"""
        # 先移除掉item
        self.windowList.takeItem(self.windowList.indexFromItem(item).row())
        hwnd, phwnd, _, _ = item.text().split('|')
        # 开始嵌入

        if self.layout().count() == 4:
            # 如果数量等于4说明之前已经嵌入了一个窗口,现在需要把它释放出来
            self.restore()
        hwnd, phwnd = int(hwnd), int(phwnd)
        # 嵌入之前的属性
        style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
        exstyle = win32gui.GetWindowLong(hwnd, win32con.GWL_EXSTYLE)
        print('save', hwnd, style, exstyle)

        widget = QWidget.createWindowContainer(QWindow.fromWinId(hwnd))
        widget.hwnd = hwnd  # 窗口句柄
        widget.phwnd = phwnd  # 父窗口句柄
        widget.style = style  # 窗口样式
        widget.exstyle = exstyle  # 窗口额外样式
        self.layout().addWidget(widget)
Beispiel #20
0
 def reparent(self):
     qwindow = self.windowHandle()
     qwindow.setParent(QWindow.fromWinId(self.emacs_xid))
     qwindow.setPosition(QPoint(self.x, self.y))