forked from shiyindebcd/ProcessTrader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Setting_Inheritance.py
95 lines (74 loc) · 3.79 KB
/
Setting_Inheritance.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# -*- coding: utf-8 -*-
from PySide6 import QtCore
from PySide6.QtGui import QCursor, Qt
from PySide6.QtWidgets import (QDialog)
import pandas as pd
from read_write_file import ReadWriteCsv
from UI.Setting_dark import Ui_Dialog as UI_dark
from UI.Setting_light import Ui_Dialog as UI_light
from main import THEME
if THEME == "dark":
UI = UI_dark
else:
UI = UI_light
class SettingDialog(QDialog, UI):
def __init__(self, parent):
super(SettingDialog, self).__init__()
self.setupUi(self)
self.parent = parent
# 不显示标题栏
self.setWindowFlags(QtCore.Qt.WindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint))
# 不显示空白边框
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
# 设置透明度
self.setWindowOpacity(0.95)
self.path = './data/main_tq_account.csv'
self.ioModule = self.parent.ioModule # 实例化读写csv文件的类
self.ioModule.judge_file_exist(path=self.path) # 判断main_tq_account.csv是否存在,如果不存在,则创建
self.data = self.ioModule.read_csv_file(path=self.path) # 读取main_tq_account.csv文件
if self.data.empty: # 判断self.data是否为空
print('当前未配置主程序天勤帐号')
else:
self.label_Account.setText('已配置天勤帐号: ' + str(self.data.iloc[0]['tq_account']) + ' 无需再配置')
self.Btn_clear_main_tq_account.clicked.connect(self.clear_main_tq_account)
self.Btn_Determine_add.clicked.connect(self.get_tq_account)
self.Btn_Determine_add.setFocusPolicy(Qt.NoFocus)
self.Btn_clear_input.clicked.connect(self.clear_input)
self.Btn_clear_input.setFocusPolicy(Qt.NoFocus)
def mousePressEvent(self, e): # 鼠标点击事件
if e.button() == Qt.LeftButton:
self.m_drag = True
self.m_DragPosition = e.globalPosition().toPoint() - self.pos()
e.accept()
self.setCursor(QCursor(Qt.OpenHandCursor))
def mouseReleaseEvent(self, e): # 鼠标释放事件
if e.button() == Qt.LeftButton:
self.m_drag = False
self.setCursor(QCursor(Qt.ArrowCursor))
def mouseMoveEvent(self, e): # 鼠标拖动事件
if Qt.LeftButton and self.m_drag:
self.move(e.globalPosition().toPoint() - self.m_DragPosition)
e.accept()
def get_tq_account(self):
dict = {}
# 如果main_tq_account不为空,则读取main_tq_account的值
if (self.main_tq_account.text() is not None) and (self.main_tq_account.text() is not None): #如果帐户框和密码框都有都有输入
self.ioModule.delete_file(path=self.path) #删除原文件
self.ioModule.judge_file_exist(path=self.path) # 判断main_tq_account.csv是否存在,如果不存在,则创建
dict['tq_account'] = self.main_tq_account.text()
dict['qt_psd'] = self.main_tq_psd.text()
self.parent.main_tq_account = self.main_tq_account.text()
self.parent.main_tq__pwd = self.main_tq_psd.text()
df = pd.DataFrame(dict, index=[0])
self.ioModule.add_dict_to_csv(df, path=self.path)
# print(df)
self.label_Account.setText('已配置主程序天勤帐号: ' + self.main_tq_account.text())
else:
pass
def clear_input(self):
self.main_tq_account.clear()
self.main_tq_psd.clear()
def clear_main_tq_account(self):
self.ioModule.delete_file(self.path)
self.ioModule.judge_file_exist(path=self.path)
self.label_Account.setText('天勤主账户已删除')