Skip to content

Commit e6adf96

Browse files
committed
Fix progress bar not closing
1 parent 9791bae commit e6adf96

4 files changed

Lines changed: 116 additions & 104 deletions

File tree

Developer/LiteIDE.app/LiteIDE

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@ class LiteInstaller(object):
6464
if reply == QtWidgets.QMessageBox.No:
6565
sys.exit(0)
6666

67-
print("Proceeding to install %s from the %s packages" %(self.filename, self.packages))
68-
self.show_install()
67+
print("Proceeding to install %s from the %s packages" %(self.filename, self.packages))
68+
self.show_install()
6969

7070

7171
def show_message(self):
72-
msgBox = QtWidgets.QMessageBox()
72+
self.msgBox = QtWidgets.QMessageBox()
7373

7474
if self.iconfile:
75-
msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
76-
msgBox.setWindowTitle(" ")
77-
msgBox.setText("%s needs to be downloaded before it can be used." % os.path.basename(__file__))
78-
msgBox.setInformativeText("Do you want to download it now?")
79-
# msgBox.setDetailedText("The following packages and their dependencies be installed:\n" + str(self.packages))
75+
self.msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
76+
self.msgBox.setWindowTitle(" ")
77+
self.msgBox.setText("%s needs to be downloaded before it can be used." % os.path.basename(__file__))
78+
self.msgBox.setInformativeText("Do you want to download it now?")
79+
# self.msgBox.setDetailedText("The following packages and their dependencies be installed:\n" + str(self.packages))
8080
print("The following packages and their dependencies be installed:\n" + str(self.packages))
81-
msgBox.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)
82-
msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
83-
return(msgBox.exec())
81+
self.msgBox.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)
82+
self.msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
83+
return(self.msgBox.exec())
8484

8585

8686
def startInstallProcess(self):
@@ -168,6 +168,7 @@ class LiteInstaller(object):
168168

169169

170170
def onProcessFinished(self):
171+
self.progress.setValue(100)
171172
print("Installer script process finished")
172173
# cursor = self.output.textCursor()
173174
# cursor.movePosition(cursor.End)
@@ -178,19 +179,21 @@ class LiteInstaller(object):
178179
executable = os.access(self.filename, os.X_OK)
179180
if exit_code == 0 and executable == True:
180181
# os.execve(self.filename, sys.argv, os.environ) # What sh exec also uses. Leads to issues when files are referenced in relation to the main binary path
182+
self.msgBox.close()
181183
subprocess.call([self.filename] + sys.argv)
184+
sys.exit(0)
182185

183186

184187
def show_install(self):
185-
msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, " ", ("Downloading %s..." % (os.path.basename(__file__))), QtWidgets.QMessageBox.NoButton)
186-
# msgBox.setWindowFlags(QtCore.Qt.CustomizeWindowHint) # Needed for the next line
187-
msgBox.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) # Remove the Close button frim the window decoration; FIXME: Why does this remove the window decorations altogether?
188-
# msgBox.setStyleSheet("QTextEdit{min-width: 500px;}")
189-
msgBox.setStyleSheet("QDialogButtonBox,QTextEdit{min-width: 500px; } QLabel{min-height: 50px;} QProgressBar{min-width: 410px;}") # FIXME: Do this without hardcoding 410px
190-
msgBox.setStandardButtons(QtWidgets.QMessageBox.NoButton)
191-
# msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
192-
msgBox.setDetailedText(" ") # Brings it into existence?
193-
self.details_textedit = msgBox.findChild(QtWidgets.QTextEdit)
188+
self.msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, " ", ("Downloading %s..." % (os.path.basename(__file__))), QtWidgets.QMessageBox.NoButton)
189+
# self.msgBox.setWindowFlags(QtCore.Qt.CustomizeWindowHint) # Needed for the next line
190+
self.msgBox.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) # Remove the Close button frim the window decoration; FIXME: Why does this remove the window decorations altogether?
191+
# self.msgBox.setStyleSheet("QTextEdit{min-width: 500px;}")
192+
self.msgBox.setStyleSheet("QDialogButtonBox,QTextEdit{min-width: 500px; } QLabel{min-height: 50px;} QProgressBar{min-width: 410px;}") # FIXME: Do this without hardcoding 410px
193+
self.msgBox.setStandardButtons(QtWidgets.QMessageBox.NoButton)
194+
# self.msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
195+
self.msgBox.setDetailedText(" ") # Brings it into existence?
196+
self.details_textedit = self.msgBox.findChild(QtWidgets.QTextEdit)
194197

195198
if self.details_textedit is not None:
196199
print("Found QTextEdit for the details")
@@ -199,9 +202,9 @@ class LiteInstaller(object):
199202

200203

201204
if self.iconfile:
202-
msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
205+
self.msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
203206

