Skip to content

Commit b154d20

Browse files
committed
updates from atom editor
pep8 added todachoppa.png fixed the waitbar propagation on Mac OS x
1 parent 97ea648 commit b154d20

8 files changed

Lines changed: 32 additions & 30 deletions

pyqt5_lesson_02.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from PyQt5.QtGui import QIcon
1515
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow
1616

17+
1718
class window(QMainWindow):
1819

1920
def __init__(self):

pyqt5_lesson_03.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def home(self):
3232
btn.move(100, 100)
3333
self.show()
3434

35+
3536
def run():
3637
app = QApplication(sys.argv)
3738
Gui = window()

pyqt5_lesson_04.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ def __init__(self):
2828
def home(self):
2929
btn = QPushButton('quit', self)
3030
btn.clicked.connect(self.close_application)
31-
32-
btn.resize(btn.sizeHint()) #set to acceptable size automatic
31+
btn.resize(btn.sizeHint()) # set to acceptable size automatic
3332
btn.move(0, 0)
3433
self.show()
3534

3635
def close_application(self):
3736
print('whooo so custom')
3837
sys.exit()
3938

39+
4040
def run():
4141
app = QApplication(sys.argv)
4242
Gui = window()

pyqt5_lesson_06.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from PyQt5.QtCore import QCoreApplication
1515
# from PyQt5.QtGui import *
1616
from PyQt5.QtGui import QIcon
17-
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QAction
17+
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, \
18+
QAction
1819
from PyQt5.uic.properties import QtGui
1920

2021

@@ -37,12 +38,6 @@ def __init__(self):
3738
fileMenu = mainMenu.addMenu('&File')
3839
fileMenu.addAction(extractAction)
3940

40-
extractAction = QAction(QIcon('pic.png'), 'flee the scene', self)
41-
extractAction.triggered.connect(self.close_application)
42-
43-
self.toolBar = self.addToolBar('Extraction')
44-
self.toolBar.addAction(extractAction)
45-
4641
self.home()
4742

4843
def home(self):
@@ -51,6 +46,12 @@ def home(self):
5146
btn.resize(btn.sizeHint())
5247
btn.move(0, 100)
5348

49+
extractAction = QAction(QIcon('todachoppa.png'), 'flee the scene', self)
50+
extractAction.triggered.connect(self.close_application)
51+
52+
self.toolBar = self.addToolBar('Extraction')
53+
self.toolBar.addAction(extractAction)
54+
5455
self.show()
5556

5657
def close_application(self):

pyqt5_lesson_07.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
from PyQt5.QtCore import QCoreApplication
1515
# from PyQt5.QtGui import *
1616
from PyQt5.QtGui import QIcon
17-
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QAction, QMessageBox
18-
from PyQt5.uic.properties import QtGui
17+
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, \
18+
QAction, QMessageBox
19+
# from PyQt5.uic.properties import QtGui
1920

2021

2122
class window(QMainWindow):
@@ -56,8 +57,8 @@ def home(self):
5657
def close_application(self):
5758

5859
choice = QMessageBox.question(self, 'Message',
59-
"Are you sure to quit?", QMessageBox.Yes |
60-
QMessageBox.No, QMessageBox.No)
60+
"Are you sure to quit?", QMessageBox.Yes |
61+
QMessageBox.No, QMessageBox.No)
6162

6263
if choice == QMessageBox.Yes:
6364
print('quit application')

pyqt5_lesson_08.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
import sys
1414
from PyQt5.QtCore import QCoreApplication, Qt
1515
from PyQt5.QtGui import QIcon
16-
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QAction, QMessageBox
16+
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, \
17+
QAction, QMessageBox
1718
from PyQt5.QtWidgets import QCheckBox
1819

1920

20-
2121
class window(QMainWindow):
2222

2323
def __init__(self):
@@ -53,24 +53,23 @@ def home(self):
5353

5454
checkBox = QCheckBox('Enlarge window', self)
5555
# checkBox.toggle() # if you want to be checked in in the begin
56-
checkBox.move(0, 50)
57-
checkBox.stateChanged.connect(self.enlarge_window)
56+
checkBox.move(100, 25)
5857

58+
checkBox.stateChanged.connect(self.enlarge_window)
5959

6060
self.show()
6161

6262
def enlarge_window(self, state):
6363
if state == Qt.Checked:
6464
self.setGeometry(50, 50, 1000, 600)
6565
else:
66-
self.setGeometry(50, 50 , 500, 300)
67-
66+
self.setGeometry(50, 50, 500, 300)
6867

6968
def close_application(self):
7069

7170
choice = QMessageBox.question(self, 'Message',
72-
"Are you sure to quit?", QMessageBox.Yes |
73-
QMessageBox.No, QMessageBox.No)
71+
"Are you sure to quit?", QMessageBox.Yes |
72+
QMessageBox.No, QMessageBox.No)
7473

7574
if choice == QMessageBox.Yes:
7675
print('quit application')

pyqt5_lesson_09.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
import sys
1414
from PyQt5.QtCore import QCoreApplication, Qt
1515
from PyQt5.QtGui import QIcon
16-
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QAction, QMessageBox
16+
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, \
17+
QAction, QMessageBox
1718
from PyQt5.QtWidgets import QCheckBox, QProgressBar
1819

20+
1921
class window(QMainWindow):
2022

2123
def __init__(self):
@@ -61,30 +63,27 @@ def home(self):
6163
self.btn.move(200, 120)
6264
self.btn.clicked.connect(self.download)
6365

64-
6566
self.show()
6667

6768
def download(self):
6869
self.completed = 0
6970

7071
while self.completed < 100:
71-
self.completed += 0.0001
72+
self.completed += 0.00005
7273
self.progress.setValue(self.completed)
73-
74-
74+
QApplication.processEvents() # from stackoverflow
7575

7676
def enlarge_window(self, state):
7777
if state == Qt.Checked:
7878
self.setGeometry(50, 50, 1000, 600)
7979
else:
80-
self.setGeometry(50, 50 , 500, 300)
81-
80+
self.setGeometry(50, 50, 500, 300)
8281

8382
def close_application(self):
8483

8584
choice = QMessageBox.question(self, 'Message',
86-
"Are you sure to quit?", QMessageBox.Yes |
87-
QMessageBox.No, QMessageBox.No)
85+
"Are you sure to quit?", QMessageBox.Yes |
86+
QMessageBox.No, QMessageBox.No)
8887

8988
if choice == QMessageBox.Yes:
9089
print('quit application')

todachoppa.png

6.57 KB
Loading

0 commit comments

Comments
 (0)