Exemplo n.º 1
0
    def paint(self, painter, option, index):
        rect = option.rect
        movie = index.data(Qt.UserRole)

        painter.setOpacity(0.7)
        if option.state & QStyle.State_Selected:
            painter.drawRect(rect)

        # draw poster background
        painter.setPen(self.outline)
        painter.setBrush(self.backgoundBrush)
        painter.drawRect(rect)

        # draw poster
        pixmap = QPixmap(movie.poster).scaled(rect.width() - 25,
                                              rect.height() - 50,
                                              Qt.KeepAspectRatio,
                                              Qt.SmoothTransformation)

        posterRect = QRect(rect.x() + 15,
                           rect.y() + 15, pixmap.width(), pixmap.height())
        painter.drawPixmap(posterRect, pixmap)

        # draw movie title
        titleRect = QRect(rect.x(),
                          rect.bottom() - 30, rect.width(), rect.height())

        releaseText = "({})".format(
            movie.releaseDate.split("-")[0]) if movie.releaseDate else ""
        painter.drawText(titleRect, Qt.AlignHCenter,
                         u"{0} {1}".format(movie.name, releaseText))
Exemplo n.º 2
0
    def __init__(self, parent):
        '''Initialization'''

        QStyledItemDelegate.__init__(self, parent)

        self.bg_color = QColor('#000000')
        self.bg_alternate_color = QColor('#333333')
        self.new_bg_color = QColor('#0044dd')
        self.new_bg_alternate_color = QColor('#223399')
        self.user_color = QColor('#7AB4F5')
        self.time_color = QColor('#7AB4F5')
        self.replyto_color = QColor('#7AB4F5')

        self.text_color = QColor('#FFFFFF')
        self.separator_color = QColor('#000000')
        self.fsize = 1.0
        self.fm = None
        self.minifm = None

        self.normFont = None
        self.miniFont = None

        #        print os.path.join(os.path.dirname(__file__),
        #                                  'icons', 'reply.png')
        self.reply_icon = QPixmap(
            os.path.join(os.path.dirname(__file__), 'icons', 'reply.png'))
        #        print dir(self.reply_icon)
        self.retweet_icon = QPixmap(
            os.path.join(os.path.dirname(__file__), 'icons', 'retweet.png'))
        self.geoloc_icon = QPixmap(
            os.path.join(os.path.dirname(__file__), 'icons', 'geoloc.png'))
Exemplo n.º 3
0
    def __init__(self, parent=None, warningAction=None, warningService=None):
        """
        Constructor

        @param parent: Qt widget parent of this dialog window
        @type parent: QWidget

        @param warningAction: The action to connect to.
        @type warningAction: QAction
        """
        super(WarningsDialog, self).__init__(parent)
        self.setupUi(self)

        self.setWarningAction(warningAction)
        self.setWarningService(warningService)

        self.statusBarService = StatusBarService()

        self.errorString = ""
        self.errorMsgTextEdit.setPlainText(self.errorString)

        self.iconWarning = QIcon()
        self.iconWarning.addPixmap(
            QPixmap(
                ":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-severe-alert.png"
            ), QIcon.Normal, QIcon.Off)

        self.iconNoWarning = QIcon()
        self.iconNoWarning.addPixmap(
            QPixmap(
                ":/tango-status-32px/images/tango-icon-theme/32x32/status/weather-clear.png"
            ), QIcon.Normal, QIcon.Off)
Exemplo n.º 4
0
    def decoration(self, index):
        """Defines the decoration of the node.

        Tries to load a banner from the URL, defined by :py:meth:`banner_url`,
        sets a default image while loading and in case the attempt to
        obtain a banner was unsuccesful. If a banner has been cached for the
        given URL, the cached image will be used instead.

        :param index: The index referring to the node to get decoration for.
        :type index: :class:`~.PySide.QtCore.QModelIndex`

        :returns: The :class:`PySide.QtGui.Pixmap` to use as the node's decoration.

        """
        pixmap = QPixmap()
        banner_url = self.banner_url()
        if banner_url:
            placeholder = ":/icons/image-loading.png"
            fetch = True
        else:
            banner_url = placeholder = ":/icons/image-missing.png"
            fetch = False

        if not pixmap_cache.find(banner_url, pixmap):
            if fetch:
                banner_loader.fetch_banner(banner_url, index, self._cache)
            pixmap.load(placeholder)
            if self._scale:
                pixmap = pixmap.scaled(self._scale, Qt.AspectRatioMode.KeepAspectRatio)
            pixmap_cache.insert(banner_url, pixmap)
        return pixmap
Exemplo n.º 5
0
    def __init__(self, title, subtitle, icon_path):
        """
        :param title: str title
        :param subtitle: str subtitle
        :param icon_path: path of picture
        """
        super(MyLable, self).__init__()
        self.lb_title = QLabel(title)
        self.lb_title.setFont(QFont("Arial", 10, QFont.Bold))
        self.lb_subtitle = QLabel(subtitle)
        self.lb_subtitle.setFont(QFont("Arial", 8, QFont.StyleItalic))

        self.lb_subtitle1 = QLabel(subtitle)
        self.lb_subtitle1.setFont(QFont("Arial", 8, QFont.StyleItalic))

        self.lb_icon = QLabel()
        self.lb_icon.setFixedSize(40, 40)
        pixMap = QPixmap(icon_path).scaled(self.lb_icon.width(), self.lb_icon.height())
        self.lb_icon.setPixmap(pixMap)

        self.lb_icon1 = QLabel()
        self.lb_icon1.setFixedSize(40, 40)
        pixMap1 = QPixmap(icon_path).scaled(self.lb_icon.width(), self.lb_icon.height())
        self.lb_icon1.setPixmap(pixMap1)

        self.double_click_fun = None
        self.init_ui()
