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])
  • 相关阅读:
    vim 编辑器
    用得到到的超方便软件
    关于 lua table表
    python 写入文件形式
    ifconfig中lo、eth0、br0、wlan0接口
    CPU:chip、core 和 processor 的关系
    lua 匹配空白符
    排序,查找(借鉴某大神的想法)
    sublime 快捷键
    获取进程的名称
  • 原文地址:https://www.cnblogs.com/CGAlpha/p/6906696.html
Copyright © 2011-2022 走看看