wxPython實(shí)現(xiàn)窗口用圖片做背景
本文實(shí)例為大家分享了wxPython實(shí)現(xiàn)窗口用圖片做背景的具體代碼,供大家參考,具體內(nèi)容如下
效果圖:

實(shí)現(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)建一個(gè)按鈕 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)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Python基礎(chǔ)之?dāng)?shù)據(jù)類型詳解
python的數(shù)值類型包括整數(shù),浮點(diǎn)數(shù),復(fù)數(shù),集合,小數(shù)和分?jǐn)?shù),布爾值.它們都是python中的數(shù)值類型.如果是有過其他語言編寫經(jīng)驗(yàn)的人,一定很好奇,浮點(diǎn)數(shù)和小數(shù)的區(qū)別是什么?文中有非常詳細(xì)的介紹,需要的朋友可以參考下2021-06-06
python實(shí)現(xiàn)基本進(jìn)制轉(zhuǎn)換的方法
這篇文章主要介紹了python實(shí)現(xiàn)基本進(jìn)制轉(zhuǎn)換的方法,涉及Python數(shù)學(xué)運(yùn)算的取余與字符串操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07
python神經(jīng)網(wǎng)絡(luò)Keras實(shí)現(xiàn)LSTM及其參數(shù)量詳解
這篇文章主要為大家介紹了python神經(jīng)網(wǎng)絡(luò)Keras實(shí)現(xiàn)LSTM及其參數(shù)量詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05
一款Python工具制作的動(dòng)態(tài)條形圖(強(qiáng)烈推薦!)
有時(shí)為了方便看數(shù)據(jù)的變化情況,需要畫一個(gè)動(dòng)態(tài)圖來看整體的變化情況,下面這篇文章主要給大家介紹了一款Python工具制作的動(dòng)態(tài)條形圖的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-02-02
python輸出當(dāng)前目錄下index.html文件路徑的方法
這篇文章主要介紹了python輸出當(dāng)前目錄下index.html文件路徑的方法,涉及Python操作目錄的相關(guān)技巧,需要的朋友可以參考下2015-04-04

