7 Star 30 Fork 19

shiyindebcd/进程交易者

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Setting_Inheritance.py 3.79 KB
一键复制 编辑 原始数据 按行查看 历史
shiyindebcd 提交于 2022-10-13 00:20 . 优化了天勤行情数据服务
# -*- 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('天勤主账户已删除')
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/shiyindebcd/ProcessTrader.git
[email protected]:shiyindebcd/ProcessTrader.git
shiyindebcd
ProcessTrader
进程交易者
进程交易者2.0

搜索帮助