204-
msgBox.layout().setAlignment(QtCore.Qt.AlignTop)
207+
self.msgBox.layout().setAlignment(QtCore.Qt.AlignTop)
205208

206209

207210
self.progress = QtWidgets.QProgressBar()
@@ -213,14 +216,14 @@ class LiteInstaller(object):
213216
self.progress.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
214217

215218
# Add the progress bar at the bottom (last row + 1) and first column with column span
216-
# msgBox.layout().addWidget(self.progress, msgBox.layout().rowCount(), 0, 1, msgBox.layout().columnCount(), QtCore.Qt.AlignCenter)
217-
msgBox.layout().addWidget(self.progress, 1, 1, 1, msgBox.layout().columnCount(),
219+
# self.msgBox.layout().addWidget(self.progress, self.msgBox.layout().rowCount(), 0, 1, self.msgBox.layout().columnCount(), QtCore.Qt.AlignCenter)
220+
self.msgBox.layout().addWidget(self.progress, 1, 1, 1, self.msgBox.layout().columnCount(),
218221
QtCore.Qt.AlignCenter)
219222

220-
msgBox.layout().addWidget(QtWidgets.QLabel(), 1, 1, 1, msgBox.layout().columnCount(),
223+
self.msgBox.layout().addWidget(QtWidgets.QLabel(), 1, 1, 1, self.msgBox.layout().columnCount(),
221224
QtCore.Qt.AlignCenter)
222225
self.startInstallProcess()
223-
msgBox.exec()
226+
self.msgBox.exec()
224227

225228

226229
def read_file_contents(self, filename):

Developer/PyCharm CE.app/PyCharm CE

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@ class LiteInstaller(object):
6464
if reply == QtWidgets.QMessageBox.No:
6565
sys.exit(0)
6666

67-
print("Proceeding to install %s from the %s packages" %(self.filename, self.packages))
68-
self.show_install()
67+
print("Proceeding to install %s from the %s packages" %(self.filename, self.packages))
68+
self.show_install()
6969

7070

7171
def show_message(self):
72-
msgBox = QtWidgets.QMessageBox()
72+
self.msgBox = QtWidgets.QMessageBox()
7373

7474
if self.iconfile:
75-
msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
76-
msgBox.setWindowTitle(" ")
77-
msgBox.setText("%s needs to be downloaded before it can be used." % os.path.basename(__file__))
78-
msgBox.setInformativeText("Do you want to download it now?")
79-
# msgBox.setDetailedText("The following packages and their dependencies be installed:\n" + str(self.packages))
75+
self.msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
76+
self.msgBox.setWindowTitle(" ")
77+
self.msgBox.setText("%s needs to be downloaded before it can be used." % os.path.basename(__file__))
78+
self.msgBox.setInformativeText("Do you want to download it now?")
79+
# self.msgBox.setDetailedText("The following packages and their dependencies be installed:\n" + str(self.packages))
8080
print("The following packages and their dependencies be installed:\n" + str(self.packages))
81-
msgBox.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)
82-
msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
83-
return(msgBox.exec())
81+
self.msgBox.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)
82+
self.msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
83+
return(self.msgBox.exec())
8484

8585

8686
def startInstallProcess(self):
@@ -168,6 +168,7 @@ class LiteInstaller(object):
168168

169169

170170
def onProcessFinished(self):
171+
self.progress.setValue(100)
171172
print("Installer script process finished")
172173
# cursor = self.output.textCursor()
173174
# cursor.movePosition(cursor.End)
@@ -178,19 +179,21 @@ class LiteInstaller(object):
178179
executable = os.access(self.filename, os.X_OK)
179180
if exit_code == 0 and executable == True:
180181
# os.execve(self.filename, sys.argv, os.environ) # What sh exec also uses. Leads to issues when files are referenced in relation to the main binary path
182+
self.msgBox.close()
181183
subprocess.call([self.filename] + sys.argv)
184+
sys.exit(0)
182185

183186

