<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 'Microsoft YaHei UI'; color: rgb(0, 0, 0); line-height: 1.5; }</style>
</head>
<body>
<div>Hi <span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">Florian,</span></div>
<div><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;"><br>
</span></div>
<div><span></span>Thanks for your reply. The whole script that I referenced from the website is as follows:</div>
<div><span style="font-family: "" microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?=""></span><a href="http://pythonforengineers.com/your-first-gui-app-with-python-and-pyqt/" microsoftyaheiui??;font-size:14px;font-weight:normal;font-style:normal;?="" style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;">http://pythonforengineers.com/your-first-gui-app-with-python-and-pyqt/</a><span microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?="" style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"> </span></div>
<div><span microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?="" style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;">######################################################</span></div>
<div><span microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?="" style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"><span style="font-family: "" microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgb(255,255,255);font-weight:normal;font-style:normal;text-decoration:none;?="">#!/usr/bin/env python<br>
# -*- coding: utf-8 -*-<br>
<br>
import sys<br>
from PyQt4 import QtCore, QtGui, uic<br>
<br>
qtCreatorFile = "a.ui" # a.ui is in my case<br>
<br>
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)<br>
<br>
class MyApp(QtGui.QMainWindow, Ui_MainWindow):<br>
def __init__(self):<br>
QtGui.QMainWindow.__init__(self)<br>
Ui_MainWindow.__init__(self)<br>
self.setupUi(self)<br>
<br>
def CalculateTax(self):<br>
price=int(self.price_box.toPlainText())<br>
tax=(self.tax_rate.value())<br>
total_price=price+((tax/100)*price)<br>
total_price_string="The total price with tax is: " + str(total_price)<br>
self.results_window.setText(total_price_string)<br>
<br>
if __name__ == "__main__":<br>
app = QtGui.QApplication(sys.argv)<br>
window = MyApp()<br>
window.show()<br>
self.calc_tax_button.clicked.connect(self.CalculateTax)<br>
sys.exit(app.exec_())<br>
</span></span></div>
<div><span microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?="" style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;">###########################################################</span></div>
<div><span microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?="" style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"><br>
</span></div>
<div><span style="background-color: window; font-family: ''; font-size: 10.5pt; line-height: 1.5;">I run the whole example script and the terminal still shows: </span><span style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;">Segmentation fault
(core dumped)</span></div>
<div><span style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;"><br>
</span></div>
<div><span style="font-family: ''; font-size: 10.5pt; line-height: 1.5; background-color: window;">Then I run the script line by line and found that the error occured at the line: </span><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile)</span></div>
<div><br>
</div>
<div><span style="font-size: 10.5pt; line-height: 1.5; background-color: window;">Any suggestions will be appreciated and thank you very much.</span></div>
<span style="font-family: "" microsoftyaheiui??;font-size:14px;color:rgb(0,0,0);background-color:rgba(0,font-weight:normal;font-style:normal;text-decoration:none;?=""></span>
<blockquote style="margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em;">
<div> </div>
<div>Zhefu</div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px">
<div><b>From:</b> <a href="mailto:me@the-compiler.org">Florian Bruhin</a></div>
<div><b>Date:</b> 2018-03-19 13:21</div>
<div><b>To:</b> <a href="mailto:lzfneu@live.com">lzf neu</a></div>
<div><b>CC:</b> <a href="mailto:pyqt@riverbankcomputing.com">pyqt</a></div>
<div><b>Subject:</b> Re: [PyQt] Question about the segmentation fault induced by uic.loadUiTyp</div>
</div>
</div>
<div>
<div>Hi,</div>
<div> </div>
<div>On Mon, Mar 19, 2018 at 03:48:45AM +0000, lzf neu wrote:</div>
<div>> My simple testing script is as follows:</div>
<div>> #============================</div>
<div>> import sys</div>
<div>> from PyQt4 import QtCore, QtGui, uic</div>
<div>> uic.loadUiType("a.ui") # the GUI generated by qt-designer saved as a.ui</div>
<div>> #============================</div>
<div>> </div>
<div>> When running to the last line, an error ocurred and shows in the terminal:</div>
<div>> Segmentation fault (core dumped)</div>
<div> </div>
<div>I'm guessing you need to create a QApplication first.</div>
<div> </div>
<div>> My installing enviroments are: CentOs7, PyQt4_gpl_x11-4.12.1,</div>
<div>> qt-everywhere-opensource-src-4.8.7, sip-4.19.8, QtPy-1.4.0, and the</div>
<div>> python version of CentOs7 is 2.7.5</div>
<div> </div>
<div>Let me note that those are ~3 years old and unsupported/end-of-life</div>
<div>since a while.</div>
<div> </div>
<div>Florian</div>
<div> </div>
<div>-- </div>
<div>https://www.qutebrowser.org | me@the-compiler.org (Mail/XMPP)</div>
<div> GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc</div>
<div> I love long mails! | https://email.is-not-s.ms/</div>
</div>
</blockquote>
</body>
</html>