Exemplo n.º 1
0
    def __init__(self, parent, ui, stereo=False, opengl_context=None):
        self.session = ui.session
        self.view = ui.session.main_view

        QWindow.__init__(self)
        from PyQt5.QtWidgets import QWidget
        self.widget = w = QWidget.createWindowContainer(self, parent)
        w.setAcceptDrops(True)
        self.setSurfaceType(QSurface.OpenGLSurface)

        if opengl_context is None:
            from chimerax.graphics import OpenGLContext
            oc = OpenGLContext(self, ui.primaryScreen(), use_stereo=stereo)
        else:
            from chimerax.graphics import OpenGLError
            try:
                opengl_context.enable_stereo(stereo, window=self)
            except OpenGLError as e:
                from chimerax.core.errors import UserError
                raise UserError(str(e))
            oc = opengl_context

        self.opengl_context = oc
        self.view.initialize_rendering(oc)

        self.popup = Popup(self)  # For display of atom spec balloons
Exemplo n.º 2
0
    def __init__(self, parent, view, session, panel, side=RIGHT_SIDE):
        QWindow.__init__(self)
        from PyQt5.QtWidgets import QWidget
        self.widget = QWidget.createWindowContainer(self, parent)
        self.setSurfaceType(QSurface.OpenGLSurface)
        self.view = view
        self.session = session
        self.panel = panel
        self.main_view = session.main_view
        self.side = side
        # self.side = self.TOP_SIDE  # DEBUG
        self.moving = self.ON_NOTHING

        self.locations = loc = _PixelLocations()
        loc.eye = 0, 0, 0   # x, y coordinates of eye
        loc.near = 0        # X coordinate of near plane
        loc.far = 0         # Y coordinate of near plane
        loc.bottom = 0      # bottom of clipping planes
        loc.top = 0         # top of clipping planes
        loc.far_bottom = 0  # right clip intersect far
        loc.far_top = 0     # left clip intersect far

        self.applique = OrthoOverlay('sideview')
        self.applique.display_style = Drawing.Mesh
        self.applique.use_lighting = False
        self.view.add_overlay(self.applique)
        self.handler = session.triggers.add_handler('frame drawn', self._redraw)
        from PyQt5.QtCore import QSize
        self.widget.setMinimumSize(QSize(20, 20))
Exemplo n.º 3
0
    def __init__(self,
                 session,
                 device_number=0,
                 view_angle=None,
                 field_of_view=None,
                 depth_offset=None,
                 verbose=False,
                 quilt=False):
        self._session = session

        # Create camera for rendering LookingGlass image
        cam_settings = {
            name: value
            for name, value in (('device_number', device_number),
                                ('view_angle', view_angle), ('field_of_view',
                                                             field_of_view),
                                ('depth_offset', depth_offset), ('verbose',
                                                                 verbose))
            if value is not None
        }
        lgc = LookingGlassCamera(session, **cam_settings)
        self.looking_glass_camera = lgc

        # Create fullscreen window on LookingGlass display
        screen = None if quilt else self._looking_glass_screen()
        QWindow.__init__(self, screen=screen)
        from PyQt5.QtGui import QSurface
        self.setSurfaceType(QSurface.OpenGLSurface)

        if screen:
            from sys import platform
            if platform == 'win32':
                # Qt 5.12 hangs if OpenGL window is put on second display
                # but works if moved after a delay.
                self.setScreen(self._session.ui.primaryScreen())

                def _set_fullscreen(self=self, screen=screen):
                    self.setScreen(screen)
                    self.showFullScreen()

                # Have to save reference to timer or it is deleted before executing.
                self._timer = self._session.ui.timer(1000, _set_fullscreen)
                #from PyQt5.QtCore import Qt
                #self.setFlags(Qt.FramelessWindowHint)
                self.show()
            else:
                self.showFullScreen()
        else:
            lgc._show_quilt = True
            self.setWidth(500)
            self.setHeight(500)
            self.show()

        t = session.triggers
        self._render_handler = t.add_handler('frame drawn', self._frame_drawn)
        self._app_quit_handler = t.add_handler('app quit', self._app_quit)
Exemplo n.º 4
0
    def let_program_embed(self, command):
        self.w = QWindow()
        self.container = QWidget.createWindowContainer(self.w, self)

        xid = int(self.w.winId())
        cmd = command.replace('{XID}', str(xid))
        self.launch(cmd)
        self.show()
        # there seems to be a race - sometimes the foreign window doesn't embed
        time.sleep(.2)