184187
def show_install(self):
185-
msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, " ", ("Downloading %s..." % (os.path.basename(__file__))), QtWidgets.QMessageBox.NoButton)
186-
# msgBox.setWindowFlags(QtCore.Qt.CustomizeWindowHint) # Needed for the next line
187-
msgBox.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) # Remove the Close button frim the window decoration; FIXME: Why does this remove the window decorations altogether?
188-
# msgBox.setStyleSheet("QTextEdit{min-width: 500px;}")
189-
msgBox.setStyleSheet("QDialogButtonBox,QTextEdit{min-width: 500px; } QLabel{min-height: 50px;} QProgressBar{min-width: 410px;}") # FIXME: Do this without hardcoding 410px
190-
msgBox.setStandardButtons(QtWidgets.QMessageBox.NoButton)
191-
# msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
192-
msgBox.setDetailedText(" ") # Brings it into existence?
193-
self.details_textedit = msgBox.findChild(QtWidgets.QTextEdit)
188+
self.msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, " ", ("Downloading %s..." % (os.path.basename(__file__))), QtWidgets.QMessageBox.NoButton)
189+
# self.msgBox.setWindowFlags(QtCore.Qt.CustomizeWindowHint) # Needed for the next line
190+
self.msgBox.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) # Remove the Close button frim the window decoration; FIXME: Why does this remove the window decorations altogether?
191+
# self.msgBox.setStyleSheet("QTextEdit{min-width: 500px;}")
192+
self.msgBox.setStyleSheet("QDialogButtonBox,QTextEdit{min-width: 500px; } QLabel{min-height: 50px;} QProgressBar{min-width: 410px;}") # FIXME: Do this without hardcoding 410px
193+
self.msgBox.setStandardButtons(QtWidgets.QMessageBox.NoButton)
194+
# self.msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
195+
self.msgBox.setDetailedText(" ") # Brings it into existence?
196+
self.details_textedit = self.msgBox.findChild(QtWidgets.QTextEdit)
194197

195198
if self.details_textedit is not None:
196199
print("Found QTextEdit for the details")
@@ -199,9 +202,9 @@ class LiteInstaller(object):
199202

200203

201204
if self.iconfile:
202-
msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
205+
self.msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
203206

204-
msgBox.layout().setAlignment(QtCore.Qt.AlignTop)
207+
self.msgBox.layout().setAlignment(QtCore.Qt.AlignTop)
205208

206209

207210
self.progress = QtWidgets.QProgressBar()
@@ -213,14 +216,14 @@ class LiteInstaller(object):
213216
self.progress.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
214217

215218
# Add the progress bar at the bottom (last row + 1) and first column with column span
216-
# msgBox.layout().addWidget(self.progress, msgBox.layout().rowCount(), 0, 1, msgBox.layout().columnCount(), QtCore.Qt.AlignCenter)
217-
msgBox.layout().addWidget(self.progress, 1, 1, 1, msgBox.layout().columnCount(),
219+
# self.msgBox.layout().addWidget(self.progress, self.msgBox.layout().rowCount(), 0, 1, self.msgBox.layout().columnCount(), QtCore.Qt.AlignCenter)
220+
self.msgBox.layout().addWidget(self.progress, 1, 1, 1, self.msgBox.layout().columnCount(),
218221
QtCore.Qt.AlignCenter)
219222

220-
msgBox.layout().addWidget(QtWidgets.QLabel(), 1, 1, 1, msgBox.layout().columnCount(),
223+
self.msgBox.layout().addWidget(QtWidgets.QLabel(), 1, 1, 1, self.msgBox.layout().columnCount(),
221224
QtCore.Qt.AlignCenter)
222225
self.startInstallProcess()
223-
msgBox.exec()
226+
self.msgBox.exec()
224227

225228

226229
def read_file_contents(self, filename):

Developer/Qt Creator.app/Qt Creator

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@ class LiteInstaller(object):
6464
if reply == QtWidgets.QMessageBox.No:
6565
sys.exit(0)
6666

67-
print("Proceeding to install %s from the %s packages" %(self.filename, self.packages))
68-
self.show_install()
67+
print("Proceeding to install %s from the %s packages" %(self.filename, self.packages))
68+
self.show_install()
6969

7070

7171
def show_message(self):
72-
msgBox = QtWidgets.QMessageBox()
72+
self.msgBox = QtWidgets.QMessageBox()
7373

7474
if self.iconfile:
75-
msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
76-
msgBox.setWindowTitle(" ")
77-
msgBox.setText("%s needs to be downloaded before it can be used." % os.path.basename(__file__))
78-
msgBox.setInformativeText("Do you want to download it now?")
79-
# msgBox.setDetailedText("The following packages and their dependencies be installed:\n" + str(self.packages))
75+
self.msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
76+
self.msgBox.setWindowTitle(" ")
77+
self.msgBox.setText("%s needs to be downloaded before it can be used." % os.path.basename(__file__))
78+
self.msgBox.setInformativeText("Do you want to download it now?")
79+
# self.msgBox.setDetailedText("The following packages and their dependencies be installed:\n" + str(self.packages))
8080
print("The following packages and their dependencies be installed:\n" + str(self.packages))
81-
msgBox.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)
82-
msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
83-
return(msgBox.exec())
81+
self.msgBox.setStandardButtons(QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Yes)
82+
self.msgBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
83+
return(self.msgBox.exec())
8484

8585

8686
def startInstallProcess(self):
@@ -168,6 +168,7 @@ class LiteInstaller(object):
168168

169169

170170
def onProcessFinished(self):
171+
self.progress.setValue(100)
171172
print("Installer script process finished")
172173
# cursor = self.output.textCursor()
173174
# cursor.movePosition(cursor.End)
@@ -178,19 +179,21 @@ class LiteInstaller(object):
178179
executable = os.access(self.filename, os.X_OK)
179180
if exit_code == 0 and executable == True:
180181
# os.execve(self.filename, sys.argv, os.environ) # What sh exec also uses. Leads to issues when files are referenced in relation to the main binary path
182+
self.msgBox.close()
181183
subprocess.call([self.filename] + sys.argv)
184+
sys.exit(0)
182185

183186

184187
def show_install(self):
185-
msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, " ", ("Downloading %s..." % (os.path.basename(__file__))), QtWidgets.QMessageBox.NoButton)
186-
# msgBox.setWindowFlags(QtCore.Qt.CustomizeWindowHint) # Needed for the next line
187-
msgBox.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) # Remove the Close button frim the window decoration; FIXME: Why does this remove the window decorations altogether?
188-
# msgBox.setStyleSheet("QTextEdit{min-width: 500px;}")
189-
msgBox.setStyleSheet("QDialogButtonBox,QTextEdit{min-width: 500px; } QLabel{min-height: 50px;} QProgressBar{min-width: 410px;}") # FIXME: Do this without hardcoding 410px
190-
msgBox.setStandardButtons(QtWidgets.QMessageBox.NoButton)
191-
# msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
192-
msgBox.setDetailedText(" ") # Brings it into existence?
193-
self.details_textedit = msgBox.findChild(QtWidgets.QTextEdit)
188+
self.msgBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Warning, " ", ("Downloading %s..." % (os.path.basename(__file__))), QtWidgets.QMessageBox.NoButton)
189+
# self.msgBox.setWindowFlags(QtCore.Qt.CustomizeWindowHint) # Needed for the next line
190+
self.msgBox.setWindowFlag(QtCore.Qt.WindowCloseButtonHint, False) # Remove the Close button frim the window decoration; FIXME: Why does this remove the window decorations altogether?
191+
# self.msgBox.setStyleSheet("QTextEdit{min-width: 500px;}")
192+
self.msgBox.setStyleSheet("QDialogButtonBox,QTextEdit{min-width: 500px; } QLabel{min-height: 50px;} QProgressBar{min-width: 410px;}") # FIXME: Do this without hardcoding 410px
193+
self.msgBox.setStandardButtons(QtWidgets.QMessageBox.NoButton)
194+
# self.msgBox.setDefaultButton(QtWidgets.QMessageBox.Cancel)
195+
self.msgBox.setDetailedText(" ") # Brings it into existence?
196+
self.details_textedit = self.msgBox.findChild(QtWidgets.QTextEdit)
194197