Exemplo n.º 6
0
def main():
    app = QApplication(sys.argv)
    import qdarkstyle
    # setup stylesheet
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    pixmap = QPixmap(os.path.join(_resourcepath('images'), "splash.png"))
    splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
    splash.setMask(pixmap.mask())
    splash_font = splash.font()
    splash_font.setPixelSize(14)
    splash.setFont(splash_font)
    splash.show()
    splash.showMessage('Initialising...',
                       Qt.AlignBottom | Qt.AlignLeft |
                       Qt.AlignAbsolute,
                       Qt.white)
    app.processEvents()
    """
    for count in range(1, 6):
        splash.showMessage('Processing {0}...'.format(count),
                           Qt.AlignBottom | Qt.AlignLeft,
                           Qt.white)
        QApplication.processEvents()
        QThread.msleep(1000)
    """
    frame = ConfiguratorWindow()

    frame.show_and_raise()
    splash.finish(frame)
    sys.exit(app.exec_())
Exemplo n.º 7
0
 def update_data(self):
     """
     Updates the data in the form
     """
     try:
         data = self.backend_handle.read_report(code=int(self.code))
         if data:
             if data[0]:
                 data = data[1]
                 self.code_line.setText(data['code'])
                 self.code_line.setDisabled(True)
                 self.date_line.setDate(data['date'])
                 self.organization_line.setText(data['organization'])
                 self.test_line.setText(data['test'])
                 self.description_line.setText(data['description'])
                 self.image_data = str(data['report'])
                 self.pixmap = QPixmap()
                 self.pixmap.loadFromData(self.image_data)
                 self.image_label.setPixmap(
                     self.pixmap.scaled(self.image_label.size(),
                                        Qt.KeepAspectRatio,
                                        Qt.FastTransformation))
     except Exception:
         if settings.level == 10:
             logger.exception('raised exception')
         return False, 'Some Internal Error'
Exemplo n.º 8
0
 def apply(self, value):
     if isinstance(value, basestring):
         value = QPixmap(value)
     assert isinstance(value, QPixmap), "Image bridge must be assigned a pixmap"
     if self.width and self.height:
         value = value.scaled(self.width, self.height)
     self.widget.setPixmap(value)
Exemplo n.º 9
0
 def convertTextureSize(texturePath):
     if int(cmds.about(v=1)) < 2017:
         from PySide import QtCore
         from PySide.QtGui import QPixmap, QImage
         from PySide.QtCore import QFile, QIODevice
     else:
         from PySide2 import QtCore
         from PySide2.QtGui import QPixmap, QImage
         from PySide2.QtCore import QFile, QIODevice
     folder, fileName = ntpath.split(texturePath)
     origFileName = fileName if fileName[:
                                         8] != 'resized_' else fileName[
                                             8:]
     origPath = folder + '/' + origFileName
     if not os.path.exists(origPath):
         cmds.warning("original is not exists : %s" %
                      texturePath)
         return
     convertedFileName = 'resized_%d_' % (
         int(resolusion)) + origFileName
     renamedPath = folder + "/" + convertedFileName
     ext = os.path.splitext(fileName)[-1]
     img = QImage(origPath)
     pixmap = QPixmap()
     pixmap = pixmap.fromImage(
         img.scaled(int(resolusion), int(resolusion),
                    QtCore.Qt.IgnoreAspectRatio,
                    QtCore.Qt.FastTransformation))
     qfile = QFile(renamedPath)
     qfile.open(QIODevice.WriteOnly)
     pixmap.save(qfile, ext[1:], 100)
     qfile.close()
     return renamedPath
Exemplo n.º 10
0
    def load_more_images(self):

        if(self.within_set_index == -1):
            print "New set."
            self.current_set_index += 1
            arr = self.sets["sets"][self.current_set_index]

            if(len(arr) == 0):
                ret = QMessageBox.information(self, "Image Verification UI",
                                             "Ran out of images to compare.",
                                              QMessageBox.Ok)
                self.close()
            
            self.image1_filepath = arr[0].strip()
            self.image2_filepath = arr[1].strip()

            #print self.image1_filepath
            #print self.image2_filepath

            self.image1.setPixmap(QPixmap(self.image1_filepath).scaledToHeight(192))
            self.image2.setPixmap(QPixmap(self.image2_filepath).scaledToHeight(192))
            self.within_set_index = 2

        else:
            arr = self.sets["sets"][self.current_set_index]
            if(self.within_set_index >= len(arr)):
                self.within_set_index = -1
                self.load_more_images()
            else:
                self.image2_filepath = arr[self.within_set_index].strip()
                #print self.image2_filepath
                self.image2.setPixmap(QPixmap(self.image2_filepath).scaledToHeight(192))
                self.within_set_index += 1
