module_setting.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # -*- coding: utf-8 -*-
  2. import time
  3. import sys
  4. import os
  5. import settings
  6. from UI.set_image_mode import Ui_Form
  7. from PySide6.QtWidgets import *
  8. from PySide6.QtCore import *
  9. class ToSetting(QWidget, Ui_Form):
  10. signal_data = Signal(dict)
  11. def __init__(self, windows):
  12. super().__init__()
  13. self.windows = windows
  14. self.setupUi(self)
  15. self.setFixedSize(self.width(), self.height())
  16. self.init()
  17. self.setWindowModality(Qt.ApplicationModal)
  18. self.show()
  19. def init(self):
  20. self.pushButton.clicked.connect(self.run)
  21. # 回填数据
  22. self.lineEdit.setText(",".join(settings.is_fall_dir))
  23. self.lineEdit_2.setText(",".join(settings.is_fall_file))
  24. def run(self):
  25. is_fall_dir = self.lineEdit.text()
  26. if not is_fall_dir:
  27. is_fall_dir = "已扣图"
  28. else:
  29. if "已扣图" not in is_fall_dir:
  30. is_fall_dir += ",已扣图"
  31. is_fall_dir = is_fall_dir.replace(",", ",")
  32. is_fall_dir = is_fall_dir.replace(",,", ",")
  33. settings.set_config(data_dict={"is_fall_dir": is_fall_dir}, section="basicSetup")
  34. if is_fall_dir:
  35. is_fall_dir = is_fall_dir.split(",")
  36. settings.is_fall_dir = [x for x in is_fall_dir if x]
  37. else:
  38. settings.is_fall_dir = []
  39. is_fall_file = self.lineEdit_2.text()
  40. is_fall_file = is_fall_file.replace(",", ",")
  41. settings.set_config(data_dict={"is_fall_file": is_fall_file}, section="basicSetup")
  42. if is_fall_file:
  43. is_fall_file = is_fall_file.split(",")
  44. settings.is_fall_file = [x for x in is_fall_file if x]
  45. else:
  46. settings.is_fall_file = []
  47. self.close()