python界面是什么样子的图片_如何在python界面显示图片
展开全部
5261代码:
4102# show a jpeg (.jpg) image using wxPython, newer coding style
1653# two different ways to load and display are given
# tested with Python24 and wxPython25 vegaseat 24jul2005
import wx
import cStringIO
class Panel1(wx.Panel):
""" class Panel1 creates a panel with an image on it, inherits wx.Panel """
def __init__(self, parent, id):
# create the panel
wx.Panel.__init__(self, parent, id)
try:
# pick a .jpg file you have in the working folder
imageFile = 'Moo.jpg'
data = open(imageFile, "rb").read()
# convert to a data stream
stream = cStringIO.StringIO(data)
# convert to a bitmap
bmp = wx.BitmapFromImage( wx.ImageFromStream( stream ))
# show the bitmap, (5, 5) are upper left corner coordinates
wx.StaticBitmap(self, -1, bmp, (5, 5))
# alternate (simpler) way to load and display a jpg image from a file
# actually you can load .jpg .png .bmp or .gif files
jpg1 = wx.Image(imageFile, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
# bitmap upper left corner is in the position tuple (x, y) = (5, 5)
wx.StaticBitmap(self, -1, jpg1, (10 + jpg1.GetWidth(), 5), (jpg1.GetWidth(), jpg1.GetHeight()))
except IOError:
print "Image file %s not found" % imageFile
raise SystemExit
app = wx.PySimpleApp()
# create a window/frame, no parent, -1 is default ID
# increase the size of the frame for larger images
frame1 = wx.Frame(None, -1, "An image on a panel", size = (400, 300))
# call the derived class
Panel1(frame1,-1)
frame1.Show(1)
app.MainLoop()
已赞过
已踩过<
你对这个回答的评价是?
评论
收起
python界面是什么样子的图片_如何在python界面显示图片相关推荐
- python包含多个元组的元组_如何在python中将多个”列出的”元组连接成一个元组?...
在python中,关于这个问题的答案很少,如何将一个元组列表连接到一个列表中?,如何在python中合并两个元组?,如何在python中合并任意数量的元组?所有的答案都引用了元组列表,所以提供的解决方 ...
- python类的动态方法是什么_如何在python中为类动态创建类方法
如果我将一个小python程序定义为class a(): def _func(self): return "asdf" # Not sure what to resplace __ ...
- python将小时数换成分钟_如何在Python中将datetime.timedelta转换为分钟、小时?
没有用于timedelta对象的内置格式化程序,但您自己很容易做到:days, seconds = duration.days, duration.seconds hours = days * 24 ...
- python getopt参数参数自动补全_如何在Python中使用getopt / OPTARG?如果给出过多的参数(9),如何转移参数?...
How to use getopt/optarg in Python? 解决方案 This is an example of how I do it, I usually use the same b ...
- python对文件每行数据计算_如何在python中对pandas数据帧的每一行进行计算?
我是python的新手,我正在尝试将我在R中创建的函数转换为python,R函数描述如下: 从我的阅读来看,在python中实现这一点的最佳方法是使用一个for循环,该循环采用以下形式for line ...
- python列表转化为元组、集合_如何在Python中将元组列表更改为集合?
我在Python中创建了一个函数,它返回抛出2个骰子的所有可能结果的列表. 元组列表:[(1,1),(1,2),-,(6,6)].在 然后我写了一个函数来找出两个值之和为偶数的所有元素(a),另一个函 ...
- python中变量通过变量名访问_如何在python中访问给定变量的名称?
我在python编程,并需要访问我已经给一个对象的名称,以便能够将其作为一个字符串(与另一个字符串连接)传递. 我需要这样做的原因是,我使用的程序迫使我创建一个全局(在我的情况下是一个字典),我正在写 ...
- python中 n是换几行_如何在Python中用`\ n`替换通用换行符?
b'\n'在bytesPython3对象中,用替换所有"通用换行符"的最佳(最干净,最快)方法是什么? 编辑:我最终使用b'\n'.join(bytestr.splitlines( ...
- python创建长度为20的列表_如何在python中创建固定大小列表?
小编典典 (tl;博士:您问题的确切答案是numpy.empty或numpy.empty_like,但您可能不在乎,可以摆脱使用的困扰myList = [None]*10000.) 简单的方法 您可以 ...
最新文章
- 200 个工具分析机器学习十年:开源是大势,工程师是核心
- 数据派翻译组招募 | 寻找最志同道合的你!
- 往自身页面提交和别处页面提交到本页的设计小技巧
- u盘读写测试_关于闪迪u盘cz880速度测试
- PHP利用P3P实现跨域
- python对角线图_python对角线图_python – 在Seaborn Jointplot上绘制对角线(相等的线)...
- css 回到首页按钮,js+css实现回到顶部按钮(back to top)
- android 字符串替换_Android开发之旅:android架构
- json规范及转义字符
- 为何python不好找工作-为什么说Python不好找工作?原因在这里!
- phpmyadmin出现缺少mysqli扩展问题
- header元素 footer元素 hgroup元素
- C# 关于浏览器——CefSharp篇
- Latex--插入表格
- 点云配准icp算法推导
- 1、结构化、面向对象程序设计差别、类基本概念
- Pytorch中iter(dataloader)的使用
- c语言_kbhit函数怎么用,kbhit再c语言中怎么用请教
- 12.8 Font 对象
- 3d图形计算机学,计算机科学速成课 | 27 3D图形