Exemplo n.º 11
0
	def __init__(self, root_node, parent=None):
		super(AddDeviceDlg, self).__init__(parent)
		self.setWindowTitle("Add Relief Device")

		id_label = QLabel("&Relief Device ID:")
		self.id_lineedit = QLineEdit()
		self.id_lineedit.setMaxLength(200)
		id_label.setBuddy(self.id_lineedit)
		area_label = QLabel("Associated Relief Device &Area:")
		self.area_combobox = QComboBox()
		for area in root_node.children:
			self.area_combobox.addItem(area.name, area)
		area_label.setBuddy(self.area_combobox)
		color_label = QLabel("&Text Color:")
		self.color_combobox = QComboBox()
		for key in sorted(COLORS.keys()):
			pixmap = QPixmap(26, 26)
			pixmap.fill(COLORS[key])
			self.color_combobox.addItem(QIcon(pixmap), key)
		color_label.setBuddy(self.color_combobox)
		button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
			
		layout = QGridLayout()
		layout.addWidget(id_label, 0, 0)
		layout.addWidget(self.id_lineedit, 0, 1)
		layout.addWidget(area_label, 1, 0)
		layout.addWidget(self.area_combobox, 1, 1)
		layout.addWidget(color_label, 2, 0)
		layout.addWidget(self.color_combobox, 2, 1)
		layout.addWidget(button_box, 3, 1)
		self.setLayout(layout)
		
		button_box.accepted.connect(self.accept)
		button_box.rejected.connect(self.reject)
Exemplo n.º 12
0
 def pixmap(path):
     d = Resource.instance()
     f = d._pixmapPrefix + path
     p = QPixmap(f)
     if p.isNull():
         print "Pixmap not found: ", f
     return p
Exemplo n.º 13
0
def main():
    app = QApplication(sys.argv)
    import qdarkstyle
    # setup stylesheet
    app.setStyleSheet(qdarkstyle.load_stylesheet())
    pixmap = QPixmap(os.path.join(_resourcepath('images'), "splash.png"))
    splash = QSplashScreen(pixmap, Qt.WindowStaysOnTopHint)
    splash.setMask(pixmap.mask())
    splash_font = splash.font()
    splash_font.setPixelSize(14)
    splash.setFont(splash_font)
    splash.show()
    splash.showMessage('Initialising...',
                       Qt.AlignBottom | Qt.AlignLeft | Qt.AlignAbsolute,
                       Qt.white)
    app.processEvents()
    """
    for count in range(1, 6):
        splash.showMessage('Processing {0}...'.format(count),
                           Qt.AlignBottom | Qt.AlignLeft,
                           Qt.white)
        QApplication.processEvents()
        QThread.msleep(1000)
    """
    frame = ConfiguratorWindow()

    frame.show_and_raise()
    splash.finish(frame)
    sys.exit(app.exec_())
Exemplo n.º 14
0
    def _make_tabs_button(self, side_widgets, side_icons):

        if len(side_widgets) != len(side_icons):
            raise Exception(
                "Bad parameters : len(side_widgets) ({}) != len(side_icons) ({})"
                .format(len(side_widgets), len(side_icons)))

        layout = QVBoxLayout()

        self._side_icons = []

        ndx = 0
        for w in side_widgets:

            resource_name = side_icons[ndx]
            pixmap = QPixmap(os.path.join(resource_dir, resource_name))
            icon = QIcon(pixmap)
            self._side_icons.append(icon)

            b = QToolButton()
            b.setIcon(icon)
            b.setIconSize(pixmap.rect().size())
            b.setMaximumWidth(pixmap.rect().width() + 6)

            b.clicked.connect(self.signal_mapper_tab_changed.map)
            self.signal_mapper_tab_changed.setMapping(b, ndx)

            layout.addWidget(b)
            layout.setStretch(ndx, 1)
            ndx += 1

        layout.addStretch()

        return layout
 def setUp(self):
     super(QPixmapQDatastream, self).setUp()
     self.source_pixmap = QPixmap(100, 100)
     self.source_pixmap.fill(Qt.red)
     self.output_pixmap = QPixmap()
     self.buffer = QByteArray()
     self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
     self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)
Exemplo n.º 16
0
 def savePng(self, filename, filetype='PNG'):
     rect = self.sceneRect()
     pix = QPixmap(rect.width(), rect.height())
     painter = QPainter(pix)
     self.render(painter, painter.window(), rect)
     pix.save(filename, filetype)
     del painter
     del pix
 def setUp(self):
     super(QPixmapQDatastream, self).setUp()
     self.source_pixmap = QPixmap(100, 100)
     self.source_pixmap.fill(Qt.red)
     self.output_pixmap = QPixmap()
     self.buffer = QByteArray()
     self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly)
     self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly)
Exemplo n.º 18
0
 def paintEvent(self, pe):
   painter = QPainter(self)
   icon = QPixmap(self._icon)
   icon = icon.scaled(self.size(), Qt.IgnoreAspectRatio)
   if not self._mouse_over or not self._enabled:
     painter.setOpacity(self._normal_opacity)
   else:
     painter.setOpacity(self._hover_opacity)
   painter.drawPixmap(0, 0, icon)
