Skip to content

Commit 73fba60

Browse files
Merge pull request #1 from wilfilho/master
indentation fixed
2 parents 7c34b9f + c0e0511 commit 73fba60

File tree

4 files changed

+105
-105
lines changed

4 files changed

+105
-105
lines changed

Post-2(QtCore)/progress_bar.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@
44

55

66
class Window(QWidget):
7-
def __init__(self, parent=None):
8-
super(Window, self).__init__()
9-
self.set_settings()
10-
self.create_widgets()
7+
def __init__(self, parent=None):
8+
super(Window, self).__init__()
9+
self.set_settings()
10+
self.create_widgets()
1111

12-
def set_settings(self):
13-
self.resize(350,200)
12+
def set_settings(self):
13+
self.resize(350,200)
1414

15-
def create_widgets(self):
16-
self.progress_bar = QProgressBar(self)
17-
self.progress_bar.setFixedWidth(300)
18-
self.progress_bar.move(50,80)
19-
#timer creating
20-
self.timer = QBasicTimer()
21-
self.step = 0
22-
self.timer.start(100, self)
15+
def create_widgets(self):
16+
self.progress_bar = QProgressBar(self)
17+
self.progress_bar.setFixedWidth(300)
18+
self.progress_bar.move(50,80)
19+
#timer creating
20+
self.timer = QBasicTimer()
21+
self.step = 0
22+
self.timer.start(100, self)
2323

24-
def timerEvent(self, e):
25-
if self.step >= 100:
26-
self.timer.stop()
24+
def timerEvent(self, e):
25+
if self.step >= 100:
26+
self.timer.stop()
2727

28-
self.step += 1
29-
self.progress_bar.setValue(self.step)
28+
self.step += 1
29+
self.progress_bar.setValue(self.step)
3030

3131
root = QApplication(sys.argv)
3232
app = Window()

Post-2(QtCore)/signal_emited.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,33 @@
55

66

77
class CustomLabel(QLabel):
8-
def __init__(self, parent=None):
9-
super(CustomLabel, self).__init__(parent)
10-
self.setMouseTracking(True)
8+
def __init__(self, parent=None):
9+
super(CustomLabel, self).__init__(parent)
10+
self.setMouseTracking(True)
1111

12-
def mousePressEvent(self, e):
13-
img, re = QFileDialog.getOpenFileName(self,"Selecionar Arquivo",
14-
filter="All(*.png *.jpg)")
15-
if re:
16-
self.setPixmap(QPixmap(img).scaled(250,150,
17-
Qt.KeepAspectRatio))
12+
def mousePressEvent(self, e):
13+
img, re = QFileDialog.getOpenFileName(self,"Selecionar Arquivo",
14+
filter="All(*.png *.jpg)")
15+
if re:
16+
self.setPixmap(QPixmap(img).scaled(250,150,
17+
Qt.KeepAspectRatio))
1818

19-
def mouseMoveEvent(self, e):
20-
QApplication.setOverrideCursor(Qt.PointingHandCursor)
19+
def mouseMoveEvent(self, e):
20+
QApplication.setOverrideCursor(Qt.PointingHandCursor)
2121

22-
def leaveEvent(self, e):
23-
QApplication.setOverrideCursor(Qt.ArrowCursor)
22+
def leaveEvent(self, e):
23+
QApplication.setOverrideCursor(Qt.ArrowCursor)
2424

2525
class HandlerWindow(QWidget):
26-
def __init__(self, parent=None):
27-
super(HandlerWindow, self).__init__()
28-
self.resize(300,350)
29-
self.label = CustomLabel(self)
30-
self.label.setPixmap(QPixmap("imgs/default-user.png").scaled(250,150,
31-
Qt.KeepAspectRatio))
26+
def __init__(self, parent=None):
27+
super(HandlerWindow, self).__init__()
28+
self.resize(300,350)
29+
self.label = CustomLabel(self)
30+
self.label.setPixmap(QPixmap("imgs/default-user.png").scaled(250,150,
31+
Qt.KeepAspectRatio))
3232

3333
if __name__ == "__main__":
34-
root = QApplication(sys.argv)
35-
app = HandlerWindow()
36-
app.show()
37-
sys.exit(root.exec_())
34+
root = QApplication(sys.argv)
35+
app = HandlerWindow()
36+
app.show()
37+
sys.exit(root.exec_())

Post-2(QtCore)/signalsslots.py

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton, QLineEdit,
2-
QHBoxLayout, QMessageBox, QRadioButton,
3-
QGroupBox, QVBoxLayout)
2+
QHBoxLayout, QMessageBox, QRadioButton,
3+
QGroupBox, QVBoxLayout)
44
import sys
55

66

