def importJsonSetting(self, path=None): """ importJsonSetting 导入Json Keyword Arguments: path {str} -- 导入路径 为空则弹出选择窗口获取 (default: {None}) """ if not path: path, _ = QFileDialog.getOpenFileName(self, caption=u"获取设置", filter=u"json (*.json)") if not path: return # NOTE 如果文件不存在则返回空 if not os.path.exists(path): return with open(path, 'r') as f: self.setting_data = json.load(f, encoding="utf-8") if self.setting_data["Horizontal_RB"]: self.Horizontal_RB.setChecked(1) else: self.Vertical_RB.setChecked(1) if self.setting_data["Maya_RB"]: self.Maya_RB.setChecked(1) else: self.Qt_RB.setChecked(1) self.Crop_CB.setChecked(self.setting_data["Crop_CB"]) self.Limit_CB.setChecked(self.setting_data["Limit_CB"]) self.Width_SP.setValue(self.setting_data["Width_SP"]) self.Height_SP.setValue(self.setting_data["Height_SP"]) self.Fit_SP.setValue(self.setting_data["Fit_SP"])
def import_csv(self, path=None): if not path: path, _ = QFileDialog.getOpenFileName( self, caption=u"获取设置", filter=u"csv (*.csv)" ) # NOTE 如果文件不存在则返回空 if not path or not os.path.exists(path): return self.handle_csv(path) self.settings.setValue("csv_file", path)
def import_setting(self): path, _ = QFileDialog.getOpenFileName(self, caption=u"获取设置", filter=u"ini (*.ini)") # NOTE 如果文件不存在则返回空 if not path or not os.path.exists(path): return self.settings = QtCore.QSettings(path, QtCore.QSettings.IniFormat) self.settings.sync() self.load_settings() name = "%s.ini" % self.__class__.__name__ self.settings = QtCore.QSettings(name, QtCore.QSettings.IniFormat) self.save_settings() toast(u"加载成功", "info")
def importJsonSetting(self): """ importJsonSetting 导入 Json 设置 """ path, _ = QFileDialog.getOpenFileName(self, caption=u"获取摄像机设置", filter=u"json (*.json)") if not path: return # NOTE 如果文件不存在则返回空 if not os.path.exists(path): return with open(path, 'r') as f: self.camera_setting = json.load(f, encoding="utf-8", object_pairs_hook=OrderedDict) # NOTE 更新面板内容 self.showProcess()
def importJsonSetting(self, path=None): """ importJsonSetting 导入Json Keyword Arguments: path {str} -- 导入路径 为空则弹出选择窗口获取 (default: {None}) """ if not path: path, _ = QFileDialog.getOpenFileName(self, caption=u"获取设置", filter=u"json (*.json)") if not path: return # NOTE 如果文件不存在则返回空 if not os.path.exists(path): return with open(path, 'r') as f: self.setting = json.load(f, encoding="utf-8", object_pairs_hook=OrderedDict) # NOTE 更新面板内容 self.refresh()