資源簡(jiǎn)介
NULL
博文鏈接:https://westice.iteye.com/blog/972648

代碼片段和文件信息
#-*-?coding:utf-8?-*-
‘‘‘
Created?on?2011-3-22
@author:?123
‘‘‘
import?wx
import?random
#圖片屬性封裝
class?ImageProperty():
????checked=False#被選中狀態(tài)
????def?__init__(self):
????????randnum=-1
????def?setrandnum(selfnum):
????????self.randnum=num
????def?getrandnum(self):
????????return?self.randnum
????def?setchecked(selfchecked):
????????self.checked=checked
????def?getchecked(self):
????????return?self.checked
????#選中狀態(tài)轉(zhuǎn)變
????def?checkedshift(self):
????????if?self.checked:
???????????self.checked=False
????????else:
???????????self.checked=True
class?Myframe(wx.frame):
????gridwidth=10
????gridheight=10
????imagelist=[]#圖片對(duì)象列表
????imageProlist=[]#圖片屬性列表,代表哪一個(gè)圖片
????prevcheckedimageindex=-1#前一次選中的圖片
????checkedimageindex=-1#當(dāng)前選中的圖片
????panel=None
????def?__init__(self):
????????????wx.frame.__init__(selfNone-1“My?frame“size=(540600))
????????????self.panel=wx.Panel(self-1)
????????????self.panel.Bind(wx.EVT_MOTIONself.onmove)
????????????self.panel.Bind(wx.EVT_LEFT_DOWNself.onclickPanel)
????????????self.Bind(wx.EVT_PAINTself.OnPaint)
????????????wx.StaticText(self.panel-1“mousePos:“pos=(10534))
????????????self.posCtrl=wx.TextCtrl(self.panel-1““pos=(80530))
????????????fgs=wx.FlexGridSizer(cols=10hgap=3vgap=3)
????????????
????????????for?col?in?range(self.gridwidth):
????????????????for?row?in?range(self.gridheight):
????????????????????randnum=int(random.random()*5)
????????????????????imagename=‘image‘+str(randnum)+‘.jpg‘
????????????????????img1=wx.Image(imagenamewx.BITMAP_TYPE_ANY)
????????????????????img1=img1.Scale(5050)#2?縮小圖像
????????????????????sb1=wx.StaticBitmap(self.panel-1wx.BitmapFromImage(img1))
????????????????????sb1.Bind(wx.EVT_LEFT_DOWNself.onclickImage)
????????????????????self.imagelist.append(sb1)
????????????????????imageproperty=ImageProperty()
????????????????????imageproperty.setrandnum(randnum)
????????????????????self.imageProlist.append(imageproperty)
????????????????????fgs.Add(sb1)
????????????self.panel.SetSizerAndFit(fgs)
????????????
????????????
????def?onmove(selfevent):
????????pass
????????#pos=event.GetPosition()
????????#self.posCtrl.SetValue(“%s?%s“%(pos.xpos.y))
????def?onclickPanel(selfevent):
????????pos=event.GetPosition()
????????self.posCtrl.SetValue(“%s?%s“%(pos.xpos.y))
????
????#置空一個(gè)位置
????def?setBlank(selfimageindex):
????????#處理imagelist
????????img1=wx.Image(‘image-1.jpg‘wx.BITMAP_TYPE_ANY)
????????img1=img1.Scale(5050)#2?縮小圖像
????????self.imagelist[imageindex].SetBitmap(wx.BitmapFromImage(img1))
????????self.imageProlist[imageindex].setrandnum(-1)#空白圖片用-1表示????????
????#設(shè)置alpha
????def?setAlpha(selfimageindex):
????????#處理imagelist
????????imagename=‘image‘+str(self.imageProlist[imageindex].getrandnum())+‘.jpg‘
????????print?‘imagename:‘self.imageProlist[imageindex].getrandnum()
????????img1=wx.Image(imagenamewx.BITMAP_TYPE_ANY)
????????if?self.imageProlist[imageindex]
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件???????3873??2011-03-22?20:49??image-1.jpg
?????文件???????9802??2011-03-23?12:03??westiceWxproject.py
?????文件???????8713??2011-03-22?15:31??image0.jpg
?????文件??????10413??2011-03-22?15:31??image1.jpg
?????文件??????12744??2011-03-22?15:32??image2.jpg
?????文件??????15367??2011-03-22?15:32??image3.jpg
?????文件???????9469??2011-03-22?15:32??image4.jpg
-----------?---------??----------?-----??----
????????????????70381????????????????????7
評(píng)論
共有 條評(píng)論