195198
if self.details_textedit is not None:
196199
print("Found QTextEdit for the details")
@@ -199,9 +202,9 @@ class LiteInstaller(object):
199202

200203

201204
if self.iconfile:
202-
msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
205+
self.msgBox.setIconPixmap(QtGui.QPixmap(self.iconfile).scaledToWidth(64, QtCore.Qt.SmoothTransformation))
203206

204-
msgBox.layout().setAlignment(QtCore.Qt.AlignTop)
207+
self.msgBox.layout().setAlignment(QtCore.Qt.AlignTop)
205208

206209

207210
self.progress = QtWidgets.QProgressBar()
@@ -213,14 +216,14 @@ class LiteInstaller(object):
213216
self.progress.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
214217

215218
# Add the progress bar at the bottom (last row + 1) and first column with column span
216-
# msgBox.layout().addWidget(self.progress, msgBox.layout().rowCount(), 0, 1, msgBox.layout().columnCount(), QtCore.Qt.AlignCenter)
217-
msgBox.layout().addWidget(self.progress, 1, 1, 1, msgBox.layout().columnCount(),
219+
# self.msgBox.layout().addWidget(self.progress, self.msgBox.layout().rowCount(), 0, 1, self.msgBox.layout().columnCount(), QtCore.Qt.AlignCenter)
220+
self.msgBox.layout().addWidget(self.progress, 1, 1, 1, self.msgBox.layout().columnCount(),
218221
QtCore.Qt.AlignCenter)
219222

220-
msgBox.layout().addWidget(QtWidgets.QLabel(), 1, 1, 1, msgBox.layout().columnCount(),
223+
self.msgBox.layout().addWidget(QtWidgets.QLabel(), 1, 1, 1, self.msgBox.layout().columnCount(),
221224
QtCore.Qt.AlignCenter)
222225
self.startInstallProcess()
223-
msgBox.exec()
226+
self.msgBox.exec()
224227

225228

226229
def read_file_contents(self, filename):

0 commit comments

Comments
 (0)