码迷,mamicode.com
首页 > 编程语言 > 详细

wxPython 显示一张图片

时间:2014-06-28 18:35:24      阅读:829      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   get   width   os   

#!/usr/bin/env python   
"""Hello, wxPython! program."""
import wx    
 
class Frame(wx.Frame):
    """Frame class that displays an image."""
    def __init__(self, image, parent=None, id=-1,   
                 pos=wx.DefaultPosition, 
                 title=Hello, wxPython!):
        """Create a Frame instance and display image."""

        temp = image.ConvertToBitmap()                           
        size = temp.GetWidth(), temp.GetHeight()                
        wx.Frame.__init__(self, parent, id, title, pos, size)   
        self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)     
 
class App(wx.App):
    """Application class."""
    def OnInit(self):
        image = wx.Image(1.jpg, wx.BITMAP_TYPE_JPEG)
        self.frame = Frame(image)
        self.frame.Show() 
        self.SetTopWindow(self.frame) 
        return True 
def main():
    app = App()      
    app.MainLoop()

if __name__ == __main__:
     main()

 

wxPython 显示一张图片,布布扣,bubuko.com

wxPython 显示一张图片

标签:style   blog   color   get   width   os   

原文地址:http://www.cnblogs.com/yufenghou/p/3797195.html

(0)
(1)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!