zoukankan      html  css  js  c++  java
  • python new kill callback

     1 # coding=utf-8
     2 '''
     3     Created  by Alpha on 2017-05-25.
     4     Copyright (c) 2018 Alpha.All rights reserved.
     5 '''
     6 try:
     7     from PyQt4 import QtGui, QtCore
     8     from PyQt4.QtCore import pyqtSignal as pyqtSignal
     9     from PyQt4.QtCore import pyqtSlot as pyqtSlot
    10 except:
    11     pass
    12 import os,sys
    13 import math
    14 #usage first
    15 class myLabel(QtGui.QLabel):
    16     Clicked = pyqtSignal(str)
    17     def __init__(self,parent=None):
    18         super(myLabel, self).__init__(parent)
    19         self.textStr = ''
    20     def mousePressEvent(self, e):
    21         self.Clicked.emit(self.textStr)
    22 
    23 class myTest(QtGui.QWidget):
    24     def __init__(self,parent=None):
    25         super(myTest, self).__init__(parent)
    26 
    27         self.imgPath = []
    28         self.callbackList = []
    29         self.imgLabels = []
    30 
    31         self.grideLayout = QtGui.QGridLayout()
    32         self.setLayout(self.grideLayout)
    33 
    34     def loadImg(self,callback,*args):
    35         self.callbackList.append(callback)
    36         if not os.path.isdir(args):
    37             return False
    38         dirs = os.listdir(args)
    39         for file in dirs:
    40             imgLabel = myLabel()
    41             self.imgPath.append(file)
    42             self.imgLabels.append(imgLabel)
    43             indexImg = dirs.index(file)
    44             imgLabel.Clicked.connect(self.callbackList[indexImg])
  • 相关阅读:
    杭电 1548 A strange lift(广搜)
    JAVA数组的定义及用法
    WPF之Binding深入探讨
    FBReaderJ源代码编译配置
    【剑指offer】合并两有序单链表
    对HGE游戏引擎的一次封装
    WAV文件格式分析
    Ubuntu9.04更新源
    内核及内核模块
    java实现第七届蓝桥杯愤怒小鸟
  • 原文地址:https://www.cnblogs.com/CGAlpha/p/6906696.html
Copyright © 2011-2022 走看看