Пример #1
0
    def from_hash(cls, hash):
        u = User(hash['identifier'], hash['name'])
        u.image = QImage.fromData(QByteArray(
            hash['picture_bytes'].data)).scaledToHeight(128)
        #u.image = None
        return u

        f = open(hash['picture_bytes'], "rb")
        bytes = f.read(-1)
        f.close()
        u.image = QImage.fromData(QByteArray(bytes)).scaledToHeight(256)

        return u
Пример #2
0
    def copy_clipboard(self):
        from io import BytesIO

        buf = BytesIO()
        self.fig.savefig(buf)
        QApplication.clipboard().setImage(QImage.fromData(buf.getvalue()))
        buf.close()
Пример #3
0
    def copy_clipboard(self):
        from io import BytesIO

        buf = BytesIO()
        self.fig.savefig(buf)
        QApplication.clipboard().setImage(QImage.fromData(buf.getvalue()))
        buf.close()
Пример #4
0
    def image(self):
        if self._image_as_pixmap is None and self.picture_data:
            # Caution ! QImage and stuff work only if QApplication has been initialized !
            image = QImage.fromData(QByteArray(self.picture_data))
            self._image_as_pixmap = QPixmap.fromImage(image.convertToFormat(QImage.Format_RGB16, Qt.MonoOnly).scaledToHeight(128))

        return self._image_as_pixmap
Пример #5
0
 def clipboard_handler(event):
     if event.key == 'ctrl+c':
         # store the image in a buffer using savefig(), this has the
         # advantage of applying all the default savefig parameters
         # such as background color; those would be ignored if you simply
         # grab the canvas using Qt
         buf = io.BytesIO()
         fig.savefig(buf)
         QApplication.clipboard().setImage(QImage.fromData(buf.getvalue()))
         buf.close()
Пример #6
0
 def clipboard_handler(event):
     if event.key == 'ctrl+c':
         # store the image in a buffer using savefig(), this has the
         # advantage of applying all the default savefig parameters
         # such as background color; those would be ignored if you simply
         # grab the canvas using Qt
         buf = io.BytesIO()
         fig.savefig(buf)
         QApplication.clipboard().setImage(QImage.fromData(buf.getvalue()))
         buf.close()
Пример #7
0
    def new_picture(self):
        dialog = QFileDialog()
        if (dialog.exec_()):
            filename = dialog.selectedFiles()[0]
            # print "ok {}".format(filename)

            f = open(filename,"rb")
            bytes = f.read(-1)
            f.close()

            image = QImage.fromData(QByteArray(bytes))

            if image:
                # save as buffer(bytes)

                pixmap = QPixmap.fromImage(image.convertToFormat(QImage.Format_RGB16, Qt.MonoOnly).scaledToHeight(128))
                self.set_pixmap_as_icon(pixmap)
Пример #8
0
    def _setWallpaper(self, url, offset, width):
        inStream = urllib2.urlopen(url)
        img = QImage.fromData(inStream.read())
        img = img.scaledToHeight(854,Qt.SmoothTransformation)
        #offset = int(img.width() / 2) - 240
        print 'offset:', offset, 'img.width', img.width(), 'width', width
        img = img.copy(offset, 0, 480, 854)
        img.save(WALLPATH)

        #Set in gconf
        import gconf
        gclient = gconf.client_get_default()
        gclient.set_string(GCONFKEY, '')
        gclient.set_string(GCONFKEY, \
                           WALLPATH)
        #Emit done signal
        self._set_running(False)
        self.done.emit()
Пример #9
0
 def takeSnapshot(self, path):
     '''
     screen capture in png format
     :param path: saved file path
     :return: None
     '''
     p1 = self.cmd.popen(['screencap', '-p'], stdout=PIPE)
     p = Popen(['perl', '-pe', 's/\x0D\x0D\x0A/\x0A/g'], stdin=p1.stdout, stdout=PIPE)
     out, error = p.communicate()
     ba = QByteArray.fromRawData(out)
     img = QImage.fromData(ba, 'PNG')
     orient = self.getCurrDisplay()['orientation']
     if orient == 1:
         img = img.transformed(QMatrix().rotate(-90))
     elif orient == 2:
         img = img.transformed(QMatrix().rotate(-180))
     elif orient == 3:
         img = img.transformed(QMatrix().rotate(-270))
     img.save(path, 'PNG')
Пример #10
0
 def takeSnapshot(self, path):
     '''
     screen capture in png format
     :param path: saved file path
     :return: None
     '''
     p1 = self.cmd.popen(['screencap', '-p'], stdout=PIPE)
     p = Popen(['perl', '-pe', 's/\x0D\x0D\x0A/\x0A/g'],
               stdin=p1.stdout,
               stdout=PIPE)
     out, error = p.communicate()
     ba = QByteArray.fromRawData(out)
     img = QImage.fromData(ba, 'PNG')
     orient = self.getCurrDisplay()['orientation']
     if orient == 1:
         img = img.transformed(QMatrix().rotate(-90))
     elif orient == 2:
         img = img.transformed(QMatrix().rotate(-180))
     elif orient == 3:
         img = img.transformed(QMatrix().rotate(-270))
     img.save(path, 'PNG')
Пример #11
0
import format_cards
import cards_output
from PySide.QtCore import QByteArray, QThread, Signal, Qt
from PySide.QtGui import QImage, QApplication, QClipboard, QTextEdit, QMainWindow, QPixmap, QIcon, QHBoxLayout, \
    QVBoxLayout, QLabel, QComboBox, QPushButton, QFont, QSpinBox, QTextOption, QFrame, QWidget, QSplashScreen
import sys
import os
import ctypes
from time import sleep
from key_format import formatDict
from splash import *
from icon import *

# Convert binary image strings to usable images
baSplash = QByteArray.fromBase64(splashString)
splashByteArray = QImage.fromData(baSplash, 'PNG')
baIcon = QByteArray.fromBase64(iconString)
iconByteArray = QImage.fromData(baIcon, 'PNG')

app = QApplication(sys.argv)  # Define application

# Set some global variables
directory = os.getcwd()
clip = QClipboard()
privateKeyFormats = list(formatDict.keys())
privateKeyFormats.sort(reverse=True)
ethDonationAddress = '0x50Adc7CfDB7b52D26E3820740D0A15f614098A35'
btcDonationAddress = '1LPZ1mfSftiTcEvAfMrHEq1NhjyBVdeZLj'

# Application Information
__appname__ = 'Brain Cypher'
Пример #12
0
 def copy_to_clipboard(self):
     img_buffer = io.BytesIO()
     self.figure.savefig(img_buffer)
     QApplication.clipboard().setImage(QImage.fromData(img_buffer.getvalue()))
     img_buffer.close()