Exemplo n.º 19
0
 def paintEvent(self, pe):
   if self._mouse_over:
     icon = self._hover_icon
   else:
     icon = self._normal_icon
   painter = QPainter(self)
   pixmap = QPixmap(icon)
   pixmap = pixmap.scaled(self.size(), Qt.IgnoreAspectRatio)
   painter.drawPixmap(0, 0, pixmap)
Exemplo n.º 20
0
 def _update_cursor(self):
     x = self.diameter
     w, h = x, x
     pixmap = QPixmap(w, h)
     pixmap.fill(Qt.transparent)
     p = QPainter(pixmap)
     p.drawPoints(self._points)
     p.end()
     self._cursor_pixmap = pixmap.createMaskFromColor(Qt.transparent)
Exemplo n.º 21
0
 def __init__(self, iconPath, hoverOpacity=1, normalOpacity=0.25, parent=None):
   super(IconWidget, self).__init__(parent)
   self.setMouseTracking(True)
   self._icon = QPixmap(iconPath)
   self.setFixedSize(QSize(self._icon.width(), self._icon.height()))
   self._hover_opacity = hoverOpacity
   self._normal_opacity = normalOpacity
   self._mouse_over = False # this is correct because when an icon appears after another, it appears where the mouse is
   self._enabled = True
Exemplo n.º 22
0
 def set_image_id(self, input_id):
     # hack bool to prevent blank meteors from rendering
     self.is_blank = True if input_id == 'blank' else False
     
     url = "assets/drawable/" + input_id + ".png"
     self.pixmap_image = QPixmap()
     
     if not self.pixmap_image.load(url):
         raise RuntimeError("Could not load image resource")
    def __init__(self, parent=None):
        super(SeparatorButton, self).__init__(parent)

        self.pix = (QPixmap(':/ShortCloseBar.png'),
                    QPixmap(':/ShortOpenBar.png'))

        self.is_collapsed = False
        self.icon = self.pix[1]
        self.setFlat(True)
        self.setFixedSize(TOOLBAR_SEPARATOR_WIDTH, 20)
Exemplo n.º 24
0
    def size_changed(self, value):
        "Handle the slider drag event."

        size = self.ui.brush_demo_label.size()
        pixmap = QPixmap(100, 100)
        pixmap.fill(Qt.white)
        cx, cy = int(size.width()/2), int(size.height()/2)
        self.current_brush.set_size(value)
        self.current_brush.draw_marker(cx, cy, pixmap, 1)
        self.ui.brush_demo_label.setPixmap(pixmap)
Exemplo n.º 25
0
    def size_changed(self, value):
        "Handle the slider drag event."

        size = self.ui.brush_demo_label.size()
        pixmap = QPixmap(100, 100)
        pixmap.fill(Qt.white)
        cx, cy = int(size.width() / 2), int(size.height() / 2)
        self.current_brush.set_size(value)
        self.current_brush.draw_marker(cx, cy, pixmap, 1)
        self.ui.brush_demo_label.setPixmap(pixmap)
Exemplo n.º 26
0
 def _wait_for_frame(self):
     if self.camera.wait_for_frame(0):
         data = self.camera.image_buffer()
         bpl = self.camera.bytes_per_line
         format = QImage.Format_RGB32
         image = QImage(data, self.camera.width, self.camera.height, bpl, format)
         if self.pixmapitem is None:
             self.pixmapitem = self.scene.addPixmap(QPixmap.fromImage(image))
         else:
             self.pixmapitem.setPixmap(QPixmap.fromImage(image))
Exemplo n.º 27
0
    def drawWidget(self, painter):

        if self.isHighlighted:
            painter.setOpacity(1.0)
        else:
            painter.setOpacity(0.5)

        pixmap = QPixmap(self.icon)
        pixmap = pixmap.scaledToWidth(self.width(), Qt.SmoothTransformation)
        painter.drawPixmap(self.rect(), pixmap)
