Aug-01-2020, 02:46 PM
Do you create your examples with a designer?
I think using setGeometry for all widgets is not a good idea.
Shrinking the window has the effect that your widgets are no longer visible.
I changed your ProgressBar Example this way
I think using setGeometry for all widgets is not a good idea.
Shrinking the window has the effect that your widgets are no longer visible.
I changed your ProgressBar Example this way
from PyQt5 import QtWidgets from PyQt5.QtWidgets import QApplication, QMainWindow import sys def update(): reset() completed = 0 while completed < 100: completed += 0.0001 prog_bar.setValue(completed) def reset(): value = 0 prog_bar.setValue(value) app = QApplication(sys.argv) win = QMainWindow() win.setGeometry(400,400,300,150) win.setWindowTitle("CodersLegacy") prog_bar = QtWidgets.QProgressBar() prog_bar.setFixedHeight(26) prog_bar.setValue(0) button = QtWidgets.QPushButton(win) button.setText("Update") button.setFixedWidth(80) button.clicked.connect(update) reset_button = QtWidgets.QPushButton() reset_button.setText("Reset") reset_button.setFixedWidth(80) reset_button.clicked.connect(reset) prog_barwid = QtWidgets.QVBoxLayout() prog_barwid.addWidget(prog_bar) btn_wid = QtWidgets.QHBoxLayout() btn_wid.addWidget(button) btn_wid.addWidget(reset_button) layout = QtWidgets.QVBoxLayout() layout.addLayout(prog_barwid) layout.addLayout(btn_wid) main_wid = QtWidgets.QWidget() main_wid.setLayout(layout) main_wid.setFixedWidth(280) main_wid.setFixedHeight(100) win.setCentralWidget(main_wid) win.show() sys.exit(app.exec_())