forked from Jarvis-K/wechat_jump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
109 lines (81 loc) · 3.19 KB
/
main.py
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
import sys
from PyQt5.QtWidgets import (QWidget, QLabel, QLineEdit, QGridLayout, QApplication, QPushButton)
from PyQt5 import QtGui, QtCore
import play # _test as play
from directory import *
class ProcessRunnable(QtCore.QRunnable):
def __init__(self, target, args):
QtCore.QRunnable.__init__(self)
self.t = target
self.args = args
def run(self):
self.t(*self.args)
def start(self):
QtCore.QThreadPool.globalInstance().start(self)
def changeImg(imagelabel, path):
imagelabel.setPixmap(QtGui.QPixmap(""))
pixmap = QtGui.QPixmap(path)
scaredPixmap = pixmap.scaled(800, 400, aspectRatioMode=QtCore.Qt.KeepAspectRatio)
imagelabel.setPixmap(scaredPixmap)
def changeText(label,text):
label.setText(str(text) + 's')
class Example(QWidget):
signal1 = QtCore.pyqtSignal(int)
wJump = play.WechatJump()
def __init__(self):
super().__init__()
self.initUI()
def click(self, checked):
self.p = ProcessRunnable(target=self.wJump.main, args=(self.wLineEdit.text(), self.hLineEdit.text(), self.signal1))
self.p.start()
def stop(self, checked):
self.wJump.runSig.emit()
print('stopppppp')
def signalCall1(self, press_time):
self.p0 = ProcessRunnable(target=changeImg, args=(self.imageLabel, '%sphone_screen.png' % temp_dir))
self.p1 = ProcessRunnable(target=changeImg, args=(self.imageLabel2, '%slast1.png' % temp_dir))
self.p2 = ProcessRunnable(target=changeText,args=(self.timeLineLabel, press_time))
self.p0.start()
self.p1.start()
self.p2.start()
def initUI(self):
layout = QGridLayout()
wLabel = QLabel("phone width")
self.wLineEdit = QLineEdit("1080")
self.wLineEdit.setFixedWidth(100)
hLabel = QLabel("phone height")
self.hLineEdit = QLineEdit("1920")
self.hLineEdit.setFixedWidth(100)
timeLabel = QLabel("press_time")
self.timeLineLabel = QLabel("700s")
self.imageLabel = QLabel()
button = QPushButton("Play", self)
stopbt = QPushButton("Stop",self)
button.clicked.connect(self.click)
stopbt.clicked.connect(self.stop)
self.imageLabel2 = QLabel()
self.signal1.connect(self.signalCall1)
leftlable = QLabel('<---------origin')
rightlable = QLabel('last----------->')
layout.setSpacing(10)
layout.addWidget(wLabel, 0, 0)
layout.addWidget(self.wLineEdit, 0, 1)
layout.addWidget(hLabel, 0, 3)
layout.addWidget(self.hLineEdit, 0, 4)
layout.addWidget(self.imageLabel, 1, 0, 8, 2)
layout.addWidget(leftlable, 3, 2)
layout.addWidget(rightlable, 5, 2)
layout.addWidget(self.imageLabel2, 1, 3, 8, 4)
layout.addWidget(button, 8, 2)
layout.addWidget(stopbt, 9, 2)
layout.addWidget(timeLabel, 10, 0)
layout.addWidget(self.timeLineLabel, 10, 1)
layout.setColumnStretch(1, 10)
self.setLayout(layout)
self.setGeometry(200, 200, 500, 500)
self.setWindowTitle('Jump')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())