├── .DS_Store
├── 02.02 PushButton
├── pushbuttonTest.py
└── pushbuttonTest.ui
├── 02.03 RadioButton
├── radiobuttonTest.py
└── radiobuttonTest.ui
├── 02.04 CheckBox
├── checkboxTest.py
└── checkboxTest.ui
├── 02.05 Label
├── labelTest.py
└── labelTest.ui
├── 02.06 TextBrowser
├── textbrowerTest.py
└── textbrowserTest.ui
├── 02.07 LineEdit
├── lineeditTest.py
└── lineeditTest.ui
├── 02.08 TextEdit
├── .DS_Store
├── plaintexteditTest.py
├── plaintexteditTest.ui
├── texteditTest.py
└── texteditTest.ui
├── 02.09 ComboBox
├── comboboxTest.py
└── comboboxTest.ui
├── 02.10 SpinBox
├── spinboxTest.py
└── spinboxTest.ui
├── 02.11 SliderDial
├── sliderDialTest.py
└── sliderDialTest.ui
├── 02.12 DateTimeEdit
├── .vscode
│ └── settings.json
├── dateTimeEditTest.py
└── dateTimeEditTest.ui
├── 02.13 DateEditTimeEdit
├── .DS_Store
├── .vscode
│ └── settings.json
├── dateEditTest.py
├── dateEditTest.ui
├── timeEditTest.py
└── timeEditTest.ui
├── 02.14 Calendar
├── calendarTest.py
└── calendarTest.ui
├── 02.15 Pixmap
├── .DS_Store
├── pixmapTest.py
├── pixmapTest.ui
└── testImage.jpg
├── 02.16 WebEngineView
├── .DS_Store
├── webEngineViewTest.py
└── webEngineViewTest.ui
├── 02.17 ProgressBar
├── .DS_Store
├── progressbarTest.py
└── progressbarTest.ui
├── 02.18 List Widget
├── .DS_Store
├── listwidgetTest.py
└── listwidgetTest.ui
├── 02.19. Table Widget
├── .DS_Store
├── tablewidgetTest.py
└── tablewidgetTest.ui
├── 02.20 Container
├── .DS_Store
└── containerTest.ui
└── etc
├── .DS_Store
└── 02.17.03 QProgressBar SameMinMax.gif
/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/.DS_Store
--------------------------------------------------------------------------------
/02.02 PushButton/pushbuttonTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | #UI파일 연결
6 | #단, UI파일은 Python 코드 파일과 같은 디렉토리에 위치해야한다.
7 | form_class = uic.loadUiType("pushbuttonTest.ui")[0]
8 |
9 | #화면을 띄우는데 사용되는 Class 선언
10 | class WindowClass(QMainWindow, form_class) :
11 | def __init__(self) :
12 | super().__init__()
13 | self.setupUi(self)
14 | #test
15 |
16 | self.btn_1.clicked.connect(self.button1Function)
17 | self.btn_2.clicked.connect(self.button2Function)
18 |
19 | def button1Function(self) :
20 | print("btn_1 Clicked")
21 |
22 | def button2Function(self) :
23 | print("btn_2 Clicked")
24 |
25 |
26 | if __name__ == "__main__" :
27 | app = QApplication(sys.argv)
28 | myWindow = WindowClass()
29 | myWindow.show()
30 | app.exec_()
--------------------------------------------------------------------------------
/02.02 PushButton/pushbuttonTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 205
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 70
20 | 80
21 | 113
22 | 32
23 |
24 |
25 |
26 | Button1
27 |
28 |
29 |
30 |
31 |
32 | 220
33 | 80
34 | 113
35 | 32
36 |
37 |
38 |
39 | Button2
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/02.03 RadioButton/radiobuttonTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("radiobuttonTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #GroupBox안에 있는 RadioButton들을 연결합니다.
13 | #GroupBox의 자세한 설명은 02.14 GroupBox를 참고하세요.
14 | self.groupBox_rad1.clicked.connect(self.groupboxRadFunction)
15 | self.groupBox_rad2.clicked.connect(self.groupboxRadFunction)
16 | self.groupBox_rad3.clicked.connect(self.groupboxRadFunction)
17 | self.groupBox_rad4.clicked.connect(self.groupboxRadFunction)
18 |
19 | def groupboxRadFunction(self) :
20 | if self.groupBox_rad1.isChecked() : print("GroupBox_rad1 Chekced")
21 | elif self.groupBox_rad2.isChecked() : print("GroupBox_rad2 Checked")
22 | elif self.groupBox_rad3.isChecked() : print("GroupBox_rad3 Checked")
23 | elif self.groupBox_rad4.isChecked() : print("GroupBox_rad4 Checked")
24 |
25 | if __name__ == "__main__" :
26 | app = QApplication(sys.argv)
27 | myWindow = WindowClass()
28 | myWindow.show()
29 | app.exec_()
--------------------------------------------------------------------------------
/02.03 RadioButton/radiobuttonTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 130
20 | 60
21 | 131
22 | 158
23 |
24 |
25 |
26 | GroupBox
27 |
28 |
29 | -
30 |
31 |
32 | groupBox1
33 |
34 |
35 |
36 | -
37 |
38 |
39 | groupBox2
40 |
41 |
42 |
43 | -
44 |
45 |
46 | groupBox3
47 |
48 |
49 |
50 | -
51 |
52 |
53 | groupBox4
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/02.04 CheckBox/checkboxTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("checkboxTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #GroupBox밖에 있는 CheckBox에 기능 연결
13 | self.chk_1.stateChanged.connect(self.chkFunction)
14 | self.chk_2.stateChanged.connect(self.chkFunction)
15 | self.chk_3.stateChanged.connect(self.chkFunction)
16 | self.chk_4.stateChanged.connect(self.chkFunction)
17 |
18 | #GroupBox안에 있는 CheckBox에 기능 연결
19 | self.groupchk_1.stateChanged.connect(self.groupchkFunction)
20 | self.groupchk_2.stateChanged.connect(self.groupchkFunction)
21 | self.groupchk_3.stateChanged.connect(self.groupchkFunction)
22 | self.groupchk_4.stateChanged.connect(self.groupchkFunction)
23 |
24 | def chkFunction(self) :
25 | #CheckBox는 여러개가 선택될 수 있기 때문에 elif를 사용하지 않습니다.
26 | if self.chk_1.isChecked() : print("chk_1 isChecked")
27 | if self.chk_2.isChecked() : print("chk_2 isChecked")
28 | if self.chk_3.isChecked() : print("chk_3 isChecked")
29 | if self.chk_4.isChecked() : print("chk_4 isChecked")
30 |
31 | def groupchkFunction(self) :
32 | if self.groupchk_1.isChecked() : print("groupchk_1 isChecked")
33 | if self.groupchk_2.isChecked() : print("groupchk_2 isChecked")
34 | if self.groupchk_3.isChecked() : print("groupchk_3 isChecked")
35 | if self.groupchk_4.isChecked() : print("groupchk_4 isChecked")
36 |
37 | if __name__ == "__main__" :
38 | app = QApplication(sys.argv)
39 | myWindow = WindowClass()
40 | myWindow.show()
41 | app.exec_()
--------------------------------------------------------------------------------
/02.04 CheckBox/checkboxTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 50
20 | 142
21 | 95
22 | 20
23 |
24 |
25 |
26 | CheckBox3
27 |
28 |
29 |
30 |
31 |
32 | 50
33 | 121
34 | 95
35 | 20
36 |
37 |
38 |
39 | CheckBox2
40 |
41 |
42 |
43 |
44 |
45 | 50
46 | 163
47 | 95
48 | 20
49 |
50 |
51 |
52 | CheckBox4
53 |
54 |
55 |
56 |
57 |
58 | 50
59 | 100
60 | 95
61 | 20
62 |
63 |
64 |
65 | CheckBox1
66 |
67 |
68 |
69 |
70 |
71 | 190
72 | 80
73 | 171
74 | 121
75 |
76 |
77 |
78 | GroupBox
79 |
80 |
81 |
82 |
83 | 10
84 | 71
85 | 120
86 | 20
87 |
88 |
89 |
90 | GroupCheck3
91 |
92 |
93 |
94 |
95 |
96 | 10
97 | 29
98 | 120
99 | 20
100 |
101 |
102 |
103 | GroupCheck1
104 |
105 |
106 |
107 |
108 |
109 | 10
110 | 92
111 | 120
112 | 20
113 |
114 |
115 |
116 | GroupCheck4
117 |
118 |
119 |
120 |
121 |
122 | 10
123 | 50
124 | 120
125 | 20
126 |
127 |
128 |
129 | GroupCheck2
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
--------------------------------------------------------------------------------
/02.05 Label/labelTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("labelTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #버튼에 기능을 할당하는 코드
13 | self.btn_changeText.clicked.connect(self.changeTextFunction)
14 | self.btn_printText.clicked.connect(self.printTextFunction)
15 |
16 | def changeTextFunction(self) :
17 | #self.Label이름.setText("String")
18 | #Label에 글자를 바꾸는 메서드
19 | self.lbl_Test.setText("This is Label - Change Text")
20 |
21 | def printTextFunction(self) :
22 | #self.Label이름.text()
23 | #Label에 있는 글자를 가져오는 메서드
24 | print(self.lbl_Test.text())
25 |
26 | if __name__ == "__main__" :
27 | app = QApplication(sys.argv)
28 | myWindow = WindowClass()
29 | myWindow.show()
30 | app.exec_()
31 |
--------------------------------------------------------------------------------
/02.05 Label/labelTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 300
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 120
20 | 110
21 | 171
22 | 20
23 |
24 |
25 |
26 | This is Label - Display Text
27 |
28 |
29 |
30 |
31 |
32 | 92
33 | 160
34 | 116
35 | 32
36 |
37 |
38 |
39 | ChangeText
40 |
41 |
42 |
43 |
44 |
45 | 210
46 | 160
47 | 98
48 | 32
49 |
50 |
51 |
52 | PrintText
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/02.06 TextBrowser/textbrowerTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("textbrowserTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #버튼에 기능을 할당하는 코드
13 | self.btn_Print.clicked.connect(self.printTextFunction)
14 | self.btn_setText.clicked.connect(self.changeTextFunction)
15 | self.btn_appendText.clicked.connect(self.appendTextFunction)
16 | self.btn_Clear.clicked.connect(self.clearTextFunction)
17 |
18 | def printTextFunction(self) :
19 | #self.Textbrowser이름.toPlainText()
20 | #Textbrowser에 있는 글자를 가져오는 메서드
21 | print(self.textbrow_Test.toPlainText())
22 |
23 | def changeTextFunction(self) :
24 | #self.Textbrowser이름.setPlainText()
25 | #Textbrowser에 있는 글자를 가져오는 메서드
26 | self.textbrow_Test.setPlainText("This is Textbrowser - Change Text")
27 |
28 | def appendTextFunction(self) :
29 | #self.Textbrowser이름.append()
30 | #Textbrowser에 있는 글자를 가져오는 메서드
31 | self.textbrow_Test.append("Append Text")
32 |
33 | def clearTextFunction(self) :
34 | #self.Textbrowser.clear()
35 | #Textbrowser에 있는 글자를 지우는 메서드
36 | self.textbrow_Test.clear()
37 |
38 | if __name__ == "__main__" :
39 | app = QApplication(sys.argv)
40 | myWindow = WindowClass()
41 | myWindow.show()
42 | app.exec_()
43 |
--------------------------------------------------------------------------------
/02.06 TextBrowser/textbrowserTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 410
10 | 228
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 20
21 | 256
22 | 192
23 |
24 |
25 |
26 |
27 |
28 |
29 | 280
30 | 50
31 | 116
32 | 134
33 |
34 |
35 |
36 | -
37 |
38 |
39 | Print
40 |
41 |
42 |
43 | -
44 |
45 |
46 | SetText
47 |
48 |
49 |
50 | -
51 |
52 |
53 | AppendText
54 |
55 |
56 |
57 | -
58 |
59 |
60 | Clear
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/02.07 LineEdit/lineeditTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("lineeditTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #버튼에 기능을 할당하는 코드
13 | self.lineedit_Test.textChanged.connect(self.lineeditTextFunction)
14 | self.lineedit_Test.returnPressed.connect(self.printTextFunction)
15 | self.btn_changeText.clicked.connect(self.changeTextFunction)
16 |
17 | def lineeditTextFunction(self) :
18 | self.lbl_textHere.setText(self.lineedit_Test.text())
19 |
20 | def printTextFunction(self) :
21 | #self.lineedit이름.text()
22 | #Lineedit에 있는 글자를 가져오는 메서드
23 | print(self.lineedit_Test.text())
24 |
25 | def changeTextFunction(self) :
26 | #self.lineedit이름.setText("String")
27 | #Lineedit의 글자를 바꾸는 메서드
28 | self.lineedit_Test.setText("Change Text")
29 |
30 | if __name__ == "__main__" :
31 | app = QApplication(sys.argv)
32 | myWindow = WindowClass()
33 | myWindow.show()
34 | app.exec_()
--------------------------------------------------------------------------------
/02.07 LineEdit/lineeditTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 171
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 30
20 | 50
21 | 351
22 | 16
23 |
24 |
25 |
26 | Text Here
27 |
28 |
29 |
30 |
31 |
32 | 30
33 | 80
34 | 351
35 | 33
36 |
37 |
38 |
39 | -
40 |
41 |
42 | -
43 |
44 |
45 | Change Label Text
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
--------------------------------------------------------------------------------
/02.08 TextEdit/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.08 TextEdit/.DS_Store
--------------------------------------------------------------------------------
/02.08 TextEdit/plaintexteditTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("plaintexteditTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #PlainTextEdit과 관련된 버튼에 기능 연결
13 | self.btn_printPlainTextEdit.clicked.connect(self.printPlainTextEdit)
14 | self.btn_clearPlainTextEdit.clicked.connect(self.clearPlainTextEdit)
15 | self.btn_appendPlainText.clicked.connect(self.appendPlainText)
16 |
17 | #PlainTextEdit과 관련된 함수
18 | def printPlainTextEdit(self) :
19 | print(self.plaintextedit_Test.toPlainText())
20 |
21 | def clearPlainTextEdit(self) :
22 | self.plaintextedit_Test.clear()
23 |
24 | def appendPlainText(self) :
25 | self.plaintextedit_Test.appendPlainText("Append Plain Text")
26 |
27 | if __name__ == "__main__" :
28 | app = QApplication(sys.argv)
29 | myWindow = WindowClass()
30 | myWindow.show()
31 | app.exec_()
--------------------------------------------------------------------------------
/02.08 TextEdit/plaintexteditTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 634
10 | 251
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 20
21 | 91
22 | 16
23 |
24 |
25 |
26 | Plain Text Edit
27 |
28 |
29 |
30 |
31 |
32 | 400
33 | 90
34 | 221
35 | 100
36 |
37 |
38 |
39 | -
40 |
41 |
42 | Print Plain Text Edit
43 |
44 |
45 |
46 | -
47 |
48 |
49 | Clear Plain Text Edit
50 |
51 |
52 |
53 | -
54 |
55 |
56 | Append Plain Text
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | 10
66 | 40
67 | 371
68 | 194
69 |
70 |
71 |
72 | -
73 |
74 |
75 | This is Plain Text Edit
76 | This widget support PlainText
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/02.08 TextEdit/texteditTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtGui import *
4 | from PyQt5 import uic
5 |
6 | form_class = uic.loadUiType("texteditTest.ui")[0]
7 |
8 | class WindowClass(QMainWindow, form_class) :
9 | def __init__(self) :
10 | super().__init__()
11 | self.setupUi(self)
12 | self.fontSize = 10
13 |
14 | #TextEdit과 관련된 버튼에 기능 연결
15 | self.btn_printTextEdit.clicked.connect(self.printTextEdit)
16 | self.btn_clearTextEdit.clicked.connect(self.clearTextEdit)
17 | self.btn_setFont.clicked.connect(self.setFont)
18 | self.btn_setFontItalic.clicked.connect(self.fontItalic)
19 | self.btn_setFontColor.clicked.connect(self.fontColorRed)
20 | self.btn_fontSizeUp.clicked.connect(self.fontSizeUp)
21 | self.btn_fontSizeDown.clicked.connect(self.fontSizeDown)
22 |
23 | def printTextEdit(self) :
24 | print(self.textedit_Test.toPlainText())
25 |
26 | def clearTextEdit(self) :
27 | self.textedit_Test.clear()
28 |
29 | def setFont(self) :
30 | fontvar = QFont("Apple SD Gothic Neo",10)
31 | self.textedit_Test.setCurrentFont(fontvar)
32 |
33 | def fontItalic(self) :
34 | self.textedit_Test.setFontItalic(True)
35 |
36 | def fontColorRed(self) :
37 | colorvar = QColor(255,0,0)
38 | self.textedit_Test.setTextColor(colorvar)
39 |
40 | def fontSizeUp(self) :
41 | self.fontSize = self.fontSize + 1
42 | self.textedit_Test.setFontPointSize(self.fontSize)
43 |
44 | def fontSizeDown(self) :
45 | self.fontSize = self.fontSize - 1
46 | self.textedit_Test.setFontPointSize(self.fontSize)
47 |
48 | if __name__ == "__main__" :
49 | app = QApplication(sys.argv)
50 | myWindow = WindowClass()
51 | myWindow.show()
52 | app.exec_()
--------------------------------------------------------------------------------
/02.08 TextEdit/texteditTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 702
10 | 276
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 30
21 | 60
22 | 16
23 |
24 |
25 |
26 | Text Edit
27 |
28 |
29 |
30 |
31 |
32 | 400
33 | 50
34 | 271
35 | 207
36 |
37 |
38 |
39 | -
40 |
41 |
42 | Print Text Edit
43 |
44 |
45 |
46 | -
47 |
48 |
49 | Clear Text Edit
50 |
51 |
52 |
53 | -
54 |
55 |
56 | Set Font
57 |
58 |
59 |
60 | -
61 |
62 |
63 | Set Font Italic
64 |
65 |
66 |
67 | -
68 |
69 |
70 | Set Font Color Red
71 |
72 |
73 |
74 | -
75 |
76 |
-
77 |
78 |
79 | Font Size Up
80 |
81 |
82 |
83 | -
84 |
85 |
86 | Font Size Down
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | 20
98 | 50
99 | 369
100 | 211
101 |
102 |
103 |
104 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
105 | <html><head><meta name="qrichtext" content="1" /><style type="text/css">
106 | p, li { white-space: pre-wrap; }
107 | </style></head><body style=" font-family:'.SF NS Text'; font-size:13pt; font-weight:400; font-style:normal;">
108 | <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600; color:#feaba5;">This is Text Edit</span></p>
109 | <p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#baa4ff;">This widget support </span><span style=" font-weight:600; font-style:italic; text-decoration: underline; color:#baa4ff;">Rich Text</span></p></body></html>
110 |
111 |
112 |
113 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/02.09 ComboBox/comboboxTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("comboboxTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #프로그램 실행 시 두개의 ComboBox를 동기화시키는 코드
13 | self.syncComboBox()
14 |
15 | #ComboBox에 기능 연결
16 | self.cmb_Test.currentIndexChanged.connect(self.comboBoxFunction)
17 |
18 | #버튼에 기능 연결
19 | self.btn_printItem.clicked.connect(self.printComboBoxItem)
20 | self.btn_clearItem.clicked.connect(self.clearComboBoxItem)
21 | self.btn_addItem.clicked.connect(self.addComboBoxItem)
22 | self.btn_deleteItem.clicked.connect(self.deleteComboBoxItem)
23 |
24 | def syncComboBox(self) :
25 | for i in range(0,self.cmb_Test.count()) :
26 | self.cmb_second.addItem(self.cmb_Test.itemText(i))
27 |
28 | def comboBoxFunction(self) :
29 | self.lbl_display.setText(self.cmb_Test.currentText())
30 |
31 | def clearComboBoxItem(self) :
32 | self.cmb_Test.clear()
33 | self.cmb_second.clear()
34 |
35 | def printComboBoxItem(self) :
36 | print(self.cmb_second.currentText())
37 |
38 | def addComboBoxItem(self) :
39 | self.cmb_Test.addItem(self.lineedit_addItem.text())
40 | self.cmb_second.addItem(self.lineedit_addItem.text())
41 | print("Item Added")
42 |
43 | def deleteComboBoxItem(self) :
44 | self.delidx = self.cmb_second.currentIndex()
45 | self.cmb_Test.removeItem(self.delidx)
46 | self.cmb_second.removeItem(self.delidx)
47 | print("Item Deleted")
48 |
49 | if __name__ == "__main__" :
50 | app = QApplication(sys.argv)
51 | myWindow = WindowClass()
52 | myWindow.show()
53 | app.exec_()
54 |
--------------------------------------------------------------------------------
/02.09 ComboBox/comboboxTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 395
10 | 304
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 24
21 | 371
22 | 265
23 |
24 |
25 |
26 | -
27 |
28 |
29 | Display ComboBox Text
30 |
31 |
32 |
33 | -
34 |
35 |
-
36 |
37 | 1st Item
38 |
39 |
40 | -
41 |
42 | 2nd Item
43 |
44 |
45 | -
46 |
47 | 3rd Item
48 |
49 |
50 |
51 |
52 | -
53 |
54 |
-
55 |
56 |
57 | PrintItem
58 |
59 |
60 |
61 | -
62 |
63 |
64 | ClearItem
65 |
66 |
67 |
68 |
69 |
70 | -
71 |
72 |
73 | Qt::Horizontal
74 |
75 |
76 |
77 | -
78 |
79 |
80 | Add Item to ComboBox
81 |
82 |
83 |
84 | -
85 |
86 |
-
87 |
88 |
89 | -
90 |
91 |
92 | AddItem
93 |
94 |
95 |
96 |
97 |
98 | -
99 |
100 |
101 | Delete ComboBox Item
102 |
103 |
104 |
105 | -
106 |
107 |
-
108 |
109 |
110 | -
111 |
112 |
113 | DeleteItem
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/02.10 SpinBox/spinboxTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("spinboxTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | self.spinbox_Test.valueChanged.connect(self.printValue)
13 | self.btn_showInfo.clicked.connect(self.printInfo)
14 | self.btn_changeRangeStep.clicked.connect(self.changeRangeStep)
15 |
16 | self.doublespinbox_Test.valueChanged.connect(self.printDoubleValue)
17 | self.btn_doubleShowInfo.clicked.connect(self.printDoubleInfo)
18 | self.btn_doubleChangeRangeStep.clicked.connect(self.doubleChangeRangeStep)
19 |
20 |
21 | def printValue(self) :
22 | print(self.spinbox_Test.value())
23 |
24 | def printInfo(self) :
25 | print("Maximum value is",self.spinbox_Test.maximum())
26 | print("Minimum value is",self.spinbox_Test.minimum())
27 | print("Step Size is",self.spinbox_Test.singleStep())
28 |
29 | def changeRangeStep(self) :
30 | self.spinbox_Test.setRange(0,1000)
31 | self.spinbox_Test.setStep(10)
32 |
33 | def printDoubleValue(self) :
34 | print(self.doublespinbox_Test.value())
35 |
36 | def printDoubleInfo(self) :
37 | print("Maximum value is",self.doublespinbox_Test.maximum())
38 | print("Minimum value is",self.doublespinbox_Test.minimum())
39 | print("Step Size is",self.doublespinbox_Test.singleStep())
40 |
41 | def doubleChangeRangeStep(self) :
42 | self.doublespinbox_Test.setRange(0,1000)
43 | self.doublespinbox_Test.setStep(1.5)
44 |
45 | if __name__ == "__main__" :
46 | app = QApplication(sys.argv)
47 | myWindow = WindowClass()
48 | myWindow.show()
49 | app.exec_()
--------------------------------------------------------------------------------
/02.10 SpinBox/spinboxTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 284
10 | 133
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 20
21 | 262
22 | 103
23 |
24 |
25 |
26 | -
27 |
28 |
-
29 |
30 |
31 | -
32 |
33 |
34 | ShowInfo
35 |
36 |
37 |
38 | -
39 |
40 |
41 | Change
42 |
43 |
44 |
45 |
46 |
47 | -
48 |
49 |
-
50 |
51 |
52 | -
53 |
54 |
55 | ShowInfo
56 |
57 |
58 |
59 | -
60 |
61 |
62 | Change
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/02.11 SliderDial/sliderDialTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5 import uic
4 |
5 | form_class = uic.loadUiType("sliderDialTest.ui")[0]
6 |
7 | class WindowClass(QMainWindow, form_class) :
8 | def __init__(self) :
9 | super().__init__()
10 | self.setupUi(self)
11 |
12 | #Vertical Slider의 시그널 사용
13 | self.slider_vertical.valueChanged.connect(self.showVerticalSliderValue)
14 | self.slider_vertical.rangeChanged.connect(self.printRangeChanged)
15 |
16 | #Horizontal Slider의 시그널 사용
17 | self.slider_horizontal.valueChanged.connect(self.showHorizontalSliderValue)
18 | self.slider_horizontal.rangeChanged.connect(self.printRangeChanged)
19 |
20 | #Dial의 시그널 사용
21 | self.dial_Test.valueChanged.connect(self.showDialValue)
22 | self.dial_Test.rangeChanged.connect(self.printRangeChanged)
23 |
24 | #버튼에 기능 연결
25 | self.btn_vInfo.clicked.connect(self.getVerticalInfo)
26 | self.btn_vValue.clicked.connect(self.setVertical)
27 | self.btn_hInfo.clicked.connect(self.getHorizontalInfo)
28 | self.btn_hValue.clicked.connect(self.setHorizontal)
29 | self.btn_dInfo.clicked.connect(self.getDialInfo)
30 | self.btn_dValue.clicked.connect(self.setDial)
31 |
32 |
33 | def printRangeChanged(self) :
34 | print("Range Changed")
35 |
36 | #Vertical Slider에 관련된 함수들
37 |
38 | def showVerticalSliderValue(self) :
39 | #Vertical Slider의 시그널 이용 - Vertical Slider의 값이 변경되면 Label에 값을 표시
40 | self.lbl_vertical.setText(str(self.slider_vertical.value()))
41 |
42 | def getVerticalInfo(self) :
43 | #Vertical Slider의 최대/최솟값과 PageStep/SingleStep값을 출력합니다.
44 | print("Maximum : " + str(self.slider_vertical.maximum()))
45 | print("Minimum : " + str(self.slider_vertical.minimum()))
46 | print("PageStep : " + str(self.slider_vertical.pageStep()))
47 | print("SingleStep : " + str(self.slider_vertical.singleStep()))
48 |
49 | def setVertical(self) :
50 | #Vertical Slider의 최대/최솟값과 PageStep/SingleStep값을 변경합니다.
51 | self.slider_vertical.setMaximum(500)
52 | self.slider_vertical.setMinimum(-500)
53 | self.slider_vertical.setPageStep(100)
54 | self.slider_vertical.setSingleStep(20)
55 |
56 |
57 | #Horizontal Slider에 관련된 함수들
58 |
59 | def showHorizontalSliderValue(self) :
60 | #Horizontal Slider의 시그널 이용 - Horizontal Slider의 값이 변경되면 Label에 값을 표시
61 | self.lbl_horizontal.setText(str(self.slider_horizontal.value()))
62 |
63 | def getHorizontalInfo(self) :
64 | #Horizontal Slider의 최대/최솟값과 PageStep/SingleStep값을 출력합니다.
65 | print("Maximum : " + str(self.slider_horizontal.maximum()))
66 | print("Minimum : " + str(self.slider_horizontal.minimum()))
67 | print("PageStep : " + str(self.slider_horizontal.pageStep()))
68 | print("SingleStep : " + str(self.slider_horizontal.singleStep()))
69 |
70 | def setHorizontal(self) :
71 | #Horizontal Slider의 최대/최솟값과 PageStep/SingleStep값을 변경합니다.
72 | self.slider_horizontal.setMaximum(500)
73 | self.slider_horizontal.setMinimum(-500)
74 | self.slider_horizontal.setPageStep(100)
75 | self.slider_horizontal.setSingleStep(20)
76 |
77 | #Dial에 관련된 함수들
78 | def showDialValue(self) :
79 | #Dial의 시그널 이용 - Dial의 값이 변경되면 Label에 값을 표시
80 | self.lbl_dial.setText(str(self.dial_Test.value()))
81 |
82 | def getDialInfo(self) :
83 | #Dial의 최대/최솟값과 PageStep/SingleStep값을 출력합니다.
84 | print("Maximum : " + str(self.dial_Test.maximum()))
85 | print("Minimum : " + str(self.dial_Test.minimum()))
86 | print("PageStep : " + str(self.dial_Test.pageStep()))
87 | print("SingleStep : " + str(self.dial_Test.singleStep()))
88 |
89 | def setDial(self) :
90 | #Dial의 최대/최솟값과 PageStep/SingleStep값을 변경합니다.
91 | self.dial_Test.setMaximum(500)
92 | self.dial_Test.setMinimum(-500)
93 | self.dial_Test.setPageStep(100)
94 | self.dial_Test.setSingleStep(20)
95 |
96 |
97 | if __name__ == "__main__" :
98 | app = QApplication(sys.argv)
99 | myWindow = WindowClass()
100 | myWindow.show()
101 | app.exec_()
--------------------------------------------------------------------------------
/02.11 SliderDial/sliderDialTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 457
10 | 196
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 40
20 | 160
21 | 201
22 | 22
23 |
24 |
25 |
26 | Qt::Horizontal
27 |
28 |
29 |
30 |
31 |
32 | 10
33 | 20
34 | 22
35 | 160
36 |
37 |
38 |
39 | Qt::Vertical
40 |
41 |
42 |
43 |
44 |
45 | 40
46 | 30
47 | 205
48 | 118
49 |
50 |
51 |
52 | -
53 |
54 |
55 | Vertical Value Here
56 |
57 |
58 |
59 | -
60 |
61 |
62 | Horizontal Value Here
63 |
64 |
65 |
66 | -
67 |
68 |
-
69 |
70 |
-
71 |
72 |
73 | V_Info
74 |
75 |
76 |
77 | -
78 |
79 |
80 | V_Range
81 |
82 |
83 |
84 |
85 |
86 | -
87 |
88 |
-
89 |
90 |
91 | H_Info
92 |
93 |
94 |
95 | -
96 |
97 |
98 | H_Range
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 | 290
112 | 20
113 | 101
114 | 101
115 |
116 |
117 |
118 | Qt::Horizontal
119 |
120 |
121 |
122 |
123 |
124 | 260
125 | 120
126 | 181
127 | 58
128 |
129 |
130 |
131 | -
132 |
133 |
134 | Dial Value Here
135 |
136 |
137 |
138 | -
139 |
140 |
-
141 |
142 |
143 | D_Info
144 |
145 |
146 |
147 | -
148 |
149 |
150 | D_Range
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/02.12 DateTimeEdit/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.linting.pylintArgs": [
3 | "--extension-pkg-whitelist=PyQt5"
4 | ]
5 | }
--------------------------------------------------------------------------------
/02.12 DateTimeEdit/dateTimeEditTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5 import uic
5 |
6 | form_class = uic.loadUiType("dateTimeEditTest.ui")[0]
7 |
8 | class WindowClass(QMainWindow, form_class) :
9 | def __init__(self) :
10 | super().__init__()
11 | self.setupUi(self)
12 |
13 | #프로그램이 실행되면 DateTimeEdit의 값이 현재 날짜/시간으로 설정되게 하기
14 | self.currentDateTime = QDateTime.currentDateTime()
15 | self.dateTimeEdit_Test.setDateTime(self.currentDateTime)
16 |
17 | #버튼들에 기능 할당
18 | self.btn_displayDateTime.clicked.connect(self.displayDateTime)
19 | self.btn_enterDateTime.clicked.connect(self.enterDateTimeFunc)
20 | self.btn_enterDate.clicked.connect(self.enterDateFunc)
21 | self.btn_enterTime.clicked.connect(self.enterTimeFunc)
22 | self.btn_changeFormat.clicked.connect(self.changeDisplayFormat)
23 | self.btn_showRange.clicked.connect(self.showRangeFunc)
24 | self.btn_editMaximum.clicked.connect(self.extendMaximum)
25 | self.btn_editMinimum.clicked.connect(self.extendMinimum)
26 |
27 | def displayDateTime(self) :
28 | #DateTimeEdit의 값을 사용할 때는 아래와 같이 객체를 만들고, 그 객체에 값을 저장한 후 사용해야 합니다.
29 | self.displayDateTimeVar = self.dateTimeEdit_Test.dateTime()
30 | self.displayDateVar = self.dateTimeEdit_Test.date()
31 | self.displayTimeVar = self.dateTimeEdit_Test.time()
32 |
33 | #QDateTime, QDate, QTime 객체들의 값을 Label에 표시합니다.
34 | #toString 함수는 02.12QDateTimeEdit의 하위페이지에 있는 QDateTime, QDate, QTime 함수를 참고하시기 바랍니다.
35 | self.lbl_displayDateTime.setText(self.displayDateTimeVar.toString("yyyy-MM-dd AP hh:mm:ss"))
36 | self.lbl_displayDate.setText(self.displayDateVar.toString("yyyy-MM-dd"))
37 | self.lbl_displayTime.setText(self.displayTimeVar.toString("AP hh:mm:ss"))
38 |
39 | def enterDateTimeFunc(self) :
40 | #LineEdit에서 글자를 가져온 후, fromString 함수를 이용해서 QDateTime객체를 만듭니다.
41 | #그 후, setDateTime 함수를 이용해 DateTimeEdit에 적용합니다.
42 | self.enterDateTimeText = self.line_dateTime.text()
43 | self.enterDateTimeVar = QDateTime.fromString(self.enterDateTimeText, "yyyy-MM-dd AP hh:mm:ss")
44 | self.dateTimeEdit_Test.setDateTime(self.enterDateTimeVar)
45 |
46 | def enterDateFunc(self) :
47 | #LineEdit에서 글자를 가져온 후, fromString 함수를 이용해서 QDate객체를 만듭니다.
48 | #그 후, setDate 함수를 이용해 DateTimeEdit에 적용합니다.
49 | self.enterDateText = self.line_date.text()
50 | self.enterDateVar = QDate.fromString(self.enterDateText, "yyyy-MM-dd")
51 | self.dateTimeEdit_Test.setDate(self.enterDateVar)
52 |
53 | def enterTimeFunc(self) :
54 | #LineEdit에서 글자를 가져온 후, fromString 함수를 이용해서 QTime객체를 만듭니다.
55 | #그 후, setTime 함수를 이용해 DateTimeEdit에 적용합니다.
56 | self.enterTimeText = self.line_time.text()
57 | self.enterTimeVar = QTime.fromString(self.enterTimeText, "AP hh:mm:ss")
58 | self.dateTimeEdit_Test.setTime(self.enterTimeVar)
59 |
60 | def changeDisplayFormat(self) :
61 | #LineEdit에서 글자를 가져온 후, 그 글자를 DateTimeEdit의 형식문자로 지정합니다.
62 | self.displayFormatText = self.line_displayFormat.text()
63 | self.dateTimeEdit_Test.setDisplayFormat(self.displayFormatText)
64 |
65 | def showRangeFunc(self) :
66 | print(self.dateTimeEdit_Test.minimumDateTime())
67 | print(self.dateTimeEdit_Test.maximumDateTime())
68 |
69 | def extendMaximum(self) :
70 | #DateTimeEdit의 현재 maximumDateTime을 가져옵니다.
71 | #그 후 addDays 함수를 이용하여 최댓값을 10일 연장시킨 후, setMaximumDateTime을 이용하여 DateTimeEdit에 적용시킵니다.
72 | self.currentMaximumDateTime = self.dateTimeEdit_Test.maximumDateTime()
73 | self.currentMaximumDateTime = self.currentMaximumDateTime.addDays(10)
74 | self.dateTimeEdit_Test.setMaximumDateTime(self.currentMaximumDateTime)
75 |
76 | def extendMinimum(self) :
77 | #DateTimeEdit의 현재 minimumDateTime을 가져옵니다.
78 | #그 후 addDays 함수를 이용하여 최솟값을 10일 뒤로 미룬 후, setMinimumDateTime을 이용하여 DateTimeEdit에 적용시킵니다.
79 | self.currentMinimumDateTime = self.dateTimeEdit_Test.minimumDateTime()
80 | self.currentMinimumDateTime = self.currentMinimumDateTime.addDays(-10)
81 | self.dateTimeEdit_Test.setMinimumDateTime(self.currentMinimumDateTime)
82 |
83 |
84 | if __name__ == "__main__" :
85 | app = QApplication(sys.argv)
86 | myWindow = WindowClass()
87 | myWindow.show()
88 | app.exec_()
--------------------------------------------------------------------------------
/02.12 DateTimeEdit/dateTimeEditTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 410
10 | 439
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 280
20 | 140
21 | 111
22 | 31
23 |
24 |
25 |
26 | Display Info
27 |
28 |
29 |
30 |
31 |
32 | 10
33 | 40
34 | 261
35 | 31
36 |
37 |
38 |
39 |
40 | 23
41 | 59
42 | 59
43 | 2100
44 | 1
45 | 1
46 |
47 |
48 |
49 |
50 | 0
51 | 0
52 | 0
53 | 2000
54 | 1
55 | 1
56 |
57 |
58 |
59 |
60 | 2100
61 | 1
62 | 1
63 |
64 |
65 |
66 | QDateTimeEdit::DaySection
67 |
68 |
69 | dd/MM/yyyy h:m:s
70 |
71 |
72 | true
73 |
74 |
75 |
76 |
77 |
78 | 10
79 | 80
80 | 380
81 | 20
82 |
83 |
84 |
85 | Qt::Horizontal
86 |
87 |
88 |
89 |
90 |
91 | 10
92 | 220
93 | 380
94 | 20
95 |
96 |
97 |
98 | Qt::Horizontal
99 |
100 |
101 |
102 |
103 |
104 | 274
105 | 248
106 | 121
107 | 23
108 |
109 |
110 |
111 | DateTime
112 |
113 |
114 |
115 |
116 |
117 | 10
118 | 249
119 | 258
120 | 20
121 |
122 |
123 |
124 | DateTime
125 |
126 |
127 |
128 |
129 |
130 | 10
131 | 280
132 | 258
133 | 20
134 |
135 |
136 |
137 | Date
138 |
139 |
140 |
141 |
142 |
143 | 274
144 | 279
145 | 121
146 | 23
147 |
148 |
149 |
150 | Date
151 |
152 |
153 |
154 |
155 |
156 | 10
157 | 310
158 | 258
159 | 20
160 |
161 |
162 |
163 | Time
164 |
165 |
166 |
167 |
168 |
169 | 274
170 | 309
171 | 121
172 | 23
173 |
174 |
175 |
176 | Time
177 |
178 |
179 |
180 |
181 |
182 | 10
183 | 340
184 | 380
185 | 20
186 |
187 |
188 |
189 | Qt::Horizontal
190 |
191 |
192 |
193 |
194 |
195 | 10
196 | 361
197 | 258
198 | 20
199 |
200 |
201 |
202 | Display Format
203 |
204 |
205 |
206 |
207 |
208 | 274
209 | 360
210 | 121
211 | 23
212 |
213 |
214 |
215 | ChangeFormat
216 |
217 |
218 |
219 |
220 |
221 | 10
222 | 110
223 | 261
224 | 101
225 |
226 |
227 |
228 | -
229 |
230 |
231 | Display DateTime
232 |
233 |
234 |
235 | -
236 |
237 |
238 | Display Date
239 |
240 |
241 |
242 | -
243 |
244 |
245 | Display Time
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 | 10
255 | 400
256 | 381
257 | 32
258 |
259 |
260 |
261 | -
262 |
263 |
264 | ShowRange
265 |
266 |
267 |
268 | -
269 |
270 |
271 | Edit Maximum
272 |
273 |
274 |
275 | -
276 |
277 |
278 | Edit Minimum
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
--------------------------------------------------------------------------------
/02.13 DateEditTimeEdit/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.13 DateEditTimeEdit/.DS_Store
--------------------------------------------------------------------------------
/02.13 DateEditTimeEdit/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "python.linting.pylintArgs": [
3 | "--extension-pkg-whitelist=PyQt5"
4 | ]
5 | }
--------------------------------------------------------------------------------
/02.13 DateEditTimeEdit/dateEditTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5 import uic
5 |
6 | form_class = uic.loadUiType("dateEditTest.ui")[0]
7 |
8 | class WindowClass(QMainWindow, form_class) :
9 | def __init__(self) :
10 | super().__init__()
11 | self.setupUi(self)
12 |
13 | #프로그램이 실행되면 DateEdit의 값이 현재 날짜/시간으로 설정되게 하기
14 | self.currentDate = QDate.currentDate()
15 | self.dateEdit_Test.setDate(self.currentDate)
16 |
17 | #버튼들에 기능 할당
18 | self.btn_displayDate.clicked.connect(self.displayDate)
19 | self.btn_enterDate.clicked.connect(self.enterDateFunc)
20 | self.btn_changeFormat.clicked.connect(self.changeDisplayFormat)
21 | self.btn_showRange.clicked.connect(self.showRangeFunc)
22 | self.btn_editMaximum.clicked.connect(self.extendMaximum)
23 | self.btn_editMinimum.clicked.connect(self.extendMinimum)
24 |
25 | def displayDate(self) :
26 | self.displayDateVar = self.dateEdit_Test.date()
27 | self.lbl_displayDate.setText(self.displayDateVar.toString("yyyy-MM-dd"))
28 |
29 | def enterDateFunc(self) :
30 | #LineEdit에서 글자를 가져온 후, fromString 함수를 이용해서 QDate객체를 만듭니다.
31 | #그 후, setDate 함수를 이용해 DateEdit에 적용합니다.
32 | self.enterDateText = self.line_date.text()
33 | self.enterDateVar = QDate.fromString(self.enterDateText, "yyyy-MM-dd")
34 | self.dateEdit_Test.setDate(self.enterDateVar)
35 |
36 | def changeDisplayFormat(self) :
37 | #LineEdit에서 글자를 가져온 후, 그 글자를 DateEdit의 형식문자로 지정합니다.
38 | self.displayFormatText = self.line_displayFormat.text()
39 | self.dateEdit_Test.setDisplayFormat(self.displayFormatText)
40 |
41 | def showRangeFunc(self) :
42 | print(self.dateEdit_Test.minimumDate())
43 | print(self.dateEdit_Test.maximumDate())
44 |
45 | def extendMaximum(self) :
46 | #DateEdit의 현재 maximumDate을 가져옵니다.
47 | #그 후 addDays 함수를 이용하여 최댓값을 10일 연장시킨 후, setMaximumDate을 이용하여 DateEdit에 적용시킵니다.
48 | self.currentMaximumDate = self.dateEdit_Test.maximumDate()
49 | self.currentMaximumDate = self.currentMaximumDate.addDays(10)
50 | self.dateEdit_Test.setMaximumDate(self.currentMaximumDate)
51 |
52 | def extendMinimum(self) :
53 | #DateEdit의 현재 minimumDate을 가져옵니다.
54 | #그 후 addDays 함수를 이용하여 최솟값을 10일 뒤로 미룬 후, setMinimumDate을 이용하여 DateEdit에 적용시킵니다.
55 | self.currentMinimumDate = self.dateEdit_Test.minimumDate()
56 | self.currentMinimumDate = self.currentMinimumDate.addDays(-10)
57 | self.dateEdit_Test.setMinimumDate(self.currentMinimumDate)
58 |
59 |
60 | if __name__ == "__main__" :
61 | app = QApplication(sys.argv)
62 | myWindow = WindowClass()
63 | myWindow.show()
64 | app.exec_()
--------------------------------------------------------------------------------
/02.13 DateEditTimeEdit/dateEditTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 410
10 | 250
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 50
21 | 380
22 | 20
23 |
24 |
25 |
26 | Qt::Horizontal
27 |
28 |
29 |
30 |
31 |
32 | 10
33 | 180
34 | 380
35 | 20
36 |
37 |
38 |
39 | Qt::Horizontal
40 |
41 |
42 |
43 |
44 |
45 | 10
46 | 200
47 | 381
48 | 32
49 |
50 |
51 |
52 | -
53 |
54 |
55 | ShowRange
56 |
57 |
58 |
59 | -
60 |
61 |
62 | Edit Maximum
63 |
64 |
65 |
66 | -
67 |
68 |
69 | Edit Minimum
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | 10
79 | 20
80 | 231
81 | 24
82 |
83 |
84 |
85 |
86 | 2100
87 | 1
88 | 1
89 |
90 |
91 |
92 |
93 | 2000
94 | 1
95 | 1
96 |
97 |
98 |
99 |
100 |
101 |
102 | 10
103 | 140
104 | 381
105 | 33
106 |
107 |
108 |
109 | -
110 |
111 |
112 | Display Format
113 |
114 |
115 |
116 | -
117 |
118 |
119 | ChangeFormat
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 | 10
129 | 101
130 | 321
131 | 33
132 |
133 |
134 |
135 | -
136 |
137 |
138 | Date
139 |
140 |
141 |
142 | -
143 |
144 |
145 | Date
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 | 10
155 | 70
156 | 219
157 | 32
158 |
159 |
160 |
161 | -
162 |
163 |
164 | Display Date
165 |
166 |
167 |
168 | -
169 |
170 |
171 | Display Info
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
--------------------------------------------------------------------------------
/02.13 DateEditTimeEdit/timeEditTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5 import uic
5 |
6 | form_class = uic.loadUiType("TimeEditTest.ui")[0]
7 |
8 | class WindowClass(QMainWindow, form_class) :
9 | def __init__(self) :
10 | super().__init__()
11 | self.setupUi(self)
12 |
13 | #프로그램이 실행되면 TimeEdit의 값이 현재 날짜/시간으로 설정되게 하기
14 | self.currentTime = QTime.currentTime()
15 | self.timeEdit_Test.setTime(self.currentTime)
16 |
17 | #버튼들에 기능 할당
18 | self.btn_displayTime.clicked.connect(self.displayTime)
19 | self.btn_enterTime.clicked.connect(self.enterTimeFunc)
20 | self.btn_changeFormat.clicked.connect(self.changeDisplayFormat)
21 |
22 | def displayTime(self) :
23 | self.displayTimeVar = self.timeEdit_Test.time()
24 | self.lbl_displayTime.setText(self.displayTimeVar.toString("AP hh:mm:ss"))
25 |
26 | def enterTimeFunc(self) :
27 | #LineEdit에서 글자를 가져온 후, fromString 함수를 이용해서 QTime객체를 만듭니다.
28 | #그 후, setTime 함수를 이용해 TimeEdit에 적용합니다.
29 | self.enterTimeText = self.line_time.text()
30 | self.enterTimeVar = QTime.fromString(self.enterTimeText, "AP hh:mm:ss")
31 | self.timeEdit_Test.setTime(self.enterTimeVar)
32 |
33 | def changeDisplayFormat(self) :
34 | #LineEdit에서 글자를 가져온 후, 그 글자를 TimeEdit의 형식문자로 지정합니다.
35 | self.displayFormatText = self.line_displayFormat.text()
36 | self.timeEdit_Test.setDisplayFormat(self.displayFormatText)
37 |
38 | if __name__ == "__main__" :
39 | app = QApplication(sys.argv)
40 | myWindow = WindowClass()
41 | myWindow.show()
42 | app.exec_()
--------------------------------------------------------------------------------
/02.13 DateEditTimeEdit/timeEditTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 410
10 | 191
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 50
21 | 380
22 | 20
23 |
24 |
25 |
26 | Qt::Horizontal
27 |
28 |
29 |
30 |
31 |
32 | 10
33 | 140
34 | 381
35 | 33
36 |
37 |
38 |
39 | -
40 |
41 |
42 | Display Format
43 |
44 |
45 |
46 | -
47 |
48 |
49 | ChangeFormat
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 10
59 | 101
60 | 321
61 | 33
62 |
63 |
64 |
65 | -
66 |
67 |
68 | Time
69 |
70 |
71 |
72 | -
73 |
74 |
75 | Time
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | 10
85 | 70
86 | 219
87 | 32
88 |
89 |
90 |
91 | -
92 |
93 |
94 | Display Time
95 |
96 |
97 |
98 | -
99 |
100 |
101 | Display Info
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | 10
111 | 20
112 | 231
113 | 24
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
--------------------------------------------------------------------------------
/02.14 Calendar/calendarTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5 import uic
5 |
6 | form_class = uic.loadUiType("calendarTest.ui")[0]
7 |
8 | class WindowClass(QMainWindow, form_class) :
9 | def __init__(self) :
10 | super().__init__()
11 | self.setupUi(self)
12 |
13 | #QCalendarWidget의 시그널
14 | self.calendarWidget_Test.clicked.connect(self.calendarClicked)
15 | self.calendarWidget_Test.currentPageChanged.connect(self.calendarPageChanged)
16 | self.calendarWidget_Test.selectionChanged.connect(self.calendarSelectionChanged)
17 |
18 | #QCalendarWidget이 자동으로 오늘 날짜가 있는 달력을 보여주게 설정
19 | self.todayDate = QDate.currentDate()
20 | self.calendarWidget_Test.setCurrentPage(self.todayDate.year(), self.todayDate.month())
21 |
22 | #버튼에 기능 연결
23 | self.btn_prevMonth.clicked.connect(self.prevMonth)
24 | self.btn_nextMonth.clicked.connect(self.nextMonth)
25 | self.btn_today.clicked.connect(self.today)
26 |
27 | #CalendarWidget의 시그널에 연결된 함수들
28 | def calendarClicked(self) :
29 | print(self.calendarWidget_Test.selectedDate())
30 |
31 | def calendarPageChanged(self) :
32 | self.year = str(self.calendarWidget_Test.yearShown()) + "년"
33 | self.month = str(self.calendarWidget_Test.monthShown()) + "월"
34 | self.lbl_currentPage.setText(self.year + " " + self.month)
35 |
36 | def calendarSelectionChanged(self) :
37 | self.selectedDateVar = self.calendarWidget_Test.selectedDate()
38 | self.lbl_selectedDate.setText(self.selectedDateVar.toString())
39 |
40 | #버튼에 연결된 함수들
41 | def prevMonth(self) :
42 | self.calendarWidget_Test.showPreviousMonth()
43 |
44 | def nextMonth(self) :
45 | self.calendarWidget_Test.showNextMonth()
46 |
47 | def today(self) :
48 | self.calendarWidget_Test.showToday()
49 |
50 |
51 | if __name__ == "__main__" :
52 | app = QApplication(sys.argv)
53 | myWindow = WindowClass()
54 | myWindow.show()
55 | app.exec_()
--------------------------------------------------------------------------------
/02.14 Calendar/calendarTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 400
10 | 307
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 10
21 | 381
22 | 211
23 |
24 |
25 |
26 | false
27 |
28 |
29 |
30 |
31 |
32 | 10
33 | 230
34 | 381
35 | 32
36 |
37 |
38 |
39 | -
40 |
41 |
42 | Prev. Month
43 |
44 |
45 |
46 | -
47 |
48 |
49 | Today
50 |
51 |
52 |
53 | -
54 |
55 |
56 | Next Month
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | 10
66 | 270
67 | 381
68 | 20
69 |
70 |
71 |
72 | -
73 |
74 |
75 | Selected Date Here
76 |
77 |
78 |
79 | -
80 |
81 |
82 | Current Page Here
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/02.15 Pixmap/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.15 Pixmap/.DS_Store
--------------------------------------------------------------------------------
/02.15 Pixmap/pixmapTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | import urllib.request
3 | from PyQt5.QtWidgets import *
4 | from PyQt5.QtCore import *
5 | from PyQt5.QtGui import *
6 | from PyQt5 import uic
7 |
8 | form_class = uic.loadUiType("pixmapTest.ui")[0]
9 |
10 | class WindowClass(QMainWindow, form_class) :
11 | def __init__(self) :
12 | super().__init__()
13 | self.setupUi(self)
14 |
15 | self.btn_loadFromFile.clicked.connect(self.loadImageFromFile)
16 | self.btn_loadFromWeb.clicked.connect(self.loadImageFromWeb)
17 | self.btn_savePicture.clicked.connect(self.saveImageFromWeb)
18 |
19 | def loadImageFromFile(self) :
20 | #QPixmap 객체 생성 후 이미지 파일을 이용하여 QPixmap에 사진 데이터 Load하고, Label을 이용하여 화면에 표시
21 | self.qPixmapFileVar = QPixmap()
22 | self.qPixmapFileVar.load("testImage.jpg")
23 | self.qPixmapFileVar = self.qPixmapFileVar.scaledToWidth(600)
24 | self.lbl_picture.setPixmap(self.qPixmapFileVar)
25 |
26 | def loadImageFromWeb(self) :
27 |
28 | #Web에서 Image 정보 로드
29 | urlString = "https://avatars1.githubusercontent.com/u/44885477?s=460&v=4"
30 | imageFromWeb = urllib.request.urlopen(urlString).read()
31 |
32 | #웹에서 Load한 Image를 이용하여 QPixmap에 사진데이터를 Load하고, Label을 이용하여 화면에 표시
33 | self.qPixmapWebVar = QPixmap()
34 | self.qPixmapWebVar.loadFromData(imageFromWeb)
35 | self.qPixmapWebVar = self.qPixmapWebVar.scaledToWidth(600)
36 | self.lbl_picture.setPixmap(self.qPixmapWebVar)
37 |
38 | def saveImageFromWeb(self) :
39 | #Label에서 표시하고 있는 사진 데이터를 QPixmap객체의 형태로 반환받은 후, save함수를 이용해 사진 저장
40 | self.qPixmapSaveVar = self.lbl_picture.pixmap()
41 | self.qPixmapSaveVar.save("SavedImage.jpg")
42 |
43 |
44 | if __name__ == "__main__" :
45 | app = QApplication(sys.argv)
46 | myWindow = WindowClass()
47 | myWindow.show()
48 | app.exec_()
--------------------------------------------------------------------------------
/02.15 Pixmap/pixmapTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 659
10 | 695
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 20
20 | 30
21 | 600
22 | 600
23 |
24 |
25 |
26 | TextLabel
27 |
28 |
29 |
30 |
31 |
32 | 20
33 | 650
34 | 631
35 | 32
36 |
37 |
38 |
39 | -
40 |
41 |
42 | loadFromFile
43 |
44 |
45 |
46 | -
47 |
48 |
49 | loadFromWeb
50 |
51 |
52 |
53 | -
54 |
55 |
56 | Save
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/02.15 Pixmap/testImage.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.15 Pixmap/testImage.jpg
--------------------------------------------------------------------------------
/02.16 WebEngineView/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.16 WebEngineView/.DS_Store
--------------------------------------------------------------------------------
/02.16 WebEngineView/webEngineViewTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5.QtGui import *
5 | from PyQt5 import uic
6 |
7 | form_class = uic.loadUiType("webEngineViewTest.ui")[0]
8 |
9 | class WindowClass(QMainWindow, form_class) :
10 | def __init__(self) :
11 | super().__init__()
12 | self.setupUi(self)
13 |
14 | #WebEngineView의 시그널
15 | self.webEngineView_Test.loadStarted.connect(self.printLoadStart)
16 | self.webEngineView_Test.loadProgress.connect(self.printLoading)
17 | self.webEngineView_Test.loadFinished.connect(self.printLoadFinished)
18 | self.webEngineView_Test.urlChanged.connect(self.urlChangedFunction)
19 |
20 | #버튼들에 기능을 연결
21 | self.btn_setUrl.clicked.connect(self.urlGo)
22 | self.btn_back.clicked.connect(self.btnBackFunc)
23 | self.btn_forward.clicked.connect(self.btnForwardFunc)
24 | self.btn_reload.clicked.connect(self.btnRelaodFunc)
25 | self.btn_stop.clicked.connect(self.btnStopFunc)
26 |
27 | #WebEngineView의 시그널에 연결된 함수들
28 | def printLoadStart(self) : print("Start Loading")
29 | def printLoading(self) : print("Loading")
30 | def printLoadFinished(self) : print("Load Finished")
31 |
32 | def urlChangedFunction(self) :
33 | self.line_url.setText(self.webEngineView_Test.url().toString())
34 | print("Url Changed")
35 |
36 | #버튼을 눌렀을 때 실행될 함수들
37 | def urlGo(self) :
38 | self.webEngineView_Test.load(QUrl(self.line_url.text()))
39 |
40 | def btnBackFunc(self) :
41 | self.webEngineView_Test.back()
42 |
43 | def btnForwardFunc(self) :
44 | self.webEngineView_Test.forward()
45 |
46 | def btnRelaodFunc(self) :
47 | self.webEngineView_Test.reload()
48 |
49 | def btnStopFunc(self) :
50 | self.webEngineView_Test.stop()
51 |
52 |
53 | if __name__ == "__main__" :
54 | app = QApplication(sys.argv)
55 | myWindow = WindowClass()
56 | myWindow.show()
57 | app.exec_()
--------------------------------------------------------------------------------
/02.16 WebEngineView/webEngineViewTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 914
10 | 679
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 10
21 | 891
22 | 571
23 |
24 |
25 |
26 |
27 | https://wikidocs.net/book/2944
28 |
29 |
30 |
31 |
32 |
33 |
34 | 10
35 | 590
36 | 891
37 | 33
38 |
39 |
40 |
41 | -
42 |
43 |
44 | -
45 |
46 |
47 | Go
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | 440
57 | 630
58 | 458
59 | 32
60 |
61 |
62 |
63 | -
64 |
65 |
66 | Back
67 |
68 |
69 |
70 | -
71 |
72 |
73 | Forward
74 |
75 |
76 |
77 | -
78 |
79 |
80 | Reload
81 |
82 |
83 |
84 | -
85 |
86 |
87 | Stop
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | QWebEngineView
97 | QWidget
98 | QtWebEngineWidgets/QWebEngineView
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/02.17 ProgressBar/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.17 ProgressBar/.DS_Store
--------------------------------------------------------------------------------
/02.17 ProgressBar/progressbarTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5.QtGui import *
5 | from PyQt5 import uic
6 |
7 | form_class = uic.loadUiType("progressbarTest.ui")[0]
8 |
9 | class WindowClass(QMainWindow, form_class) :
10 | def __init__(self) :
11 | super().__init__()
12 | self.setupUi(self)
13 |
14 | #ProgressBar의 시그널
15 | self.progressBar_Test.valueChanged.connect(self.printValue)
16 |
17 | #QTimer를 이용하여 매초마다 ProgressBar의 값이 1씩 늘어나게 설정합니다.
18 | #QTimer객체를 만들고, Interval을 1000으로 설정한 후, ProgrssBar의 값이 늘어나게 하는 함수를 연결하고 QTimer를 시작합니다.
19 | #QTimer에 대한 설명은 02.17.01 QTimer에서 보실 수 있습니다.
20 | self.timerVar = QTimer()
21 | self.timerVar.setInterval(1000)
22 | self.timerVar.timeout.connect(self.progressBarTimer)
23 | self.timerVar.start()
24 |
25 | def progressBarTimer(self) :
26 | self.time = self.progressBar_Test.value()
27 | self.time += 1
28 | self.progressBar_Test.setValue(self.time)
29 |
30 | #ProgressBar의 값이 progressBar의 최댓값 이상이 되면 Timer를 중단시켜 ProgressBar의 값이 더이상 증가하지 않게 합니다.
31 | if self.time >= self.progressBar_Test.maximum() :
32 | self.timerVar.stop()
33 |
34 | def printValue(self) :
35 | print(self.progressBar_Test.value())
36 |
37 | if __name__ == "__main__" :
38 | app = QApplication(sys.argv)
39 | myWindow = WindowClass()
40 | myWindow.show()
41 | app.exec_()
--------------------------------------------------------------------------------
/02.17 ProgressBar/progressbarTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 382
10 | 83
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 30
21 | 361
22 | 23
23 |
24 |
25 |
26 | 0
27 |
28 |
29 | 100
30 |
31 |
32 | 0
33 |
34 |
35 | true
36 |
37 |
38 | Qt::Horizontal
39 |
40 |
41 | false
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/02.18 List Widget/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.18 List Widget/.DS_Store
--------------------------------------------------------------------------------
/02.18 List Widget/listwidgetTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5.QtGui import *
5 | from PyQt5 import uic
6 |
7 | form_class = uic.loadUiType("listwidgetTest.ui")[0]
8 |
9 | class WindowClass(QMainWindow, form_class) :
10 | def __init__(self) :
11 | super().__init__()
12 | self.setupUi(self)
13 |
14 | #ListWidget의 시그널
15 | self.listWidget_Test.itemClicked.connect(self.chkItemClicked)
16 | self.listWidget_Test.itemDoubleClicked.connect(self.chkItemDoubleClicked)
17 | self.listWidget_Test.currentItemChanged.connect(self.chkCurrentItemChanged)
18 |
19 | #버튼에 기능 연결
20 | self.btn_addItem.clicked.connect(self.addListWidget)
21 | self.btn_insertItem.clicked.connect(self.insertListWidget)
22 |
23 | self.btn_printItem.clicked.connect(self.printCurrentItem)
24 | self.btn_printMultiItems.clicked.connect(self.printMultiItems)
25 | self.btn_removeItem.clicked.connect(self.removeCurrentItem)
26 | self.btn_clearItem.clicked.connect(self.clearItem)
27 |
28 | #ListWidget의 시그널에 연결된 함수들
29 | def chkItemClicked(self) :
30 | print(self.listWidget_Test.currentItem().text())
31 |
32 | def chkItemDoubleClicked(self) :
33 | print(str(self.listWidget_Test.currentRow()) + " : " + self.listWidget_Test.currentItem().text())
34 |
35 | def chkCurrentItemChanged(self) :
36 | print("Current Row : " + str(self.listWidget_Test.currentRow()))
37 |
38 | #항목을 추가, 삽입하는 함수들
39 | def addListWidget(self) :
40 | self.addItemText = self.line_addItem.text()
41 | self.listWidget_Test.addItem(self.addItemText)
42 |
43 | def insertListWidget(self) :
44 | self.insertRow = self.spin_insertRow.value()
45 | self.insertText = self.line_insertItem.text()
46 | self.listWidget_Test.insertItem(self.insertRow, self.insertText)
47 |
48 | #Button Function
49 | def printCurrentItem(self) :
50 | print(self.listWidget_Test.currentItem().text())
51 |
52 | def printMultiItems(self) :
53 | #여러개를 선택했을 때, selectedItems()를 이용하여 선택한 항목을 List의 형태로 반환받습니다.
54 | #그 후, for문을 이용하여 선택된 항목을 출력합니다.
55 | #출력할 때, List안에는 QListWidgetItem객체가 저장되어 있으므로, .text()함수를 이용하여 문자열로 변환해야 합니다.
56 | self.selectedList = self.listWidget_Test.selectedItems()
57 | for i in self.selectedList :
58 | print(i.text())
59 |
60 | def removeCurrentItem(self) :
61 | #ListWidget에서 현재 선택한 항목을 삭제할 때는 선택한 항목의 줄을 반환한 후, takeItem함수를 이용해 삭제합니다.
62 | self.removeItemRow = self.listWidget_Test.currentRow()
63 | self.listWidget_Test.takeItem(self.removeItemRow)
64 |
65 | def clearItem(self) :
66 | self.listWidget_Test.clear()
67 |
68 |
69 | if __name__ == "__main__" :
70 | app = QApplication(sys.argv)
71 | myWindow = WindowClass()
72 | myWindow.show()
73 | app.exec_()
--------------------------------------------------------------------------------
/02.18 List Widget/listwidgetTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 401
10 | 317
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 10
21 | 381
22 | 171
23 |
24 |
25 |
26 | QAbstractItemView::NoDragDrop
27 |
28 |
29 | QAbstractItemView::MultiSelection
30 |
31 |
32 | false
33 |
34 | -
35 |
36 | 1st Item
37 |
38 |
39 | -
40 |
41 | 2nd Item
42 |
43 |
44 | -
45 |
46 | 3rd Item
47 |
48 |
49 |
50 |
51 |
52 |
53 | 10
54 | 230
55 | 381
56 | 36
57 |
58 |
59 |
60 | -
61 |
62 |
63 | Insert Item
64 |
65 |
66 |
67 | -
68 |
69 |
70 | -
71 |
72 |
73 | Insert
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | 10
83 | 190
84 | 381
85 | 33
86 |
87 |
88 |
89 | -
90 |
91 |
92 | Add Item
93 |
94 |
95 |
96 | -
97 |
98 |
99 | add
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | 10
109 | 270
110 | 381
111 | 32
112 |
113 |
114 |
115 | -
116 |
117 |
118 | Print
119 |
120 |
121 |
122 | -
123 |
124 |
125 | Print_Multi
126 |
127 |
128 |
129 | -
130 |
131 |
132 | Remove
133 |
134 |
135 |
136 | -
137 |
138 |
139 | Clear
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/02.19. Table Widget/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.19. Table Widget/.DS_Store
--------------------------------------------------------------------------------
/02.19. Table Widget/tablewidgetTest.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from PyQt5.QtWidgets import *
3 | from PyQt5.QtCore import *
4 | from PyQt5.QtGui import *
5 | from PyQt5 import uic
6 |
7 | form_class = uic.loadUiType("tablewidgetTest.ui")[0]
8 |
9 | class WindowClass(QMainWindow, form_class) :
10 | def __init__(self) :
11 | super().__init__()
12 | self.setupUi(self)
13 |
14 | self.tableWidget_Test.cellChanged.connect(self.cellChangeFunc)
15 |
16 | def cellChangeFunc(self) :
17 | print("cellChanged")
18 |
19 |
20 | if __name__ == "__main__" :
21 | app = QApplication(sys.argv)
22 | myWindow = WindowClass()
23 | myWindow.show()
24 | app.exec_()
--------------------------------------------------------------------------------
/02.19. Table Widget/tablewidgetTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 401
10 | 455
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 10
20 | 260
21 | 381
22 | 36
23 |
24 |
25 |
26 | -
27 |
28 |
29 | Insert Item
30 |
31 |
32 |
33 | -
34 |
35 |
36 | -
37 |
38 |
39 | Insert
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 10
49 | 220
50 | 381
51 | 33
52 |
53 |
54 |
55 | -
56 |
57 |
58 | Add Item
59 |
60 |
61 |
62 | -
63 |
64 |
65 | add
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | 10
75 | 300
76 | 381
77 | 32
78 |
79 |
80 |
81 | -
82 |
83 |
84 | Print
85 |
86 |
87 |
88 | -
89 |
90 |
91 | Print_Multi
92 |
93 |
94 |
95 | -
96 |
97 |
98 | Remove
99 |
100 |
101 |
102 | -
103 |
104 |
105 | Clear
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | 10
115 | 10
116 | 381
117 | 201
118 |
119 |
120 |
121 | QAbstractItemView::InternalMove
122 |
123 |
124 | false
125 |
126 |
127 | QAbstractItemView::SelectItems
128 |
129 |
130 | false
131 |
132 |
133 | 4
134 |
135 |
136 |
137 | 이세빈
138 |
139 |
140 |
141 |
142 | 김민수
143 |
144 |
145 |
146 |
147 | 홍길동
148 |
149 |
150 |
151 |
152 | 이석준
153 |
154 |
155 |
156 |
157 | 학번
158 |
159 |
160 |
161 |
162 | 학부
163 |
164 |
165 | -
166 |
167 | 20170001
168 |
169 |
170 | -
171 |
172 | 글로벌미디어학부
173 |
174 |
175 | -
176 |
177 | 20170002
178 |
179 |
180 | -
181 |
182 | 전자정보공학부
183 |
184 |
185 | -
186 |
187 | 20180003
188 |
189 |
190 | -
191 |
192 | 소프트웨어학부
193 |
194 |
195 | -
196 |
197 | 20190004
198 |
199 |
200 | -
201 |
202 | 컴퓨터학부
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
--------------------------------------------------------------------------------
/02.20 Container/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/02.20 Container/.DS_Store
--------------------------------------------------------------------------------
/02.20 Container/containerTest.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | Dialog
4 |
5 |
6 |
7 | 0
8 | 0
9 | 593
10 | 156
11 |
12 |
13 |
14 | Dialog
15 |
16 |
17 |
18 |
19 | 200
20 | 20
21 | 131
22 | 111
23 |
24 |
25 |
26 | true
27 |
28 |
29 |
30 |
31 | 0
32 | 0
33 | 112
34 | 157
35 |
36 |
37 |
38 | -
39 |
40 |
41 | Button1
42 |
43 |
44 |
45 | -
46 |
47 |
48 | Button2
49 |
50 |
51 |
52 | -
53 |
54 |
55 | Button3
56 |
57 |
58 |
59 | -
60 |
61 |
62 | Button4
63 |
64 |
65 |
66 | -
67 |
68 |
69 | Button5
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 | 10
80 | 20
81 | 171
82 | 111
83 |
84 |
85 |
86 | GroupBox
87 |
88 |
89 |
90 |
91 | 10
92 | 30
93 | 75
94 | 23
95 |
96 |
97 |
98 | PushButton
99 |
100 |
101 |
102 |
103 |
104 | 110
105 | 80
106 | 56
107 | 12
108 |
109 |
110 |
111 | TextLabel
112 |
113 |
114 |
115 |
116 |
117 |
118 | 350
119 | 20
120 | 221
121 | 111
122 |
123 |
124 |
125 | QTabWidget::North
126 |
127 |
128 | 0
129 |
130 |
131 |
132 | Tab 1
133 |
134 |
135 |
136 |
137 | 0
138 | 10
139 | 121
140 | 16
141 |
142 |
143 |
144 | 이 탭은 Tab 1 입니다.
145 |
146 |
147 |
148 |
149 |
150 | Tab 2
151 |
152 |
153 |
154 |
155 | 0
156 | 10
157 | 121
158 | 16
159 |
160 |
161 |
162 | 이 탭은 Tab 2 입니다.
163 |
164 |
165 |
166 |
167 |
168 | Tab 3
169 |
170 |
171 |
172 |
173 | 10
174 | 10
175 | 121
176 | 16
177 |
178 |
179 |
180 | 이 탭은 Tab 3 입니다.
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
--------------------------------------------------------------------------------
/etc/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/etc/.DS_Store
--------------------------------------------------------------------------------
/etc/02.17.03 QProgressBar SameMinMax.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SebinLee/PyQt5forBeginner/2a480395b95349cd2d660faa52b1a46065f9e450/etc/02.17.03 QProgressBar SameMinMax.gif
--------------------------------------------------------------------------------