Exemplo n.º 28
0
	def sendLocation(self, jid, latitude, longitude, rotate):
		latitude = latitude[:10]
		longitude = longitude[:10]

		self._d("Capturing preview...")
		QPixmap.grabWindow(QApplication.desktop().winId()).save(WAConstants.CACHE_PATH+"/tempimg.png", "PNG")
		img = QImage(WAConstants.CACHE_PATH+"/tempimg.png")

		if rotate == "true":
			rot = QTransform()
			rot = rot.rotate(90)
			img = img.transformed(rot)

		if img.height() > img.width():
			result = img.scaledToWidth(320,Qt.SmoothTransformation);
			result = result.copy(result.width()/2-50,result.height()/2-50,100,100);
		elif img.height() < img.width():
			result = img.scaledToHeight(320,Qt.SmoothTransformation);
			result = result.copy(result.width()/2-50,result.height()/2-50,100,100);
		#result = img.scaled(96, 96, Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation);

		result.save( WAConstants.CACHE_PATH+"/tempimg2.jpg", "JPG" );

		f = open(WAConstants.CACHE_PATH+"/tempimg2.jpg", 'r')
		stream = base64.b64encode(f.read())
		f.close()


		os.remove(WAConstants.CACHE_PATH+"/tempimg.png")
		os.remove(WAConstants.CACHE_PATH+"/tempimg2.jpg")

		fmsg = WAXMPP.message_store.createMessage(jid);
		
		mediaItem = WAXMPP.message_store.store.Media.create()
		mediaItem.mediatype_id = WAConstants.MEDIA_TYPE_LOCATION
		mediaItem.remote_url = None
		mediaItem.preview = stream
		mediaItem.local_path ="%s,%s"%(latitude,longitude)
		mediaItem.transfer_status = 2

		fmsg.content = QtCore.QCoreApplication.translate("WAEventHandler", "Location")
		fmsg.Media = mediaItem

		if fmsg.Conversation.type == "group":
			contact = WAXMPP.message_store.store.Contact.getOrCreateContactByJid(self.conn.jid)
			fmsg.setContact(contact);
		
		fmsg.setData({"status":0,"content":fmsg.content,"type":1})
		WAXMPP.message_store.pushMessage(jid,fmsg)
		
		
		resultId = self.interfaceHandler.call("message_locationSend", (jid, latitude, longitude, stream))
		k = Key(jid, True, resultId)
		fmsg.key = k.toString()
		fmsg.save()
Exemplo n.º 29
0
    def x_bitmap_opaque ( self, bitmap ):
        """ Returns a version of the specified bitmap with no transparency.
        """
        dx = bitmap.width()
        dy = bitmap.height()
        opaque_bitmap = QPixmap( dx, dy )
        opaque_bitmap.fill( WindowColor )
        q = QPainter( opaque_bitmap )
        q.drawPixmap( 0, 0, bitmap )

        return opaque_bitmap
Exemplo n.º 30
0
	def grabImg(self):
		self.idFrame += 1	
		wid = QApplication.desktop().winId()
		QPixmap.grabWindow(wid, self.screenArea.x, self.screenArea.y, self.screenArea.w, self.screenArea.h).save(self.buffer, 'png')
		strio = StringIO.StringIO()
		strio.write(self.buffer.data())
		self.buffer.seek(0)
		strio.seek(0)
		pix = np.array(Image.open(strio))
		pix = cv2.resize(pix, (0,0), fx=self.scale, fy=self.scale)
		real_color = cv2.cvtColor(pix, cv2.COLOR_BGR2RGB)
		return real_color
Exemplo n.º 31
0
def choose_color():
    color  = QColorDialog().getColor()
    
    msgbox = QMessageBox()
    if color.isValid():
        pixmap = QPixmap(50, 50)
        pixmap.fill(color)
        msgbox.setWindowTitle(u'Selected Color')
        msgbox.setIconPixmap(pixmap)
    else:
        msgbox.setWindowTitle(u'No Color was Selected')
    msgbox.exec_()
Exemplo n.º 32
0
    def mouseReleaseEvent(self, event):
        self.rubberBand.hide()
        if self.havePressed == True:
            self.end = event.pos()
            self.hide()

            QPixmap.grabWindow(QApplication.desktop().winId(), self.origin.x(),
                               self.origin.y(),
                               self.end.x() - self.origin.x(),
                               self.end.y() - self.origin.y()).save(
                                   'C:/Users/Ta/screenshot_windowed.png',
                                   'png')
Exemplo n.º 33
0
def choose_color():
    color = QColorDialog().getColor()

    msgbox = QMessageBox()
    if color.isValid():
        pixmap = QPixmap(50, 50)
        pixmap.fill(color)
        msgbox.setWindowTitle(u'Selected Color')
        msgbox.setIconPixmap(pixmap)
    else:
        msgbox.setWindowTitle(u'No Color was Selected')
    msgbox.exec_()
Exemplo n.º 34
0
 def __init__(self, imagePath, fill=True, parent=None):
   """
   Args:
     imagePath : a system path that points to an image fles
     fill : boolean that when True, makes the image fill the widget, whatever
            the current widget size. When False, just draws the image at it's original
            size.
   """
   super(ImageWidget, self).__init__(parent)
   assert imagePath != None, self.tr("Invalid image path")
   self._image_pixmap = QPixmap(path.normpath(imagePath))
   self._fill = fill
Exemplo n.º 35
0
 def __init__(self, parent=None):
     self.hamburger = QImage(128, 128, QImage.Format_ARGB32)
     QPushButton.__init__(self, parent)
     self.svgrenderer = QSvgRenderer("icons\\hamburger.svg")
     paint = QPainter(self.hamburger)
     paint.setRenderHint(QPainter.HighQualityAntialiasing)
     paint.setRenderHint(QPainter.SmoothPixmapTransform)
     self.svgrenderer.render(paint)
     paint.end()
     pixmap = QPixmap()
     self.setIcon(QIcon(pixmap.fromImage(self.hamburger)))
     self.setStyleSheet("QPushButton, QPushButton:pressed{background-color: rgba(0,0,0,0)} QPushButton:hover {background-color: rgba(255,255,255,100); border-radius: 32px} ")
