QtGui.QPixmap
A QtGui.QPixmap
is one of the widgets used to work with images. It is optimized for showing images on screen. In our code example, we will use the QtGui.QPixmap
to display an image on the window.
#!/usr/bin/python
# -*- coding: utf-8 -*- """
ZetCode PyQt4 tutorial In this example, we dispay an image
on the window. author: Jan Bodnar
website: zetcode.com
last edited: September 2011
""" import sys
from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self):
super(Example, self).__init__() self.initUI() def initUI(self): hbox = QtGui.QHBoxLayout(self)
pixmap = QtGui.QPixmap("redrock.png") lbl = QtGui.QLabel(self)
lbl.setPixmap(pixmap) hbox.addWidget(lbl)
self.setLayout(hbox) self.move(300, 200)
self.setWindowTitle('Red Rock')
self.show() def main(): app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_()) if __name__ == '__main__':
main()
In our example, we display an image on the window.
pixmap = QtGui.QPixmap("redrock.png")
We create a QtGui.QPixmap
object. It takes the name of the file as a parameter.
lbl = QtGui.QLabel(self)
lbl.setPixmap(pixmap)
We put the pixmap into the QtGui.QLabel
widget.
QtGui.QPixmap的更多相关文章
- QtGui.QSlider
A QtGui.QSlider is a widget that has a simple handle. This handle can be pulled back and forth. This ...
- 怎样把ndarray转换为PyQt中的QPixmap
找不到文档,只在网上找到一些语焉不详,执行错误的代码,鼓捣了一个晚上,研(luan)究(gao)成功 def img2pixmap(self, image): Y, X = image.shape[: ...
- Pyqt 基础功能
总结Pyqt的基础知识 1. Pyqt 设置禁止最大化及禁止拖拽窗口大小 # PyQT禁止窗口最大化按钮: self.setWindowFlags(QtCore.Qt.WindowMinimizeB ...
- Python 创建本地服务器环境生成二维码
一. 需求 公司要做一个H5手机端适配页面,因技术问题所以H5是外包的,每次前端给我们源码,我们把源码传到服务器让其他人访问看是否存在bug,这个不是很麻烦吗?有人说,可以让前端在他们的服务器上先托管 ...
- Pyqt+QRcode 生成 识别 二维码
1.生成二维码 python生成二维码是件很简单的事,使用第三方库Python QRCode就可生成二维码,我用Pyqt给QRcode打个壳 一.python-qrcode介绍 python-qrco ...
- pyside 为窗口添加图片
有时我们需要添加一些图片到窗口上,下面给一个通过QLable实现的方法. 这里需要注意的是,当你启用多线程时,方法调用的setPixmap,会导致qt报出一个线程安全错误. 因此,让这个绘图工作尽量在 ...
- getWinSystemIcon
#include <QtGui/QImage>#include <QtGui/QPixmap>void getSystemIcon(const chConstStringA&a ...
- 从RAM新建QIcon对象 / Create a QIcon from binary data
一般,QIcon是通过png或ico等图标文件来初始化的,但是如果图标资源已经在内存里了,或者一个zip压缩文件内,可以通过QPixmap作为桥梁,转换为图标. zf = zipfile.ZipFil ...
- Pyqt 获取windows系统中已安装软件列表
开始之前的基础知识 1. 获取软件列表 在Python的标准库中,_winreg可以操作Windows的注册表.获取已经安装的软件列表一般是读去windows的注册表: SOFTWARE\Micros ...
随机推荐
- 记一次初步Linux提权
前言. 提权这么久了 还是头一次提下Linux的服务器... 由于之前一直钻研的win服务器 要不是前些日子爆出来Struts2-045漏洞 估计还没时间接触Linux提权.... 正文. st2 ...
- NOIP 解题有感
算法方面: 在搜索问题上,包括贪心等没有固定算法的题目,还有输出格式(包括输入格式)特别容易出错.这也是解题选手的弱点. 1.做搜索题把步骤先用文字写下来,再转换成代码,以避免敲代码时疏漏某个条件. ...
- SpringBoot返回结果如果为null或空值不显示处理方法
第一种方法:自定义消息转换器 @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter{ // /** // * ...
- bzoj 3298: [USACO 2011Open]cow checkers -- 数学
3298: [USACO 2011Open]cow checkers Time Limit: 10 Sec Memory Limit: 128 MB Description 一天,Besssie准备 ...
- Failed to read auto-increment value from storage engine错误的处理方法
在进行数据的插入时,系统提示Failed to read auto-increment value from storage engine(从存储引擎读取自增字段失败)错误,经查阅资料,解决方法如下: ...
- linux基础命令学习(十二)yum命令
主要功能是更方便的添加/删除/更新RPM包. 它能自动解决包的倚赖性问题. 它能便于管理大量系统的更新问题 yum list|more 列出所有包文件,可搭配grep查 ...
- CentOS 6.9搭建的网关服务器不经过静态路由表的问题解决(没有开启路由转发功能)
场景: 1.使用CentOS 6.9搭建的网关服务器,下面的机器都设置用这个网关,搭建参考:http://www.cnblogs.com/EasonJim/p/8289618.html 2.配置了静态 ...
- eclipse.ini 文件使用说明
http://wiki.eclipse.org/Eclipse.ini Overview Eclipse startup is controlled by the options in $ECLIPS ...
- lwIP Memory Management
http://lwip.wikia.com/wiki/Lwipopts.h Memory management (RAM usage) /** * MEM_LIBC_MALLOC==1: Use ma ...
- Spring工具类ToStringBuilder用法简介
比如说我们需要打印某个方法的User参数对象 package test; /** * * @author zhengtian * @time 2012-6-28 */ public class Use ...