Exemple #1
0
    def __init__(self, x, y, w, h, parent):
        self.window = QtGui.QWidget(
            None, QtCore.Qt.X11BypassWindowManagerHint
            | QtCore.Qt.WindowStaysOnTopHint)
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.parent = parent
        self.mask = QtGui.QBitmap(self.w + self.borderwidth * 2,
                                  self.h + self.borderwidth * 2)
        self.mask.fill(QtCore.Qt.color1)

        self.window.paintEvent = self.paintEvent
        self.window.setWindowTitle("qt-recordMyDesktop frame")

        self.window.setFixedSize(self.w + self.borderwidth * 2,
                                 self.h + self.borderwidth * 2)

        self.window.move(self.x - self.borderwidth, self.y - self.borderwidth)
        self.window.show()
        self.timer = QtCore.QTimer(None)
        self.timer.connect(self.timer, QtCore.SIGNAL("timeout()"),
                           self.moveFrame)
        self.timer.start(100)
        self.screen_width = QtGui.qApp.desktop().width()
        self.screen_height = QtGui.qApp.desktop().height()
Exemple #2
0
 def __mergeImages(self, imagePaths):
     """
     Combines a list of images into one image. Used for combining manacost 
     images.
     """
     
     firstImage = QtGui.QPixmap(imagePaths[0])
     width = firstImage.width()
     height = firstImage.height()
     
     mergedImage = QtGui.QPixmap(width * len(imagePaths), height)
     bitMap = QtGui.QBitmap(mergedImage)
     bitMap.clear()
     mergedImage.setMask(bitMap)
     painter = QtGui.QPainter(mergedImage)
     
     topleft = (0,0)
     
     for imagePath in imagePaths:
         image = QtGui.QPixmap(imagePath)
         rect = QtCore.QRect(topleft[0], topleft[1], width, height)
         painter.drawPixmap(rect, image, image.rect())
         
         topleft = (topleft[0] + width, topleft[1])
     
     return mergedImage
Exemple #3
0
 def __mergePixMaps(self, pixMaps):
     """
     Combines a list of pixmaps into one.
     """
     
     width = pixMaps[0].width()
     height = pixMaps[0].height() 
     
     mergedPixMap = QtGui.QPixmap(width, height+ 20 * len(pixMaps))
     bitMap = QtGui.QBitmap(mergedPixMap)
     bitMap.clear()
     mergedPixMap.setMask(bitMap)
     painter = QtGui.QPainter(mergedPixMap)
     
     counter = 0
     for pixMap in pixMaps:
         tempPixMap = QtGui.QPixmap(pixMap)
         painter.drawPixmap(0, 20 * counter, 
                            width, height,
                            tempPixMap)
         
         counter += 1
         
     
     return mergedPixMap
Exemple #4
0
    def updateIcons(self):
        iconSize = self.btnCompleteAndNext.iconSize()
        iconSize.setWidth(iconSize.width() * 2)
        pComplete = QtGui.QPixmap(
            u':/new/prefix1/icons/eq/clientComplete.png').scaledToHeight(
                iconSize.height(), QtCore.Qt.SmoothTransformation)
        pCancel = QtGui.QPixmap(
            u':/new/prefix1/icons/eq/clientNotAvailable.png').scaledToHeight(
                iconSize.height(), QtCore.Qt.SmoothTransformation)
        pNext = QtGui.QPixmap(
            u':/new/prefix1/icons/eq/next.png').scaledToHeight(
                iconSize.height(), QtCore.Qt.SmoothTransformation)

        alphaBitmap = QtGui.QBitmap(iconSize)
        alphaBitmap.clear()

        pCompleteAndNext = QtGui.QPixmap(iconSize)
        pCompleteAndNext.setMask(alphaBitmap)
        pnt = QtGui.QPainter(pCompleteAndNext)
        pnt.drawPixmap(0, 0, pComplete)
        pnt.drawPixmap(pComplete.width(), 0, pNext)
        pnt.end()
        self.btnCompleteAndNext.setIconSize(iconSize)
        self.btnCompleteAndNext.setIcon(QtGui.QIcon(pCompleteAndNext))

        pCancelAndNext = QtGui.QPixmap(iconSize)
        pCancelAndNext.setMask(alphaBitmap)
        pnt = QtGui.QPainter(pCancelAndNext)
        pnt.drawPixmap(0, 0, pCancel)
        pnt.drawPixmap(pCancel.width(), 0, pNext)
        pnt.end()
        self.btnCancelAndNext.setIconSize(iconSize)
        self.btnCancelAndNext.setIcon(QtGui.QIcon(pCancelAndNext))
