• 大小: 61KB
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2021-06-17
  • 语言: Python
  • 标签: 源码  工具  

资源简介

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#被选中状态
    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
    #选中状态转变
    def checkedshift(self):
        if self.checked:
           self.checked=False
        else:
           self.checked=True


class Myframe(wx.frame):
    gridwidth=10
    gridheight=10
    imagelist=[]#图片对象列表
    imageProlist=[]#图片属性列表,代表哪一个图片
    prevcheckedimageindex=-1#前一次选中的图片
    checkedimageindex=-1#当前选中的图片
    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))
    
    #置空一个位置
    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表示        
    #设置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]

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       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


评论

共有 条评论