Exemplo n.º 36
0
 def _wait_for_frame(self):
     if self.camera.wait_for_frame(0):
         data = self.camera.get_image_buffer()
         bpl = self.camera.bytes_per_line
         format = QImage.Format_RGB32
         image = QImage(data, self.camera.width, self.camera.height, bpl,
                        format)
         if self.pixmapitem is None:
             self.pixmapitem = self.scene.addPixmap(
                 QPixmap.fromImage(image))
         else:
             self.pixmapitem.setPixmap(QPixmap.fromImage(image))
Exemplo n.º 37
0
class Ant():
    def __init__(self, name):
        self.picture = QPixmap()
        self.motion = AntMotion()
        self.name = name
        self.zombie = False

    def width(self):
        return self.picture.width()

    def height(self):
        return self.picture.height()
Exemplo n.º 38
0
    def setInfo( *args ):
        filePath = cmds.textField( Window_global.txf_imagePath, q=1, tx=1 )
        pixmap = QPixmap(filePath)
        
        Window_global.imgWidth = pixmap.width()
        Window_global.imgHeight = pixmap.height()
        cmds.intField( Window_global.intf_imageWidth, e=1, v=Window_global.imgWidth )
        cmds.intField( Window_global.intf_imageHeight, e=1, v=Window_global.imgHeight )
        
        planeWidth = cmds.floatField( Window_global.floatf_planeWidth, q=1, v=1 )
        planeHeight = planeWidth * float(Window_global.imgWidth) / float(Window_global.imgHeight)

        cmds.floatField( Window_global.floatf_planeHeight, e=1, v= planeHeight )
Exemplo n.º 39
0
    def load_image(self, img_path):
        """Load an image in widget from a file.

        Args:
            img_path -- Path of image file to load (str)
        """
        img_path = str(img_path)
        pixmap = QPixmap(img_path)
        self.imglabel.setPixmap(pixmap)
        self.imglabel.resize(pixmap.size())
        self.namelabel.setText(f"File: {img_path}")
        self._img_path = img_path
        self._initial_size = pixmap.size()
Exemplo n.º 40
0
    def __init__(self, dock):
        """Construct a DragDockLabel for the given dock."""
        super(DragDockLabel, self).__init__("Drag Me")

        self.dock = dock
        self.setAcceptDrops(True)
        self.setScaledContents(True)
        self.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
        self.setToolTip("Click and drag to change parent.")

        pm = QPixmap(1, 10)
        pm.fill(Qt.black)
        self.setPixmap(pm)
Exemplo n.º 41
0
	def paintEvent(self, event):
		painter = QPainter(self)

		painter.setBrush(Qt.white)
		painter.drawRect(self.rect())

		painter.translate(self.width()/2, self.height()/2)

		if self.pixReady:
			grammarPix = QPixmap("/tmp/grammar.png")
			pw = grammarPix.width()
			ph = grammarPix.height()
			painter.drawPixmap(-pw/2, -ph/2, grammarPix)
Exemplo n.º 42
0
    def __init__(self, dock):
        """Construct a DragDockLabel for the given dock."""
        super(DragDockLabel, self).__init__("Drag Me")

        self.dock = dock
        self.setAcceptDrops(True)
        self.setScaledContents(True)
        self.setAlignment(Qt.AlignHCenter | Qt.AlignTop)
        self.setToolTip("Click and drag to change parent.")

        pm = QPixmap(1, 10)
        pm.fill(Qt.black)
        self.setPixmap(pm)
Exemplo n.º 43
0
 def __init__(self, firstIcon, secondIcon, parent=None):
   super(CheckIconWidget, self).__init__(parent)
   self.setMouseTracking(True)
   self._mouse_over = False
   self._checked = False
   self._first_icon = QPixmap(firstIcon)
   self._second_icon = QPixmap(secondIcon)
   w1, w2 = self._first_icon.width(), self._second_icon.width()
   h1, h2 = self._first_icon.height(), self._second_icon.height()
   max_w = w1 if w1 > w2 else w2
   max_h = h1 if h1 > h2 else h2
   # set the size to contain both images, but they should have the same size
   self.setFixedSize(max_w, max_h)
Exemplo n.º 44
0
 def __init__(self, parent=None):
     self.hamburger = QImage(128, 128, QImage.Format_ARGB32)
     QPushButton.__init__(self, parent)
     self.svgrenderer = QSvgRenderer("icons\\hamburger.svg")
     paint = QPainter(self.hamburger)
     paint.setRenderHint(QPainter.HighQualityAntialiasing)
     paint.setRenderHint(QPainter.SmoothPixmapTransform)
     self.svgrenderer.render(paint)
     paint.end()
     pixmap = QPixmap()
     self.setIcon(QIcon(pixmap.fromImage(self.hamburger)))
     self.setStyleSheet(
         "QPushButton, QPushButton:pressed{background-color: rgba(0,0,0,0)} QPushButton:hover {background-color: rgba(255,255,255,100); border-radius: 32px} "
     )