Exemplo n.º 5
0
    def embedBrowser(self):
        if LINUX:
            self.hidden_window = QWindow()
        windowInfo = cefpython.WindowInfo()
        rect = [0, 0, self.width(), self.height()]
        windowInfo.SetAsChild(self.getHandle(), rect)

        self.browser = cefpython.CreateBrowserSync(
            windowInfo, browserSettings={}, navigateUrl=config.DEFAULT_URL)

        # Add Handler
        self.browser.SetClientHandler(ClientHandler())
Exemplo n.º 6
0
    def __init__(self, parent=None):
        QWindow.__init__(self, parent)

        self.parent = parent

        self.chil = [
            item for item in self.parent.itemList
            if item.b.checkState() == 2 and item.frozen == 0
        ]

        QShortcut(QtGui.QKeySequence(Qt.Key_Escape),
                  self).activated.connect(self.close)

        self.gui()
Exemplo n.º 7
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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()))
Exemplo n.º 11
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)
Exemplo n.º 12
0
    def reparent(self):
        qwindow = self.windowHandle()

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

        qwindow.setPosition(QPoint(self.x, self.y))
    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))
Exemplo n.º 14
0
 def event(self, event):
     # QWindow does not have drag and drop methods to handle file dropped on app
     # so we detect the drag and drop events here and pass them to the main window.
     if self.handle_drag_and_drop(event):
         return True
     from PyQt5.QtCore import QEvent
     if event.type() == QEvent.Show:
         self.session.ui.mouse_modes.set_graphics_window(self)
         self._check_opengl()
     return QWindow.event(self, event)
Exemplo n.º 15
0
    def draw(self):
        pr = QWindow().devicePixelRatio()
        size = QSize(self._label.width(), self._label.height()) * pr
 
        qim = ImageQt.ImageQt(self._image.image())
        pixmap = QPixmap.fromImage(qim)
        pixmap.setDevicePixelRatio(pr)
        pixmap = pixmap.scaled(size, Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation)
        self._label.clear()
        self._label.setPixmap(pixmap)
Exemplo n.º 16
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)
Exemplo n.º 17
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
Exemplo n.º 18
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
Exemplo n.º 19
0
    def draw(self):
        self._thumb.clear()
        pr = QWindow().devicePixelRatio()
        size = QSize(self._thumb.width(), self._thumb.height()) * pr

        qim = ImageQt.ImageQt(self._image)
        pm = QPixmap.fromImage(qim)
        pm.setDevicePixelRatio(pr)
        pm = pm.scaled(size,
                       Qt.KeepAspectRatio,
                       transformMode=Qt.SmoothTransformation)
        self._thumb.setPixmap(pm)
Exemplo n.º 20
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
Exemplo n.º 21
0
    def __init__(self, parent=None):
        QWindow.__init__(self, parent)

        QShortcut(QtGui.QKeySequence(Qt.Key_Escape),
                  self).activated.connect(self.close)

        pas = ''

        for x in range(16):  # Количество символов (16)
            pas = pas + random.choice(
                list(
                    '1234567890abcdefghigklmnopqrstuvyxwzABCDEFGHIGKLMNOPQRSTUVYXWZ'
                ))

        lbl = QLabel('Новый Пароль')
        edit_text = QLineEdit()
        edit_text.setText(pas)

        mainLayout = QVBoxLayout(self)
        mainLayout.addWidget(edit_text)

        self.show()
Exemplo n.º 22
0
 def _make_widget(self):
     from PyQt5.QtWidgets import QStatusBar, QSizePolicy, QWidget
     sb = QStatusBar()
     sb.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)
     from PyQt5.QtGui import QWindow, QSurface
     self._window = pw = QWindow()
     pw.exposeEvent = self._expose_event
     pw.resizeEvent = self._resize_event
     pw.keyPressEvent = self.session.ui.forward_keystroke
     pwidget = QWidget.createWindowContainer(pw, sb)
     pw.setSurfaceType(QSurface.OpenGLSurface)
     sb.addWidget(pwidget, stretch = 1)
     return sb
