Skip to content

indentation fixed #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Post-2(QtCore)/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@


class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__()
self.set_settings()
self.create_widgets()
def __init__(self, parent=None):
super(Window, self).__init__()
self.set_settings()
self.create_widgets()

def set_settings(self):
self.resize(350,200)
def set_settings(self):
self.resize(350,200)

def create_widgets(self):
self.progress_bar = QProgressBar(self)
self.progress_bar.setFixedWidth(300)
self.progress_bar.move(50,80)
#timer creating
self.timer = QBasicTimer()
self.step = 0
self.timer.start(100, self)
def create_widgets(self):
self.progress_bar = QProgressBar(self)
self.progress_bar.setFixedWidth(300)
self.progress_bar.move(50,80)
#timer creating
self.timer = QBasicTimer()
self.step = 0
self.timer.start(100, self)

def timerEvent(self, e):
if self.step >= 100:
self.timer.stop()
def timerEvent(self, e):
if self.step >= 100:
self.timer.stop()

self.step += 1
self.progress_bar.setValue(self.step)
self.step += 1
self.progress_bar.setValue(self.step)

root = QApplication(sys.argv)
app = Window()
Expand Down
46 changes: 23 additions & 23 deletions Post-2(QtCore)/signal_emited.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@


class CustomLabel(QLabel):
def __init__(self, parent=None):
super(CustomLabel, self).__init__(parent)
self.setMouseTracking(True)
def __init__(self, parent=None):
super(CustomLabel, self).__init__(parent)
self.setMouseTracking(True)

def mousePressEvent(self, e):
img, re = QFileDialog.getOpenFileName(self,"Selecionar Arquivo",
filter="All(*.png *.jpg)")
if re:
self.setPixmap(QPixmap(img).scaled(250,150,
Qt.KeepAspectRatio))
def mousePressEvent(self, e):
img, re = QFileDialog.getOpenFileName(self,"Selecionar Arquivo",
filter="All(*.png *.jpg)")
if re:
self.setPixmap(QPixmap(img).scaled(250,150,
Qt.KeepAspectRatio))

def mouseMoveEvent(self, e):
QApplication.setOverrideCursor(Qt.PointingHandCursor)
def mouseMoveEvent(self, e):
QApplication.setOverrideCursor(Qt.PointingHandCursor)

def leaveEvent(self, e):
QApplication.setOverrideCursor(Qt.ArrowCursor)
def leaveEvent(self, e):
QApplication.setOverrideCursor(Qt.ArrowCursor)

class HandlerWindow(QWidget):
def __init__(self, parent=None):
super(HandlerWindow, self).__init__()
self.resize(300,350)
self.label = CustomLabel(self)
self.label.setPixmap(QPixmap("imgs/default-user.png").scaled(250,150,
Qt.KeepAspectRatio))
def __init__(self, parent=None):
super(HandlerWindow, self).__init__()
self.resize(300,350)
self.label = CustomLabel(self)
self.label.setPixmap(QPixmap("imgs/default-user.png").scaled(250,150,
Qt.KeepAspectRatio))

if __name__ == "__main__":
root = QApplication(sys.argv)
app = HandlerWindow()
app.show()
sys.exit(root.exec_())
root = QApplication(sys.argv)
app = HandlerWindow()
app.show()
sys.exit(root.exec_())
104 changes: 52 additions & 52 deletions Post-2(QtCore)/signalsslots.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton, QLineEdit,
QHBoxLayout, QMessageBox, QRadioButton,
QGroupBox, QVBoxLayout)
QHBoxLayout, QMessageBox, QRadioButton,
QGroupBox, QVBoxLayout)
import sys


