from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.price_box = QtWidgets.QTextEdit(self.centralwidget)
self.price_box.setGeometry(QtCore.QRect(300, 110, 291, 81))
font = QtGui.QFont()
font.setPointSize(35)
self.price_box.setFont(font)
self.price_box.setObjectName("price_box")
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setGeometry(QtCore.QRect(70, 110, 121, 61))
font = QtGui.QFont()
font.setPointSize(20)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.tax_rate = QtWidgets.QSpinBox(self.centralwidget)
self.tax_rate.setGeometry(QtCore.QRect(300, 250, 291, 81))
font = QtGui.QFont()
font.setPointSize(40)
self.tax_rate.setFont(font)
self.tax_rate.setProperty("value", 20)
self.tax_rate.setObjectName("tax_rate")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setGeometry(QtCore.QRect(70, 260, 151, 61))
font = QtGui.QFont()
font.setPointSize(20)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.calc_tax_button = QtWidgets.QPushButton(self.centralwidget)
self.calc_tax_button.setGeometry(QtCore.QRect(460, 430, 121, 71))
self.calc_tax_button.setObjectName("calc_tax_button")
self.calc_tax_button.clicked.connect(self.CalculateTax)
self.results_window = QtWidgets.QTextEdit(self.centralwidget)
self.results_window.setGeometry(QtCore.QRect(140, 430, 171, 51))
self.results_window.setObjectName("results_window")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.label.setText(_translate("MainWindow", "Price"))
self.label_2.setText(_translate("MainWindow", "Tax Rate"))
self.calc_tax_button.setText(_translate("MainWindow", "calc_tax"))
def CalculateTax(self):
price = int(self.price_box.toPlainText())
tax = (self.tax_rate.value())
total_price = price + ((tax / 100) * price)
total_price_string = "The total price with tax is: " + str(total_price)
self.results_window.setText(total_price_string)
if __name__=="__main__":
import sys
app=QtWidgets.QApplication(sys.argv)
mainwindow=QtWidgets.QMainWindow()
ui=Ui_MainWindow()
ui.setupUi(mainwindow)
mainwindow.show()
sys.exit(app.exec_())
<pre><code>這是一個代碼區(qū)塊运悲。</code></pre>
- Bird
- Magic
single asteriskssingle underscoresdouble asterisksdouble underscores
Use the printf()
function.
朝辭白帝彩云間
千里江陵一日還
兩岸猿聲啼不住
輕舟已過萬重山
朝辭白帝彩云間
我再加一句話看看效果
這是一級標題
這是二級標題
這是三級標題
這是六級標題
這是一級標題
這是二級標題
這是一級引用
這是二級引用
這是三級引用
這是一條刪除線