77
class Window(QWidget):
8-
def __init__(self, parent=None):
9-
super(Window, self).__init__()
10-
# first widgets
11-
self.button = QPushButton("Exibir mensagem")
12-
self.button.setAcceptDrops(True)
13-
self.button.clicked.connect(self.exibir)
14-
self.line_edit = QLineEdit()
15-
# group box of widgets
16-
self.groupbox = QGroupBox("Opções de Diálogo")
17-
# options
18-
self.option_information = QRadioButton("Information")
19-
self.option_information.setChecked(True)
20-
self.option_warning = QRadioButton("Warning")
21-
self.option_critical = QRadioButton("Critical")
22-
# layout of items of group box
23-
self.layout_options = QVBoxLayout()
24-
self.layout_options.addWidget(self.option_information)
25-
self.layout_options.addWidget(self.option_critical)
26-
self.layout_options.addWidget(self.option_warning)
27-
self.groupbox.setLayout(self.layout_options)
28-
# layout of QPushButton e QLineEdit
29-
self.layout_first_widgets = QHBoxLayout()
30-
self.layout_first_widgets.addWidget(self.line_edit)
31-
self.layout_first_widgets.addWidget(self.button)
32-
# main layout
33-
self.layout_master = QVBoxLayout()
34-
self.layout_master.addLayout(self.layout_first_widgets)
35-
self.layout_master.addWidget(self.groupbox)
36-
self.setLayout(self.layout_master)
8+
def __init__(self, parent=None):
9+
super(Window, self).__init__()
10+
# first widgets
11+
self.button = QPushButton("Exibir mensagem")
12+
self.button.setAcceptDrops(True)
13+
self.button.clicked.connect(self.exibir)
14+
self.line_edit = QLineEdit()
15+
# group box of widgets
16+
self.groupbox = QGroupBox("Opções de Diálogo")
17+
# options
18+
self.option_information = QRadioButton("Information")
19+
self.option_information.setChecked(True)
20+
self.option_warning = QRadioButton("Warning")
21+
self.option_critical = QRadioButton("Critical")
22+
# layout of items of group box
23+
self.layout_options = QVBoxLayout()
24+
self.layout_options.addWidget(self.option_information)
25+
self.layout_options.addWidget(self.option_critical)
26+
self.layout_options.addWidget(self.option_warning)
27+
self.groupbox.setLayout(self.layout_options)
28+
# layout of QPushButton e QLineEdit
29+
self.layout_first_widgets = QHBoxLayout()
30+
self.layout_first_widgets.addWidget(self.line_edit)
31+
self.layout_first_widgets.addWidget(self.button)
32+
# main layout
33+
self.layout_master = QVBoxLayout()
34+
self.layout_master.addLayout(self.layout_first_widgets)
35+
self.layout_master.addWidget(self.groupbox)
36+
self.setLayout(self.layout_master)
3737

38-
def exibir(self):
39-
self.text = self.line_edit.text()
40-
if self.option_information.isChecked():
41-
self.messsage_box = QMessageBox.information(self,"Exemplo 1",
42-
self.text)
43-
elif self.option_warning.isChecked():
44-
self.messsage_box = QMessageBox.warning(self,"Exemplo 1",
45-
self.text)
46-
else:
47-
self.messsage_box = QMessageBox.critical(self,"Exemplo 1",
48-
self.text)
38+
def exibir(self):
39+
self.text = self.line_edit.text()
40+
if self.option_information.isChecked():
41+
self.messsage_box = QMessageBox.information(self,"Exemplo 1",
42+
self.text)
43+
elif self.option_warning.isChecked():
44+
self.messsage_box = QMessageBox.warning(self,"Exemplo 1",
45+
self.text)
46+
else:
47+
self.messsage_box = QMessageBox.critical(self,"Exemplo 1",
48+
self.text)
4949

50-
def closeEvent(self, e):
51-
e.ignore()
52-
question_close = QMessageBox.question(self, "Fechamento",
53-
"Deseja realmente fechar a aplicação?",
54-
QMessageBox.Yes, QMessageBox.No)
55-
if question_close == QMessageBox.Yes:
56-
exit(0)
50+
def closeEvent(self, e):
51+
e.ignore()
52+
question_close = QMessageBox.question(self, "Fechamento",
53+
"Deseja realmente fechar a aplicação?",
54+
QMessageBox.Yes, QMessageBox.No)
55+
if question_close == QMessageBox.Yes:
56+
exit(0)
5757

5858
if __name__ == "__main__":
5959
root = QApplication([])
60-
app = Window()
61-
app.show()
62-
sys.exit(root.exec_())
60+
app = Window()
61+
app.show()
62+
sys.exit(root.exec_())

Post-2(QtCore)/threads_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
import sys
44

55
class Loop(QThread):
6-
def run(self):
7-
while True:
8-
print ("Estamos no loop")
6+
def run(self):
7+
while True:
8+
print ("Estamos no loop")
99

1010
class Window(QWidget):
11-
def __init__(self, parent=None):
12-
super(Window, self).__init__()
13-
self.resize(200, 200)
14-
self.button = QPushButton("Iniciar loop", self)
15-
self.button.clicked.connect(self.start_loop)
11+
def __init__(self, parent=None):
12+
super(Window, self).__init__()
13+
self.resize(200, 200)
14+
self.button = QPushButton("Iniciar loop", self)
15+
self.button.clicked.connect(self.start_loop)
1616

17-
def start_loop(self):
18-
self.thread_loop = Loop()
19-
self.thread_loop.start()
17+
def start_loop(self):
18+
self.thread_loop = Loop()
19+
self.thread_loop.start()
2020

2121

2222
root = QApplication([])

0 commit comments

Comments
 (0)