class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__()
# first widgets
self.button = QPushButton("Exibir mensagem")
self.button.setAcceptDrops(True)
self.button.clicked.connect(self.exibir)
self.line_edit = QLineEdit()
# group box of widgets
self.groupbox = QGroupBox("Opções de Diálogo")
# options
self.option_information = QRadioButton("Information")
self.option_information.setChecked(True)
self.option_warning = QRadioButton("Warning")
self.option_critical = QRadioButton("Critical")
# layout of items of group box
self.layout_options = QVBoxLayout()
self.layout_options.addWidget(self.option_information)
self.layout_options.addWidget(self.option_critical)
self.layout_options.addWidget(self.option_warning)
self.groupbox.setLayout(self.layout_options)
# layout of QPushButton e QLineEdit
self.layout_first_widgets = QHBoxLayout()
self.layout_first_widgets.addWidget(self.line_edit)
self.layout_first_widgets.addWidget(self.button)
# main layout
self.layout_master = QVBoxLayout()
self.layout_master.addLayout(self.layout_first_widgets)
self.layout_master.addWidget(self.groupbox)
self.setLayout(self.layout_master)
def __init__(self, parent=None):
super(Window, self).__init__()
# first widgets
self.button = QPushButton("Exibir mensagem")
self.button.setAcceptDrops(True)
self.button.clicked.connect(self.exibir)
self.line_edit = QLineEdit()
# group box of widgets
self.groupbox = QGroupBox("Opções de Diálogo")
# options
self.option_information = QRadioButton("Information")
self.option_information.setChecked(True)
self.option_warning = QRadioButton("Warning")
self.option_critical = QRadioButton("Critical")
# layout of items of group box
self.layout_options = QVBoxLayout()
self.layout_options.addWidget(self.option_information)
self.layout_options.addWidget(self.option_critical)
self.layout_options.addWidget(self.option_warning)
self.groupbox.setLayout(self.layout_options)
# layout of QPushButton e QLineEdit
self.layout_first_widgets = QHBoxLayout()
self.layout_first_widgets.addWidget(self.line_edit)
self.layout_first_widgets.addWidget(self.button)
# main layout
self.layout_master = QVBoxLayout()
self.layout_master.addLayout(self.layout_first_widgets)
self.layout_master.addWidget(self.groupbox)
self.setLayout(self.layout_master)

def exibir(self):
self.text = self.line_edit.text()
if self.option_information.isChecked():
self.messsage_box = QMessageBox.information(self,"Exemplo 1",
self.text)
elif self.option_warning.isChecked():
self.messsage_box = QMessageBox.warning(self,"Exemplo 1",
self.text)
else:
self.messsage_box = QMessageBox.critical(self,"Exemplo 1",
self.text)
def exibir(self):
self.text = self.line_edit.text()
if self.option_information.isChecked():
self.messsage_box = QMessageBox.information(self,"Exemplo 1",
self.text)
elif self.option_warning.isChecked():
self.messsage_box = QMessageBox.warning(self,"Exemplo 1",
self.text)
else:
self.messsage_box = QMessageBox.critical(self,"Exemplo 1",
self.text)

def closeEvent(self, e):
e.ignore()
question_close = QMessageBox.question(self, "Fechamento",
"Deseja realmente fechar a aplicação?",
QMessageBox.Yes, QMessageBox.No)
if question_close == QMessageBox.Yes:
exit(0)
def closeEvent(self, e):
e.ignore()
question_close = QMessageBox.question(self, "Fechamento",
"Deseja realmente fechar a aplicação?",
QMessageBox.Yes, QMessageBox.No)
if question_close == QMessageBox.Yes:
exit(0)

if __name__ == "__main__":
root = QApplication([])
app = Window()
app.show()
sys.exit(root.exec_())
app = Window()
app.show()
sys.exit(root.exec_())
22 changes: 11 additions & 11 deletions Post-2(QtCore)/threads_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import sys

class Loop(QThread):
def run(self):
while True:
print ("Estamos no loop")
def run(self):
while True:
print ("Estamos no loop")

class Window(QWidget):
def __init__(self, parent=None):
super(Window, self).__init__()
self.resize(200, 200)
self.button = QPushButton("Iniciar loop", self)
self.button.clicked.connect(self.start_loop)
def __init__(self, parent=None):
super(Window, self).__init__()
self.resize(200, 200)
self.button = QPushButton("Iniciar loop", self)
self.button.clicked.connect(self.start_loop)

def start_loop(self):
self.thread_loop = Loop()
self.thread_loop.start()
def start_loop(self):
self.thread_loop = Loop()
self.thread_loop.start()


root = QApplication([])
Expand Down