-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyqt5_test.py
133 lines (91 loc) · 3.65 KB
/
pyqt5_test.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import PyQt5.QtWidgets as qtw
import PyQt5.QtGui as qtg
import sys
from PyQt5.QtCore import *
class MainWindow(qtw.QWidget):
def __init__(self):
global folder_path
global subject1Detail
global subject2Detail
global subject3Detail
def pick_folder():
dialog = qtw.QFileDialog()
folder_path = dialog.getExistingDirectory(None, "Select Folder")
path.insert(folder_path)
return folder_path
# def saveSubject1():
#
# subject1Detail = detail1.toPlainText()
# print(subject1Detail)
#
#
# def saveSubject2():
#
# subject2Detail = detail2.toPlainText()
# print(subject2Detail)
#
#
# def saveSubject3():
#
# subject3Detail = detail3.toPlainText()
# print(subject3Detail)
#
#
# def saveAll():
# saveAlert = qtw.QMessageBox()
# saveAlert.setWindowTitle("Info saved!")
# saveAlert.setText(f"Your homework has been save to a text file under this folder! \n {subject1Detail}")
# pass
super().__init__()
custom_font = qtg.QFont()
custom_font.setFamily("Segoe UI")
custom_font.setPointSize(11)
# self.label.setAlignment(Qt.AlignCenter)
qtw.QApplication.setFont(custom_font, "QLabel")
# Set a title
self.setWindowTitle('Homework to Wallpaper!')
# Set a vertical layout
self.setLayout(qtw.QVBoxLayout())
# Create a label
warning = qtw.QLabel("WARNING: THIS PROGRAM WILL CHANGE YOUR WALLPAPER INSTANTLY AFTER IT'S FINISHED. PLS REMEMBER TO RECORD THE OLD WALLPAPER FILE LOCATION")
copyright = qtw.QLabel("Copyright to Leo Yu")
# Browse for the folder location
path = qtw.QLineEdit()
path.setObjectName("folder location")
path.setText("")
# Browse button
browse = qtw.QPushButton("Browse Folder", clicked = lambda: pick_folder())
# boxes
#subject1 = qtw.QLabel('Subject #1')
#detail1 = qtw.QTextEdit()
#detailSubject1 = qtw.QPushButton("Save Subject1", clicked = lambda: saveSubject1())
#subject2 = qtw.QLabel('Subject #2')
#detail2 = qtw.QTextEdit()
#detailSubject2 = qtw.QPushButton("SaveSubject2", clicked = lambda: saveSubject2())
#subject3 = qtw.QLabel('Subject #3')
#detail3 = qtw.QTextEdit()
#detailSubject3 = qtw.QPushButton("SaveSubject3", clicked = lambda: saveSubject3())
#save = qtw.QPushButton('Save', clicked = lambda: saveAll())
# Fixed. Don't need to change the font manually. Just use custom_font.
# Change the font size for the label
# warning.setFont(qtg.QFont(custom_font, 11))
# layout?
self.layout().addWidget(warning)
self.layout().addWidget(copyright)
self.layout().addWidget(path)
self.layout().addWidget(browse)
#self.layout().addWidget(subject1)
#self.layout().addWidget(detail1)
#self.layout().addWidget(detailSubject1)
#self.layout().addWidget(subject2)
#self.layout().addWidget(detail2)
#self.layout().addWidget(detailSubject2)
#self.layout().addWidget(subject3)
#self.layout().addWidget(detail3)
#self.layout().addWidget(detailSubject3)
#self.layout().addWidget(save)
self.show()
app = qtw.QApplication([])
mw = MainWindow()
# Run the App
app.exec_()