-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
61 lines (50 loc) · 1.35 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
# transfer required library
from PyQt5 import QtWidgets, QtGui
from PyQt5.QtWidgets import QApplication
import sys
class MyWindow(QtWidgets.QWidget):
# init function
def __init__(self):
super().__init__()
self.setGeometry(700, 350, 450, 400)
self.setWindowTitle("Image Changer")
self.initUI()
# init user interface
def initUI(self):
self.label = QtWidgets.QLabel()
self.label.setPixmap(QtGui.QPixmap("QT5.png"))
# Buton Previous
self.b1 = QtWidgets.QPushButton()
self.b1.setText("previous <")
# Buton Next
self.b2 = QtWidgets.QPushButton()
self.b2.setText("Next >")
# Click to Button
self.b1.clicked.connect(self.clickedPrevious)
self.b2.clicked.connect(self.clickedNext)
# Place
self.possition(self.b1,self.b2,self.label)
def possition(self,previous,next,text):
# Placing Function
hBox = QtWidgets.QHBoxLayout()
vBox = QtWidgets.QVBoxLayout()
vBox.addWidget(text)
vBox.addStretch()
vBox.addWidget(previous)
vBox.addWidget(next)
hBox.addStretch()
hBox.addLayout(vBox)
hBox.addStretch()
self.setLayout(hBox)
# Task functions
def clickedNext(self):
self.label.setPixmap(QtGui.QPixmap("python.png"))
def clickedPrevious(self):
self.label.setPixmap(QtGui.QPixmap("QT5.png"))
# create window screen
def window():
app = QApplication(sys.argv)
win = MyWindow()
win.show()
sys.exit(app.exec_())
window()