当前位置:脚本大全 > > 正文

抖音上很火的表白程序链接(我喜欢你 抖音表白程序python版)

时间:2021-10-21 07:57:37类别:脚本大全

抖音上很火的表白程序链接

我喜欢你 抖音表白程序python版

本文实例为大家分享了python抖音表白神器,供大家参考,具体内容如下

  • ?
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • # -*- coding: utf-8 -*-
  •  
  •  
  • import sys
  • from pyqt5 import qtwidgets
  • from pyqt5.qtgui import qfont,qicon#qtwidgets不包含qfont必须调用qtgui
  • from pyqt5 import qtgui,qtcore
  • import random
  •  
  • class messagebox(qtwidgets.qwidget):#继承自父类qtwidgets.qwidget
  •   closeallowed=0
  •   def __init__(self,parent = none):#parent = none代表此qwidget属于最上层的窗口,也就是mainwindows.
  •     qtwidgets.qwidget.__init__(self)#因为继承关系,要对父类初始化
  • #通过super初始化父类,__init__()函数无self,若直接qtwidgets.qwidget.__init__(self),括号里是有self的
  •     self.setgeometry(300, 300, 800,800) # setgeometry()方法完成两个功能--设置窗口在屏幕上的位置和设置窗口本身的大小。它的前两个参数是窗口在屏幕上的x和y坐标。后两个参数是窗口本身的宽和高
  •     #self.resize(1000, 500) # 设置窗体大小,本行可有可无。
  •     self.center()#自定义一个居中的函数
  •     self.setfixedsize(self.width(),self.height());#pyqt禁止调整窗口大小和窗口最大化按钮
  •     #self.setwindowflags(qtcore.qt.windowminimizebuttonhint)#pyqt禁止窗口最大化按钮和关闭按钮
  •     self.setwindowtitle(u'表白神器-powered by 遂越净郝') # 仅仅设置窗体标题,不设置位置。
  •     self.setwindowicon(qicon('rose.png')) # 调用qicon构造函数时,我们需要提供要显示的图标的路径(相对或绝对路径)。同时注意:使用qicon类型必须导入此模块from pyqt5.qtgui import qicon
  •     self.settooltip(u'知乎搜索<b>遂越净郝</b>获取源码')#调用settooltip()方法,该方法接受富文本格式的参数,css之类。
  •     qtwidgets.qtooltip.setfont(qfont('华文楷体', 10))#设置字体以及字体大小
  •     self.label1 = qtwidgets.qlabel(u'<b>小姐姐,观察你很久了!</b>', self) # 建立一个标签
  •     self.label1.move(150, 40) # 使此标签移动到这个部件(260,40)的位置
  •     self.label1.setfont(qfont("timers", 20));#设置字体与字体大小
  •     self.label2= qtwidgets.qlabel(u'<b>做我女朋友好不好?</b>', self) # 建立一个标签
  •     self.label2.move(150, 100) # 使此标签移动到这个部件(260,100)的位置
  •     self.label2.setfont(qfont("timers", 20));#设置字体与字体大小
  •  
  •     #qt中提供的调色板qpalette类就是专门用于管理控件的外观显示。qpalette类相当于对话框或控件的调色板,管理着控件和窗体的所有颜色。
  •     #每个窗体和控件都包含一个qpalette对象,在显示时,对其做相应的设置即可
  •     self.window_pale = qtgui.qpalette()#实例化qpalette类
  •     self.window_pale.setbrush(self.backgroundrole(), qtgui.qbrush(qtgui.qpixmap("biu.jpg")))#打开图片
  •     self.setpalette(self.window_pale)#应用背景色
  •     # setstylesheet来设置图形界面的外观
  •  
  •     self.buttonok = qtwidgets.qpushbutton(u'同意',self) # 因为需要增加按钮,所以我们引入了qpushbutton类,该按钮是qpushbutton类的一个实例。构造函数的第一个参数是按钮的标签。第二个参数是父窗口小部件。父窗口小部件是示例窗口小部件,它是通过qwidget继承的
  •     self.buttonok.setfocuspolicy(qtcore.qt.nofocus)#按钮无焦点
  •     # qt::tabfocus 0x1 接受tab键焦点
  •     # qt::clickfocus 0x2 接受鼠标单击做焦点
  •     # qt::strongfocus tabfocus | clickfocus | 0x8 接受tab键和鼠标单击做焦点
  •     # qt::wheelfocus strongfocus | 0x4 滑轮作为焦点选中事件
  •     # qt::nofocus 0 不接受焦点
  •     self.buttonok.move(50, 700) # move()方法来指定部件的放置坐标,坐标的顶点就是窗口的左上角
  •     self.buttonok.clicked.connect(self.showdialogok)
  •  
  •     self.buttone = qtwidgets.qpushbutton(u'考虑考虑',self) # 因为需要增加按钮,所以我们引入了qpushbutton类,该按钮是qpushbutton类的一个实例。构造函数的第一个参数是按钮的标签。第二个参数是父窗口小部件。父窗口小部件是示例窗口小部件,它是通过qwidget继承的
  •     self.buttone.setfocuspolicy(qtcore.qt.nofocus) # 按钮无焦点
  •     # qt::tabfocus 0x1 接受tab键焦点
  •     # qt::clickfocus 0x2 接受鼠标单击做焦点
  •     # qt::strongfocus tabfocus | clickfocus | 0x8 接受tab键和鼠标单击做焦点
  •     # qt::wheelfocus strongfocus | 0x4 滑轮作为焦点选中事件
  •     # qt::nofocus 0 不接受焦点
  •     self.buttone.move(330, 700) # move()方法来指定部件的放置坐标,坐标的顶点就是窗口的左上角
  •     self.buttone.clicked.connect(self.showdialogee)
  •  
  •     self.buttonno = qtwidgets.qpushbutton(u'拒绝',self) # 因为需要增加按钮,所以我们引入了qpushbutton类,该按钮是qpushbutton类的一个实例。构造函数的第一个参数是按钮的标签。第二个参数是父窗口小部件。父窗口小部件是示例窗口小部件,它是通过qwidget继承的
  •     self.buttonno.setfocuspolicy(qtcore.qt.nofocus) # 按钮无焦点
  •     # qt::tabfocus 0x1 接受tab键焦点
  •     # qt::clickfocus 0x2 接受鼠标单击做焦点
  •     # qt::strongfocus tabfocus | clickfocus | 0x8 接受tab键和鼠标单击做焦点
  •     # qt::wheelfocus strongfocus | 0x4 滑轮作为焦点选中事件
  •     # qt::nofocus 0 不接受焦点
  •     self.buttonno.move(610, 700) # move()方法来指定部件的放置坐标,坐标的顶点就是窗口的左上角
  •     self.buttonno.clicked.connect(self.showdialogno)
  •  
  •  
  •  
  •  
  •   def showdialogok(self):
  •     qtwidgets.qmessagebox.information(self, "欧耶", "爱你,么么么么么么么哒~~~", qtwidgets.qmessagebox.ok)
  •     self.closeallowed = 1
  •  
  •   def showdialogee(self):
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你完了,***让你嫁给我", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你爸也是这么说的", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你奶奶也让你嫁给我", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你哥哥也同意了,你全家都同意", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你闺蜜说嫁给我没错", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你爸说不同意就打你", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "接受现实吧,我会对你好的", qtwidgets.qmessagebox.ok)
  •     qtwidgets.qmessagebox.information(self, "别纠结了", "你都是我的人了", qtwidgets.qmessagebox.ok)
  •  
  •   def showdialogno(self):
  •     self.q = random.randint(0, 650) # 在0-650内生成随机的x坐标
  •     self.w = random.randint(150, 650) # 在150-650内生成随机的y坐标
  •     self.buttonno.move(self.q, self.w)
  •  
  •  
  •   #enterevent事件pyqt自动运行,无需调用
  •   # def enterevent(self,event):#重写了鼠标的enterevent事件,由于继承了窗口类,鼠标一进入主窗口便会出发此函数
  •   #   self.q=random.randint(0,650)#在0-650内生成随机的x坐标
  •   #   self.w=random.randint(150,650)#在150-650内生成随机的y坐标
  •   #   self.buttonno.move(self.q,self.w)
  •  
  • #当我们关闭一个窗口时,在pyqt中就会触发一个qcloseevent的事件,正常情况下会直接关闭这个窗口,
  • #但是我们不希望这样的事情发生,所以我们需要重新定义qcloseevent,函数名称为closeevent不可变
  •   def closeevent(self,event):#函数名固定不可变
  •  
  •     if self.closeallowed==1:
  •       event.accept()#关闭窗口
  •     else:
  •       qtwidgets.qmessagebox.information(self, "未作回应", "小姐姐,请不要逃避!", qtwidgets.qmessagebox.ok)
  •       event.ignore()#忽视点击x事件
  •   def center(self):
  •     screen=qtwidgets.qdesktopwidget().screengeometry()#获取屏幕分辨率
  • #qtwidgets.qdesktopwidget().screengeometry()中qdesktopwidget()也有括号
  •     size=self.geometry()#获取窗口尺寸
  •     self.move((screen.width()-size.width())/2,(screen.height()-size.height())/2)#利用move函数窗口居中
  •  
  •  
  • app=qtwidgets.qapplication(sys.argv)
  • window=messagebox()
  • window.show()
  • sys.exit(app.exec_())
  • 生成exe

  • ?
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • #!/usr/bin/env python
  •  
  • # -*- coding: utf-8 -*-
  • """
  • __title__ = '将calculator项目转换为exe文件'
  • __author__ = '遂越净郝'
  • """
  • from pyinstaller.__main__ import run
  •  
  • if __name__ == '__main__':
  •  
  •   opts = ['douyin.py', '-w', '--onefile']
  •   #opts = ['douyin.py', '-f']
  •   #opts = ['douyin.py', '-f', '-w']
  •   #opts = ['douyin.py', '-f', '-w', '--icon=targetopinionmain.ico','--upx-dir','upx391w']
  •   run(opts)
  • 运行结果请阅读原文。

    以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持开心学习网。

    原文链接:https://zhuanlan.zhihu.com/p/38284396

    标签:
    上一篇下一篇

    猜您喜欢

    热门推荐