Exemplo n.º 45
0
    def drawIconWithShadow(icon, rect, p, iconMode, radius, color, offset):
        cache = QPixmap()
        pixmapName = "icon {0} {1} {2}".format(icon.cacheKey(), iconMode, rect.height())

        if not QPixmapCache.find(pixmapName, cache):
            px = icon.pixmap(rect.size())
            cache = QPixmap(px.size() + QSize(radius * 2, radius * 2))
            cache.fill(Qt.transparent)

            cachePainter = QPainter(cache)
            if iconMode == QIcon.Disabled:
                im = px.toImage().convertToFormat(QImage.Format_ARGB32)
                for y in range(im.height()):
                    scanLine = im.scanLine(y)
                    for x in range(im.width()):
                        pixel = scanLine
                        intensity = qGray(pixel)
                        scanLine = qRgba(intensity, intensity, intensity, qAlpha(pixel))
                        scanLine += 1
                px = QPixmap.fromImage(im)

            # Draw shadow
            tmp = QImage(px.size() + QSize(radius * 2, radius * 2 + 1), QImage.Format_ARGB32_Premultiplied)
            tmp.fill(Qt.transparent)

            tmpPainter = QPainter(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_Source)
            tmpPainter.drawPixmap(QPoint(radius, radius), px)
            tmpPainter.end()

            # blur the alpha channel
            blurred = QImage(tmp.size(), QImage.Format_ARGB32_Premultiplied)
            blurred.fill(Qt.transparent)
            blurPainter = QPainter(blurred)
            # todo : blur image
            blurPainter.end()

            tmp = blurred

            # blacken the image
            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            tmpPainter.begin(tmp)
            tmpPainter.setCompositionMode(QPainter.CompositionMode_SourceIn)
            tmpPainter.fillRect(tmp.rect(), color)
            tmpPainter.end()

            # draw the blurred drop shadow...
            cachePainter.drawImage(QRect(0, 0, cache.rect().width(), cache.rect().height()), tmp)

            # Draw the actual pixmap...
            cachePainter.drawPixmap(QPoint(radius, radius) + offset, px)
            QPixmapCache.insert(pixmapName, cache)

        targetRect = cache.rect()
        targetRect.moveCenter(rect.center())
        p.drawPixmap(targetRect.topLeft() - offset, cache)
Exemplo n.º 46
0
class AntObject():
    def __init__(self, point=QPoint(0, 0)):
        self.picture = QPixmap()
        self.point = point
        self.enabled = True

    def width(self):
        return self.picture.width()

    def height(self):
        return self.picture.height()

    def __eq__(self, other):
        return self.point == other.point and self.width() == other.width() and self.height() == other.height()
Exemplo n.º 47
0
 def paint(self, painter, option, index):
   if index.column() != 0: # not the image column
     super(ScrapeItemDelegate, self).paint(painter, option, index)
   else:
     images = index.data(role=Qt.DisplayRole)
     if images:
       # yep. Make an image appear here
       image_data = images[0] # assuming a single image for now
       pixmap = QPixmap(image_data.get("path"))
       pixmap = pixmap.scaled(self.max_cell_res[0], self.max_cell_res[1], Qt.IgnoreAspectRatio)
       cell_rect = option.rect
       painter.drawPixmap(cell_rect.x(), cell_rect.y(), pixmap) 
     else:
       super(ScrapeItemDelegate, self).paint(painter, option, index)
Exemplo n.º 48
0
 def grabImg(self):
     self.idFrame += 1
     wid = QApplication.desktop().winId()
     QPixmap.grabWindow(wid, self.screenArea.x, self.screenArea.y,
                        self.screenArea.w,
                        self.screenArea.h).save(self.buffer, 'png')
     strio = StringIO.StringIO()
     strio.write(self.buffer.data())
     self.buffer.seek(0)
     strio.seek(0)
     pix = np.array(Image.open(strio))
     pix = cv2.resize(pix, (0, 0), fx=self.scale, fy=self.scale)
     real_color = cv2.cvtColor(pix, cv2.COLOR_BGR2RGB)
     return real_color
Exemplo n.º 49
0
class CheckIconWidget(QWidget):
  """An icon widget that operates as a checkbox"""
  NORMAL_OPACITY = .5
  HOVER_OPACITY = .85
  FIRST_ICON = 1000
  SECOND_ICON = 2000
  
  checked = Signal(bool)
  
  def __init__(self, firstIcon, secondIcon, parent=None):
    super(CheckIconWidget, self).__init__(parent)
    self.setMouseTracking(True)
    self._mouse_over = False
    self._checked = False
    self._first_icon = QPixmap(firstIcon)
    self._second_icon = QPixmap(secondIcon)
    w1, w2 = self._first_icon.width(), self._second_icon.width()
    h1, h2 = self._first_icon.height(), self._second_icon.height()
    max_w = w1 if w1 > w2 else w2
    max_h = h1 if h1 > h2 else h2
    # set the size to contain both images, but they should have the same size
    self.setFixedSize(max_w, max_h)
    
  def mousePressEvent(self, mpe):
    self._checked = not self._checked
    self.checked.emit(self._checked)
    self.repaint()
    
  def mouseMoveEvent(self, mme):
    self._mouse_over = True
    self.setCursor(Qt.CursorShape.PointingHandCursor)
    self.repaint()
    
  def leaveEvent(self, le):
    self._mouse_over = False
    self.repaint()
    
  def paintEvent(self, pe):
    painter = QPainter(self)
    if self._checked:
      pixmap = self._second_icon
    else:
      pixmap = self._first_icon
      
    if self._mouse_over:
      painter.setOpacity(self.HOVER_OPACITY)
    else:
      painter.setOpacity(self.NORMAL_OPACITY)  
    painter.drawPixmap(0, 0, pixmap)
