Python win32api提取exe图标icon
转载地址: http://blog.csdn.net/gumanren/article/details/6129416
代码如下:
# -*- coding: utf-8 -*-
import sys
import win32ui
import win32gui
from PyQt4 import QtCore
from PyQt4 import QtGui
class testWindow(QtGui.QMainWindow):
def __init__(self):
super(testWindow, self).__init__()
self.setGeometry(180.0, 130.0, 280.0, 200.0)
self.setMouseTracking(True)
large, small = win32gui.ExtractIconEx(r"netbeans.exe", 0)
win32gui.DestroyIcon(small[0])
self.pixmap = QtGui.QPixmap.fromWinHBITMAP(self.bitmapFromHIcon(large[0]), 2) self.pixmap.save("a.ico","ico") def bitmapFromHIcon(self, hIcon):
hdc = win32ui.CreateDCFromHandle(win32gui.GetDC(0))
hbmp = win32ui.CreateBitmap()
hbmp.CreateCompatibleBitmap(hdc, 32, 32)
hdc = hdc.CreateCompatibleDC()
hdc.SelectObject(hbmp)
hdc.DrawIcon((0, 0), hIcon)
hdc.DeleteDC()
return hbmp.GetHandle()
# paintevent事件
def paintEvent(self, event):
# palette 调色板多个pix显示,
painter = QtGui.QPainter()
palette = QtGui.QPalette()
palette.setBrush(self.backgroundRole(), QtGui.QBrush(QtGui.QPixmap(self.pixmap))) # 设置背景图片
self.setPalette(palette)
#painter绘图类只显示一个
#painter.begin(self)
#painter.setRenderHint(QtGui.QPainter.Antialiasing)
#painter.setPen(QtCore.Qt.NoPen)
#painter.setBrush(QtGui.QBrush(QtGui.QColor(255.0, 255.0, 255.0, 255.0), QtCore.Qt.SolidPattern))
#painter.drawRect(QtCore.QRect(0.0, 0.0, 280.0, 400.0))
#painter.drawPixmap(QtCore.QRect(0.0, 0.0, 32.0, 32.0), self.pixmap)
#painter.end()
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mainWindow = testWindow()
mainWindow.show()
app.exec_()
显示效果:
Python win32api提取exe图标icon的更多相关文章
- Delphi提取EXE,DLL文件图标
//uses ShellAPIprocedure TForm1.Button1Click(Sender: TObject);var IconIndex:Word; h:hICON;begin Icon ...
- Python 获取 exe 的 icon 并且保存
Python 获取 exe 的 icon 并且保存 参考链接:https://mail.python.org/pipermail/python-win32/2009-April/009078.html ...
- delphi编写提取exe文件的ICO图标
http://www.duote.com/tech/4/11797.html delphi编写提取exe文件的ICO图标 7.0分 出处:天下网吧 时间:2011-08-05 人气:2390 核心提示 ...
- [工具-001]C++更换EXE的ICON图标
我们都知道每个可执行文件EXE都会有自己的图标,它可以在项目生成的时候进行指认,但是有时候我们会遇到两种情况:1.没有源代码,2.我们的项目很多,一个个进行更换很耗时.本人就是因为接到这么一个需求,要 ...
- 关于python打包成exe的一点经验之谈
我经常用python写些脚本什么的,有时候脚本写完以后,每次运行都得在IDE打开在运行,很麻烦,所以经常将python编译成exe.SO...有了一点经验,在这和大家分享一下. python ...
- python:打包成exe程序
1.需要安装 py2exe 2.示例代码: #exetest.py #创建一个gui界面,只用一个标签和按钮,无功能 from Tkinter import * win = Tk() label = ...
- 使用pyinstaller将Python打包为exe文件
当我们完成一个Python项目或一个程序时,希望将Python的py文件打包成在Windows系统下直接可以运行的exe程序,那么pyInstaller就是一个很好的选择.pyInstaller可以将 ...
- Python打包成exe可执行文件
Python打包成exe可执行文件 安装pyinstaller pyinstaller打包机制 Pyinstaller打包exe 总结命令 可能会碰到的一些常见问题 我们开发的脚本一般都会用到一些第三 ...
- 强行替换exe图标的方法
说句实话,要想用普通的方法来替换图标,不是完全不可行,当然也不是完全可行.这个看似简单的问题并不是想象中那么容易解决,为什么有人修改exe的图标总是失败,其实他忽视了exe和图标的复杂性,用简单的方法 ...
随机推荐
- POJ 1273 网络流(最大流)模板
http://poj.org/problem?id=1273 这道题很值得反思,弄了一下午,交上去先是一直编译错误,而在本地运行没有问题, 原因可能是oj的编译器版本老旧不支持这样的写法 G[from ...
- postgresql数据库实用操作
查模型的列名: select column_name from information_schema.columns where table_name= 'your_table'; 应用: 1. 给 ...
- http statusCode(状态码)
转自:1) http://specs.openstack.org/openstack/keystone-specs/api/v3/identity-api-v3.html#unauthorized ...
- 如何用 Robotframework 来编写优秀的测试用例
介绍 这篇文档将会是一篇在「高层面」的怎么用 Robotframework 来编写优秀测试用例的原则.至于如何使用 Robotframework 来与您的待测试系统相作用这样的细节讨论是不包含在这篇文 ...
- php优化
2015年12月14日 21:20:29 之前写过两篇文章: xdebug配置 xdebug trace 结果分析 第二篇里边有两个很耗时间和内存的线条: 第一个斜坡: 从mysql里读取数据后, 用 ...
- linux (RHEL) 添加和删除用户
linux添加新用户使用 useradd -----create a new user or update default new user information 删除用户使用userdel -- ...
- [转载]Linux命令笔记
*以下内容均来自于网络转载,感谢原作者分享 <对Linux新手非常有用的20个命令> 传送门 英文原文为“Switching From Windows to Nix or a Newbie ...
- NEFU 84 五指山 (扩展欧几里得)
五指山 Problem:84 Time Limit:1000ms Memory Limit:65536K Description 西游记中孙吾空大闹天宫,如来佛祖前来降伏他,说道:"我与你打 ...
- 在Win7下使用sphinx-build建立开源软件文档
最近想看看odoo的使用文档,在线看不方便,而且还没有提供离线文档下载,由于是开源项目,此项目托管在Github上,于是就有了想通过Github把文档git下来,可是git下来的文档是.rst文件,无 ...
- IOS - Passbook
1. 什么是Passbook Passbook是苹果公司于北京时间2012年6月12日上午,在全球开发者大会(WWDC)上宣布了iOS 6系统将提供操作一个全新的应用——Passbook 这是一款可以 ...