wxPython實現(xiàn)窗口用圖片做背景
更新時間:2018年04月25日 08:35:13 作者:烈風
這篇文章主要為大家詳細介紹了wxPython實現(xiàn)窗口用圖片做背景,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了wxPython實現(xiàn)窗口用圖片做背景的具體代碼,供大家參考,具體內(nèi)容如下
效果圖:

實現(xiàn)代碼:
#!/usr/bin/env python # -*- encoding:utf-8 -*- import wx class MyPanel(wx.Panel): def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) try: image_file = 'image.jpg' to_bmp_image = wx.Image(image_file, wx.BITMAP_TYPE_ANY).ConvertToBitmap() self.bitmap = wx.StaticBitmap(self, -1, to_bmp_image, (0, 0)) image_width = to_bmp_image.GetWidth() image_height = to_bmp_image.GetHeight() set_title = '%s %d x %d' % (image_file, to_bmp_image.GetWidth(), to_bmp_image.GetHeight()) parent.SetTitle(set_title) except IOError: print 'Image file %s not found' % image_file raise SystemExit #創(chuàng)建一個按鈕 self.button = wx.Button(self.bitmap, -1, label='Test', pos=(10,10)) if __name__ == '__main__': app = wx.PySimpleApp() frame = wx.Frame(None, -1, 'Image', size=(300,300)) my_panel = MyPanel(frame, -1) frame.Show() app.MainLoop()
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
python實現(xiàn)基本進制轉(zhuǎn)換的方法
這篇文章主要介紹了python實現(xiàn)基本進制轉(zhuǎn)換的方法,涉及Python數(shù)學運算的取余與字符串操作技巧,具有一定參考借鑒價值,需要的朋友可以參考下2015-07-07
python神經(jīng)網(wǎng)絡Keras實現(xiàn)LSTM及其參數(shù)量詳解
這篇文章主要為大家介紹了python神經(jīng)網(wǎng)絡Keras實現(xiàn)LSTM及其參數(shù)量詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-05-05
一款Python工具制作的動態(tài)條形圖(強烈推薦!)
有時為了方便看數(shù)據(jù)的變化情況,需要畫一個動態(tài)圖來看整體的變化情況,下面這篇文章主要給大家介紹了一款Python工具制作的動態(tài)條形圖的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-02-02
python輸出當前目錄下index.html文件路徑的方法
這篇文章主要介紹了python輸出當前目錄下index.html文件路徑的方法,涉及Python操作目錄的相關技巧,需要的朋友可以參考下2015-04-04