Exemplo n.º 50
0
    def testWithKey(self):
        pm1 = QPixmap()
        ok = QPixmapCache.find(QPixmapCache.Key(), pm1)
        self.assertFalse(ok)

        self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None)

        pm2 = QPixmap()
        key = QPixmapCache.insert(pm2)

        pm3 = QPixmap()
        ok = QPixmapCache.find(key, pm3)
        self.assertTrue(ok)

        self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits())
Exemplo n.º 51
0
 def _put(self, res):
     """Put resource on widget"""
     label = QLabel()
     if "image" in res.mime:
         pixmap = QPixmap(res.file_path).scaledToWidth(100)
         label.setPixmap(pixmap)
         label.setMask(pixmap.mask())
     else:
         label.setText(res.file_name)
     label.mouseReleaseEvent = partial(self.click, res)
     self.widget.widget().layout().addWidget(label)
     self.widget.show()
     self._resource_labels[res] = label
     self._res_hash[res.hash] = res
     res.in_content = False
Exemplo n.º 52
0
def choose_color():
    # Select color
    color = QColorDialog().getColor()
    
    # Report about result of selection in QMessageBox dialog
    msgbox = QMessageBox()
    if color.isValid():
        # Create a memory image 50x50 filled with selected color to display
        # as a icon in the msgbox dialog
        pixmap = QPixmap(50, 50)
        pixmap.fill(color)
        msgbox.setWindowTitle(u'Selected Color')
        msgbox.setIconPixmap(pixmap)
    else:
        msgbox.setWindowTitle(u'No Color was Selected')
    msgbox.exec_()
Exemplo n.º 53
0
    def _set_pixmap_from_camera(self):
        bpl = self.camera.bytes_per_line
        arr = self.camera.image_array()

        if self.camera.color_mode == 'RGB32':
            buf = self.camera.image_buffer()  # TODO: Fix to use image_array() instead
            format = QImage.Format_RGB32
            image = QImage(buf, self.camera.width, self.camera.height, bpl, format)
        elif self.camera.color_mode == 'mono8':
            # TODO: Somehow need to make sure data is ordered as I'm assuming
            format = QImage.Format_Indexed8
            image = QImage(arr.data, self.camera.width, self.camera.height, bpl, format)
            self._saved_img = arr
        elif self.camera.color_mode == 'mono16':
            pil_img = scipy.misc.toimage(arr)  # Normalize values to fit in uint8
            format = QImage.Format_Indexed8
            data = pil_img.tostring()
            image = QImage(data, pil_img.size[0], pil_img.size[1], pil_img.size[0], format)
            self._saved_img = data  # Save a reference to keep Qt from crashing
        elif self.camera.color_mode==None:
            buf = self.camera.image_buffer()  # TODO: Fix to use image_array() instead
            format = QImage.Format_RGB32
            image = QImage(buf, self.camera.width, self.camera.height, bpl, format)
        else:
            raise Exception("Unsupported color mode '{}'".format(self.camera.color_mode))

        self.setPixmap(QPixmap.fromImage(image))
        pixmap_size = self.pixmap().size()
        if pixmap_size != self.size():
            self.setMinimumSize(self.pixmap().size())
Exemplo n.º 54
0
def pixmap_from_hicon(hicon):
    if not hicon: return
    screen_device = GetDC(None)
    hdc = CreateCompatibleDC(screen_device)
    ReleaseDC(None, screen_device)
    icon_info = ICONINFO()
    if not GetIconInfo(hicon, byref(icon_info)):
        raise WindowsError('call to GetIconInfo failed')
    width = icon_info.xHotspot * 2
    height = icon_info.yHotspot * 2
    bitmap_header = BITMAPINFOHEADER()
    bitmap_header.biSize = sizeof(bitmap_header)
    bitmap_header.biWidth = width
    bitmap_header.biHeight = height
    bitmap_header.biPlanes = 1
    bitmap_header.biBitCount = 32
    bitmap_header.biCompression = BI_RGB
    bitmap_header.biSizeImage = 0
    bitmap_header.biXPelsPerMeter = 0
    bitmap_header.biYPelsPerMeter = 0
    bitmap_header.biClrUsed = 0
    bitmap_header.biClrImportant = 0
    bits = c_void_p()
    win_bitmap = CreateDIBSection(hdc, byref(bitmap_header), DIB_RGB_COLORS, 
        byref(bits), None, 0);
    old_hdc = SelectObject(hdc, win_bitmap)
    DrawIconEx(hdc, 0, 0, hicon, width, height, 0, None, DI_NORMAL)
    image = image_from_hbitmap(hdc, win_bitmap, width, height)
    # do the alpha shit
    DeleteObject(icon_info.hbmMask)
    DeleteObject(icon_info.hbmColor)
    SelectObject(hdc, old_hdc)
    DeleteObject(win_bitmap)
    DeleteDC(hdc)
    return QPixmap.fromImage(image)