Exemple #5
0
        def __init__(self, parent=None):
            QtGui.QWidget.__init__(self, parent)
            self.parent=parent
            self.myMenu=None
            mask=QtGui.QPixmap("./icons/translate60.png")
            self.setMask(QtGui.QBitmap(mask.mask()))
            p=QtGui.QPalette()
            p.setBrush(QtGui.QPalette.Window, QtGui.QBrush(mask))
            self.setPalette(p)
            self.setGeometry(200, 100, 60, 60)
            self.setWindowFlags(QtCore.Qt.FramelessWindowHint|QtCore.Qt.WindowStaysOnTopHint|
                QtCore.Qt.X11BypassWindowManagerHint|QtCore.Qt.Tool )

            self.setWindowIcon(QtGui.QIcon('./icons/translate60.png'))
            self.mouseMovePos = QtCore.QPoint(0, 0)
Exemple #6
0
    def __init__(self, lsys=None, params=[], icons=[], parent=None):
        QMainWindow.__init__(self, parent)
        self.iconSize = [250, 100]
        self.lsys = lsys
        self.params = params
        self.icons = icons
        self.env = {}

        self.widget = Widget()
        registerPlotter(self.widget)
        self.setCentralWidget(self.widget)

        self.layout = QtGui.QHBoxLayout()
        self.vlayout = QtGui.QVBoxLayout(self.widget)
        self.vlayout.addStretch(0)
        self.vlayout.addLayout(self.layout)

        #pm = QtGui.QPixmap('heix.png')
        self.button = QPushButton('', self.widget)
        self.button.setMinimumSize(self.iconSize[1], self.iconSize[1])
        self.button.setMaximumSize(self.iconSize[1], self.iconSize[1])
        self.button.setIcon(QtGui.QIcon(get_shared_image('GoButton.png')))
        self.button.setIconSize(
            QtCore.QSize(self.iconSize[1], self.iconSize[1]))

        #mask = pm.mask()
        mask = QtGui.QBitmap(get_shared_image('GoButtonMask.png'))
        self.button.setMask(mask)

        def buttonCallback():
            self.lsys.context().updateNamespace(self.env)
            self.lsys.animate()

        def printImageCB():
            self.printImage()

        self.add_controls()

        QtCore.QObject.connect(self.button, QtCore.SIGNAL('clicked()'),
                               buttonCallback)
        self.layout.addStretch(0)
        self.layout.addWidget(self.button)

        self.widget.setLayout(self.vlayout)
Exemple #7
0
    def get_cursor(self):
        xpm_map = [
            "32 32 2 1", ". c #ffffff", "O c #000000",
            "................................",
            "................................",
            "................................",
            "...O............................",
            "...OO...........................",
            "...OOO..........................",
            "...OOOO.........................",
            "...OOOOO........................",
            "...OOOOOO.......................",
            "...OOOOOOO......................",
            "...OOOOOOOO.....................",
            "...OOOOOOOOO....................",
            "...OOOOOOOOOO...................",
            "...OOOOOOOOOOO..................",
            "...OOOOOOO......................",
            "...OOOOOOO......................",
            "...OOO.OOOO.....................",
            "...O...OOOO.....................",
            "........OOOO....................",
            "........OOOO....................",
            ".........OOOO...................",
            ".........OOOO...................",
            "..........OO....................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................"
        ]

        xpm_mask = [
            "32 32 2 1", ". c #ffffff", "O c #000000",
            "................................",
            "................................",
            "..OO............................",
            "..OOO...........................",
            "..OOOO..........................",
            "..OOOOO.........................",
            "..OOOOOO........................",
            "..OOOOOOO.......................",
            "..OOOOOOOO......................",
            "..OOOOOOOOO.....................",
            "..OOOOOOOOOO....................",
            "..OOOOOOOOOOO...................",
            "..OOOOOOOOOOOO..................",
            "..OOOOOOOOOOOOO.................",
            "..OOOOOOOOOOOOO.................",
            "..OOOOOOOOO.....................",
            "..OOOOOOOOOO....................",
            "..OOOOOOOOOO....................",
            "..OO...OOOOOO...................",
            ".......OOOOOO...................",
            "........OOOOOO..................",
            "........OOOOOO..................",
            ".........OOOO...................",
            "..........OO....................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................",
            "................................"
        ]

        pixmap = QtGui.QPixmap(xpm_map)
        mask = QtGui.QBitmap(QtGui.QPixmap(xpm_mask))
        pixmap.setMask(mask)
        return QtGui.QCursor(pixmap, 3, 3)
Exemple #8
0
 def ocultar_puntero_del_mouse(self):
     bitmap = QtGui.QBitmap(1, 1)
     nuevo_cursor = QtGui.QCursor(bitmap, bitmap)
     self.setCursor(QtGui.QCursor(nuevo_cursor))
