def gen_config_from_ui(self): config = utils.AppConfig() """ Driver """ if self.radioButton_chrome_headless.isChecked(): config.driver = "chrome_headless" """ Output directory """ config.output_dir = self.lineEdit_output.text() """ Switches """ config.face_only = self.checkBox_face_only.isChecked() config.safe_mode = self.checkBox_safe_mode.isChecked() """ Numbers """ config.max_number = self.spinBox_max_number.value() config.num_threads = self.spinBox_num_threads.value() """ Keywords List """ if self.checkBox_from_file.isChecked(): keywords_list = '' str_path = '' str_path = self.lineEdit_path2file.text() #str_path = self.lineEdit_keywords.text() if len(str_path) == 0: messagebox.showinfo("提示", "请完成文件读入功能") self.close() else: keywords_list = utils.gen_keywords_list_from_file(str_path) else: # str_keywords = self.lineEdit_path2file.text() str_keywords = self.lineEdit_keywords.text() keywords_list = utils.gen_keywords_list_from_str(str_keywords) return config, keywords_list
def gen_config_from_ui(self): config = utils.AppConfig() """ Engine """ if self.radioButton_google.isChecked(): config.engine = "Google" elif self.radioButton_bing.isChecked(): config.engine = "Bing" elif self.radioButton_baidu.isChecked(): config.engine = "Baidu" """ Driver """ if self.radioButton_chrome_headless.isChecked(): config.driver = "chrome_headless" elif self.radioButton_chrome.isChecked(): config.driver = "chrome" elif self.radioButton_phantomjs.isChecked(): config.driver = "phantomjs" """ Output directory """ config.output_dir = self.lineEdit_output.text() """ Switches """ config.face_only = self.checkBox_face_only.isChecked() config.safe_mode = self.checkBox_safe_mode.isChecked() """ Numbers """ config.max_number = self.spinBox_max_number.value() config.num_threads = self.spinBox_num_threads.value() """ Proxy """ if self.checkBox_proxy.isChecked(): if self.radioButton_http.isChecked(): config.proxy_type = "http" elif self.radioButton_socks5.isChecked(): config.proxy_type = "socks5" config.proxy = self.lineEdit_proxy.text() else: config.proxy_type = None config.proxy = None """ Keywords List """ if self.checkBox_from_file.isChecked(): str_path = self.lineEdit_path2file.text() keywords_list = utils.gen_keywords_list_from_file(str_path) else: str_keywords = self.lineEdit_keywords.text() keywords_list = utils.gen_keywords_list_from_str(str_keywords, ",") return config, keywords_list