本文整理汇总了Python中PySide.QtGui.QImage.fromData方法的典型用法代码示例。如果您正苦于以下问题:Python QImage.fromData方法的具体用法?Python QImage.fromData怎么用?Python QImage.fromData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QImage
的用法示例。
在下文中一共展示了QImage.fromData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_clipboard
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import fromData [as 别名]
def copy_clipboard(self):
from io import BytesIO
buf = BytesIO()
self.fig.savefig(buf)
QApplication.clipboard().setImage(QImage.fromData(buf.getvalue()))
buf.close()
示例2: clipboard_handler
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import fromData [as 别名]
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()
示例3: _setWallpaper
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import fromData [as 别名]
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()
示例4: takeSnapshot
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import fromData [as 别名]
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')
示例5: copy_to_clipboard
# 需要导入模块: from PySide.QtGui import QImage [as 别名]
# 或者: from PySide.QtGui.QImage import fromData [as 别名]
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()