Exemplo n.º 23
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()
Exemplo n.º 24
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)
Exemplo n.º 25
0
def mask_image(imgdata, img_size: tuple = (100, 100), size: int = 64):

    imgtype = os.path.splitext(os.path.split(imgdata)[1])[1]

    # Load image
    image = QImage.fromData(open(imgdata, "rb").read(), imgtype)

    # convert image to 32-bit ARGB (adds an alpha
    # channel ie transparency factor):
    image.convertToFormat(QImage.Format_ARGB32)

    # Crop image to a square:
    imgsize = min(image.width(), image.height())
    rect = QRect((image.width() - imgsize) // 2,
                 (image.height() - imgsize) // 2, imgsize, imgsize)

    image = image.copy(rect)

    # Create the output image with the same dimensions
    # and an alpha channel and make it completely transparent:
    out_img = QImage(imgsize, imgsize, QImage.Format_ARGB32)
    out_img.fill(Qt.transparent)

    # Create a texture brush and paint a circle
    # with the original image onto the output image:
    brush = QBrush(image)

    # Paint the output image
    painter = QPainter(out_img)
    painter.setBrush(brush)

    # Don't draw an outline
    painter.setPen(Qt.NoPen)

    # drawing circle
    painter.drawEllipse(0, 0, imgsize, imgsize)

    # closing painter event
    painter.end()

    # Convert the image to a pixmap and rescale it.
    pr = QWindow().devicePixelRatio()
    pm = QPixmap.fromImage(out_img)
    pm.setDevicePixelRatio(pr)
    size *= pr
    pm = pm.scaled(img_size[0], img_size[1], Qt.KeepAspectRatio,
                   Qt.SmoothTransformation)

    # return back the pixmap data
    return pm
Exemplo n.º 26
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
Exemplo n.º 27
0
    def __init__(self, old_widget, new_widget, duration=300):
        QtWidgets.QWidget.__init__(self, new_widget)

        pr = QWindow().devicePixelRatio()
        self.old_pixmap = QPixmap(new_widget.size()*pr)
        self.old_pixmap.setDevicePixelRatio(pr)
        old_widget.render(self.old_pixmap)

        self.timeline = QtCore.QTimeLine()
        self.timeline.valueChanged.connect(self.animate)
        self.timeline.finished.connect(self.close)
        self.timeline.setDuration(duration)
        self.timeline.start()

        self.resize(new_widget.size())
        self.show()
Exemplo n.º 28
0
    def paint(self, QPainter, QStyleOptionViewItem, QModelIndex):
        proxyModel = QModelIndex.model()
        index = proxyModel.mapToSource(QModelIndex)
        model = QModelIndex.model().sourceModel()
        filepath = model.filePath(index)
        try :
            _, _, files = next(os.walk(filepath))
        except Exception as e:
            print('filepath:%s, error:%s'%(filepath, str(e)))
            return 

        pr = QWindow().devicePixelRatio()
        lsize = QSize(ITEM_WIDTH, ITEM_HEIGHT - 20)
        rsize = lsize * pr

        qimage = None
        subext = ['srt', 'smi', 'ass', 'sub', 'sup']
        title = index.data(Qt.DisplayRole)
        sub = False
        for file in files:
            if not sub and file[-3:].lower() in subext:
                title += '(%s)' % file[-3:]
                sub = True
            elif not qimage and '-poster.' in file:
                qimage = QImage('%s/%s'%(filepath, file)).scaled(rsize,
                    Qt.KeepAspectRatio, transformMode=Qt.SmoothTransformation)
               
        if not qimage: return

        lImgHeight = int(qimage.height() / pr)
        lImgWidth = int(qimage.width() / pr)
        rect = QStyleOptionViewItem.rect
        #voffset = (rect.height() - lImgHeight)/2
        hoffset = (rect.width() - lImgWidth)/2
        imgrect = QRect(rect.left() + hoffset, rect.top(), lImgWidth, lImgHeight)
        pixmap = QPixmap.fromImage(qimage)
        pixmap.setDevicePixelRatio(pr)

        QPainter.drawPixmap(imgrect, pixmap)
        txtrect = QRect(rect.left(), rect.top() + (ITEM_HEIGHT - 20), ITEM_WIDTH, 20)
        QPainter.drawText(txtrect, Qt.AlignCenter, os.path.basename(title))

        if QStyleOptionViewItem.state & QStyle.State_Selected:
            highlight_color = QStyleOptionViewItem.palette.highlight().color()
            highlight_color.setAlpha(50)
            highlight_brush = QBrush(highlight_color)
            QPainter.fillRect(rect, highlight_brush)
Exemplo n.º 29
0
    def paint(self, QPainter, QStyleOptionViewItem, QModelIndex):
        proxyModel = QModelIndex.model()
        index = proxyModel.mapToSource(QModelIndex)
        model = QModelIndex.model().sourceModel()
        filepath = model.filePath(index)
        try:
            _, _, files = next(os.walk(filepath))
        except Exception as e:
            print('filepath:%s, error:%s' % (filepath, str(e)))
            return

        pr = QWindow().devicePixelRatio()
        lsize = QSize(ITEM_WIDTH, ITEM_HEIGHT - 20)
        rsize = lsize * pr

        qimage = None
        rect = QStyleOptionViewItem.rect
        offsetx = 0
        files.reverse()
        for file in files:
            if not '.jpg' in file:
                continue
            qimage = QImage('%s/%s' % (filepath, file)).scaled(
                rsize,
                Qt.KeepAspectRatio,
                transformMode=Qt.SmoothTransformation)

            lImgHeight = int(qimage.height() / pr)
            lImgWidth = int(qimage.width() / pr)
            imgrect = QRect(rect.left() + offsetx, rect.top(), lImgWidth,
                            lImgHeight)
            pixmap = QPixmap.fromImage(qimage)
            pixmap.setDevicePixelRatio(pr)
            QPainter.drawPixmap(imgrect, pixmap)
            offsetx += lImgWidth + 10

        txtrect = QRect(rect.left(),
                        rect.top() + (ITEM_HEIGHT - 20), ITEM_WIDTH, 20)
        QPainter.drawText(txtrect, Qt.AlignCenter,
                          os.path.basename(index.data(Qt.DisplayRole)))

        if QStyleOptionViewItem.state & QStyle.State_Selected:
            highlight_color = QStyleOptionViewItem.palette.highlight().color()
            highlight_color.setAlpha(50)
            highlight_brush = QBrush(highlight_color)
            QPainter.fillRect(rect, highlight_brush)
Exemplo n.º 30
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()
Exemplo n.º 31
0
    def mask_image(self, imgdata, imgtype='png', size=35):
        """Return a ``QPixmap`` from *imgdata* masked with a smooth circle.

        *imgdata* are the raw image bytes, *imgtype* denotes the image type.

        The returned image will have a size of *size* × *size* pixels.
        """
        # Load image and convert to 32-bit ARGB (adds an alpha channel):
        image = QImage.fromData(imgdata, imgtype)
        image.convertToFormat(QImage.Format_ARGB32)

        # Crop image to a square:
        imgsize = min(image.width(), image.height())
        rect = QRect(
            (image.width() - imgsize) / 2,
            (image.height() - imgsize) / 2,
            imgsize,
            imgsize,
        )
        image = image.copy(rect)

        # Create the output image with the same dimensions and an alpha channel
        # and make it completely transparent:
        out_img = QImage(imgsize, imgsize, QImage.Format_ARGB32)
        out_img.fill(Qt.transparent)

        # Create a texture brush and paint a circle with the original image onto
        # the output image:
        brush = QBrush(image)        # Create texture brush
        painter = QPainter(out_img)  # Paint the output image
        painter.setBrush(brush)      # Use the image texture brush
        painter.setPen(Qt.NoPen)     # Don't draw an outline
        painter.setRenderHint(QPainter.Antialiasing, True)  # Use AA
        painter.drawEllipse(0, 0, imgsize, imgsize)  # Actually draw the circle
        painter.end()                # We are done (segfault if you forget this)

        # Convert the image to a pixmap and rescale it.  Take pixel ratio into
        # account to get a sharp image on retina displays:
        pr = QWindow().devicePixelRatio()
        pm = QPixmap.fromImage(out_img)
        pm.setDevicePixelRatio(pr)
        size *= pr
        pm = pm.scaled(size, size, Qt.KeepAspectRatio, Qt.SmoothTransformation)

        return pm
Exemplo n.º 32
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()
Exemplo n.º 33
0
 def _show_window(self, window: QWindow) -> None:
     window.show()
     window.raise_()
     window.requestActivate()