Exemple #9
0
    def get_icons(self):
        if self.task.icon:
            # Get all icons of multiple sizes from window's _NET_WM_ICON property,
            # which is a flat list of integers, representing icon's dimensions
            # and ARGB pixel colors
            pos = 0
            icons = []
            while pos < len(self.task.icon):
                icon_width = self.task.icon[pos]
                icon_height = self.task.icon[pos + 1]
                data_length = icon_width * icon_height
                data_start = pos + 2  # skip width and height values
                data_finish = data_start + data_length
                data = self.task.icon[data_start:data_finish]
                icons.append({
                    'width': icon_width,
                    'height': icon_height,
                    'data': data
                })
                pos = data_finish

            for icon in icons:
                # Convert icon's pixel data to byte string as unsigned integers (4 bytes each)
                argb_data = array('I', icon['data']).tostring()

                # New QImage from icon's data,
                # third argument is number of bytes in argb_data per line of image
                image = QtGui.QImage(argb_data, icon['width'], icon['height'],
                                     4 * icon['width'],
                                     QtGui.QImage.Format_ARGB32)

                # New QPixmap to use as image in a QLabel widget
                pixmap = QtGui.QPixmap.fromImage(image)
                icon['pixmap'] = pixmap

                # Delete binary data
                icon.pop('data')

            self.icons = icons

        elif self.task.old_icon:
            # Some applications don't set _NET_WM_ICON (namely SDL-based games:
            # Wesnoth, RenPy VNs, etc), so we've got to take icon from WM_HINTS

            # Create icon's image pixmap and mask pixmap from their X11 counterparts
            pixmap = QtGui.QPixmap.fromX11Pixmap(
                self.task.old_icon['pixmap'].id, 0)
            mask_pixmap = QtGui.QPixmap.fromX11Pixmap(
                self.task.old_icon['mask'].id, 0)

            # Create and apply bitmap mask from mask pixmap
            mask_bitmap = QtGui.QBitmap(mask_pixmap)
            # pixmap.setMask(mask_bitmap)

            self.icons = [{
                'width': pixmap.width(),
                'height': pixmap.height(),
                'pixmap': pixmap
            }]
        else:
            self.icons = []
Exemple #10
0
    def __beautify(self):
        self.setTexture(u":/img/skin.png")
        self.min_btn.setAutoDefault(False)
        self.close_btn.setAutoDefault(False)
        self.play_btn.setAutoDefault(False)
        self.regret_btn.setAutoDefault(False)
        self.lose_btn.setAutoDefault(False)
        self.draw_btn.setAutoDefault(False)

        self.name_1.setFont(QtGui.QFont(u"微软雅黑", 9))
        self.name_2.setFont(QtGui.QFont(u"微软雅黑", 9))
        self.win_label.setFont(QtGui.QFont(u"微软雅黑", 40))

        self.lineEdit.setFont(QtGui.QFont(u"微软雅黑", 9))
        self.chat_browser.setFont(QtGui.QFont(u"微软雅黑", 9))

        self.time_left_1.display(u"10:00")
        self.time_left_2.display(u"10:00")
        self.time_left_1.hide()
        self.time_left_2.hide()

        self.white_turn = QtGui.QPixmap(32, 31)
        self.black_turn = QtGui.QPixmap(32, 31)
        self.turn_mask = QtGui.QBitmap(32, 31)
        painter = QtGui.QPainter()
        painter.begin(self.black_turn)
        painter.drawPixmap(0, 0, QtGui.QPixmap(u":/img/2104.bmp"), 0, 0, 32,
                           31)
        painter.end()

        painter.begin(self.white_turn)
        painter.drawPixmap(0, 0, QtGui.QPixmap(u":/img/2104.bmp"), 32, 0, 32,
                           31)
        painter.end()

        painter.begin(self.turn_mask)
        painter.drawPixmap(0, 0, QtGui.QPixmap(u":/img/2104.bmp"), 64, 0, 32,
                           31)
        painter.end()

        self.white_chess = QtGui.QPixmap(33, 33)
        self.black_chess = QtGui.QPixmap(33, 33)
        self.chess_mask = QtGui.QBitmap(33, 33)
        painter = QtGui.QPainter()
        painter.begin(self.black_chess)
        painter.drawPixmap(0, 0, QtGui.QPixmap(u":/img/2096.bmp"), 0, 0, 33,
                           33)
        painter.end()

        painter.begin(self.white_chess)
        painter.drawPixmap(0, 0, QtGui.QPixmap(u":/img/2096.bmp"), 33, 0, 33,
                           33)
        painter.end()

        painter.begin(self.chess_mask)
        painter.drawPixmap(0, 0, QtGui.QPixmap(u":/img/2096.bmp"), 66, 0, 33,
                           33)
        painter.end()

        self.pic_1.setPixmap(
            QtGui.QPixmap(u":img/01299.png").scaled(self.pic_1.size()))
        self.pic_2.setPixmap(
            QtGui.QPixmap(u":img/01299.png").scaled(self.pic_2.size()))
        self.pic_2.hide()