Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import controller
- from PyQt5 import QtCore, QtGui, QtWidgets
- class Ui_MainWindow(object):
- def setupUi(self, MainWindow):
- MainWindow.setObjectName("MainWindow")
- MainWindow.resize(490, 500)
- self.centralwidget = QtWidgets.QWidget(MainWindow)
- self.centralwidget.setObjectName("centralwidget")
- self.tell_keyword = QtWidgets.QLabel(self.centralwidget)
- self.tell_keyword.setGeometry(QtCore.QRect(30, 20, 167, 26))
- self.tell_keyword.setMaximumSize(QtCore.QSize(191, 16777215))
- font = QtGui.QFont()
- font.setFamily("Taipei Sans TC Beta")
- font.setPointSize(14)
- font.setBold(False)
- font.setWeight(50)
- self.tell_keyword.setFont(font)
- self.tell_keyword.setObjectName("tell_keyword")
- self.tell_pages = QtWidgets.QLabel(self.centralwidget)
- self.tell_pages.setGeometry(QtCore.QRect(30, 90, 148, 26))
- self.tell_pages.setMaximumSize(QtCore.QSize(191, 16777215))
- font = QtGui.QFont()
- font.setFamily("Taipei Sans TC Beta")
- font.setPointSize(14)
- font.setBold(False)
- font.setWeight(50)
- self.tell_pages.setFont(font)
- self.tell_pages.setObjectName("tell_pages")
- self.start_button = QtWidgets.QPushButton(self.centralwidget)
- self.start_button.clicked.connect(self.onButtonClick)
- self.start_button.setGeometry(QtCore.QRect(30, 238, 431, 71))
- font = QtGui.QFont()
- font.setFamily("Taipei Sans TC Beta")
- font.setPointSize(20)
- font.setBold(True)
- font.setWeight(75)
- self.start_button.setFont(font)
- self.start_button.setObjectName("start_button")
- self.state_table = QtWidgets.QTextBrowser(self.centralwidget)
- self.state_table.setGeometry(QtCore.QRect(30, 320, 431, 131))
- font = QtGui.QFont()
- font.setFamily("有愛ウォークラフト角ゴシック CN")
- font.setPointSize(11)
- self.state_table.setFont(font)
- self.state_table.setObjectName("state_table")
- self.keyword_input = QtWidgets.QLineEdit(self.centralwidget)
- self.keyword_input.setGeometry(QtCore.QRect(30, 50, 431, 31))
- font = QtGui.QFont()
- font.setFamily("有愛ウォークラフト角ゴシック CN")
- font.setPointSize(11)
- self.keyword_input.setFont(font)
- self.keyword_input.setText("")
- self.keyword_input.setObjectName("keyword_input")
- self.pages_input = QtWidgets.QLineEdit(self.centralwidget)
- self.pages_input.setGeometry(QtCore.QRect(30, 120, 431, 31))
- font = QtGui.QFont()
- font.setFamily("有愛ウォークラフト角ゴシック CN")
- font.setPointSize(11)
- self.pages_input.setFont(font)
- self.pages_input.setText("")
- self.pages_input.setObjectName("pages_input")
- self.type_shopee_button = QtWidgets.QPushButton(self.centralwidget)
- self.type_shopee_button.setCheckable(True)
- self.type_shopee_button.setGeometry(QtCore.QRect(30, 160, 211, 71))
- font = QtGui.QFont()
- font.setFamily("Taipei Sans TC Beta")
- font.setPointSize(20)
- font.setBold(True)
- font.setWeight(75)
- font.setKerning(True)
- self.type_shopee_button.setFont(font)
- self.type_shopee_button.setObjectName("type_shopee_button")
- self.type_ruten_button = QtWidgets.QPushButton(self.centralwidget)
- self.type_ruten_button.setCheckable(True)
- self.type_ruten_button.setGeometry(QtCore.QRect(250, 160, 211, 71))
- font = QtGui.QFont()
- font.setFamily("Taipei Sans TC Beta")
- font.setPointSize(20)
- font.setBold(True)
- font.setWeight(75)
- font.setKerning(True)
- self.type_ruten_button.setFont(font)
- self.type_ruten_button.setObjectName("type_ruten_button")
- self.start_button.raise_()
- self.tell_keyword.raise_()
- self.tell_pages.raise_()
- self.state_table.raise_()
- self.keyword_input.raise_()
- self.pages_input.raise_()
- self.type_shopee_button.raise_()
- self.type_ruten_button.raise_()
- MainWindow.setCentralWidget(self.centralwidget)
- self.menubar = QtWidgets.QMenuBar(MainWindow)
- self.menubar.setGeometry(QtCore.QRect(0, 0, 490, 21))
- 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.tell_keyword.setText(_translate("MainWindow", "請輸入商品關鍵字:"))
- self.tell_pages.setText(_translate("MainWindow", "請輸入搜尋頁數:"))
- self.start_button.setText(_translate("MainWindow", "開 始"))
- self.type_shopee_button.setText(_translate("MainWindow", "蝦 皮"))
- self.type_ruten_button.setText(_translate("MainWindow", "露天"))
- def onButtonClick(self):
- product_keyword = self.keyword_input.text()
- product_pages = self.pages_input.text()
- if self.type_shopee_button.isChecked():
- self.disply_text('開始執行蝦皮爬蟲1')
- controller.controller(product_keyword, product_pages, 'Shopee')
- self.disply_text('開始執行蝦皮爬蟲2')
- if self.type_ruten_button.isChecked():
- self.disply_text('開始執行露天爬蟲')
- controller.controller(product_keyword, product_pages, 'Ruten')
- def disply_text(self, text):
- print(text)
- self.state_table.append(text)
- self.cursot = self.state_table.textCursor()
- self.state_table.moveCursor(self.cursot.End)
- QtWidgets.QApplication.processEvents()
- 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_())
Advertisement
Add Comment
Please, Sign In to add comment