python+pyqt实现12306图片验证效果
2017-10-25 17:03
961 查看
本文实例为大家分享了python实现12306图片验证效果的具体代码,供大家参考,具体内容如下
思路:在鼠标点击位置加一个按钮,然后再按钮中的点击事件中写一个关闭事件.
#coding:utf-8 from PyQt4.QtGui import * from PyQt4.QtCore import * from push_button import * from PIL import Image class Yanzheng(QWidget): def __init__(self,parent=None): super(Yanzheng,self).__init__(parent) self.m_start_point=0 #x坐标 self.m_end_point=0 #y坐标 self.coordinate=[] self.codeimage="./img/code.png" self.connect(self,SIGNAL("addlable"),self.addpic) self.main_layout=QFormLayout() self.setLayout(self.main_layout) self.resize(293,190) self.pixmap=QPixmap("./img/cur.png") def addpic(self): print self.m_start_point,self.m_end_point xpoint=self.m_start_point ypoint=self.m_end_point-28 codepng2 = PushButton(self) codepng2.loadPixmapreal('./img/cur.png') codepng2.setGeometry(self.m_start_point,self.m_end_point,30,30) codepng2.show() #self.emit(SIGNAL("dellabel"),self.codepng2) self.coordinate.append("%s,%s" %(xpoint,ypoint)) self.connect(codepng2,SIGNAL("clicked()"),lambda:self.dellabel(codepng2,xpoint,ypoint)) #self.update() #删除标记 def dellabel(self,q,x,y): print x,y self.coordinate.remove("%s,%s" %(x,y)) q.close() def mousePressEvent(self,event): if (event.type()==QEvent.MouseButtonPress): self.m_start_point = event.pos().x()-12 self.m_end_point= event.pos().y()-12 self.emit(SIGNAL("addlable")) def paintEvent(self, event): p = QPainter(self) p.drawPixmap(0,0,QPixmap(self.codeimage)) if __name__=='__main__': import sys app=QApplication(sys.argv) inputurl=Yanzheng() inputurl.show() sys.exit(app.exec_())
效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
您可能感兴趣的文章:
相关文章推荐
- python+pyqt实现12306图片验证效果
- Python PyQt4实现QQ的抽屉效果
- Python基于pygame实现图片代替鼠标移动效果
- Python3实现的画图及加载图片动画效果示例
- python实现12306验证和登录
- Python tkinter实现的图片移动碰撞动画效果【附源码下载】
- python实现批量按比例缩放图片效果
- 基于jquery实现的上传图片及图片大小验证、图片预览效果代码
- 纯代码系列:Python实现验证码图片(PIL库经典用法用法,爬虫12306思路)
- pyqt实现窗口边框阴影效果(python)
- python实现12306验证和登录
- Python实现图片滑动式验证识别方法
- 字符型图片验证码识别完整过程及Python实现
- python画图和加载图片以及实现动画效果
- Python基于pygame实现图片代替鼠标移动效果
- jquery实现上传图片及图片大小验证、图片预览效果代码(借荐,谢谢原作者)
- 字符型图片验证码识别完整过程及Python实现
- 基于jquery实现的上传图片及图片大小验证、图片预览效果代码
- python实现基于两张图片生成圆角图标效果的方法
- jquery实现上传图片及图片大小验证、图片预览效果代码