【摸鱼神器】半透明盯股工具,再也不怕老板看屏幕~

0323update v1.3:
更新了页面的源码。
上证000001和平安000001冲突问题,自动识别无法实现,增加了手动配置方法:
查看沪指可配置sh000001
查看平安可配置sz000001
注意,字母要小写!!
另,如有其他识别错误的股票代码,也可自行配置前缀。
下载地址在最后。

ps:最近加班严重,累得不行,更新和修复问题较慢请各位谅解。

0310update v1.2:
新增透明度配置化。
兼容上证000001指数。
透明度默认20%,不需要修改的可以不更新。
主程序同目录下创建ui.txt文件,配置引号里面内容:“透明度:90”
90为百分比,自己按需配置即可。

0307update v1.1:
新增兼容创业板、科创板、北证下的代码监控。

update:
上个版本链接有问题,更新了蓝奏云链接。

话不多说,优先上图!
休市展示:图片[1] - 【摸鱼神器】半透明盯股工具,再也不怕老板看屏幕~ - 宋马
开市展示:图片[1] - 【摸鱼神器】半透明盯股工具,再也不怕老板看屏幕~ - 宋马
开市前展示:剩余n秒开市,没图

特性:
1.启动后在桌面左上角,可自由拖动
2.股票代码可配置到文件,高度自动调节
3.右键点击窗口可以关闭程序!

注意!

注意!

注意!
要在exe文件同目录下,创建config.txt文件,里面写上你的股票代码即可,多个代码用回车隔开!否则会报错~

python写的,图形界面使用内置库tkinter,调用的是TX的接口,每2秒请求一次。
exe文件使用pyinstaller直接生成的,怕有毒可以自己打包exe文件。
源码如下,提议研读后自己写写,自己生成exe文件,不懂代码就直接拉到最后拿exe。

import os
import tkinter as tk
from datetime import datetime

import requests


def search(gp_dm):
    # tx接口
    res = ""
    for i in gp_dm:
        url = f'http://qt.gtimg.cn/q={i}'
        resp = requests.get(url)
        name = resp.text.split('~')[1]
        fl = resp.text.split('~')[32]
        # print修改颜色
        # content = f"33[31m{fl}33[0m" if float(fl) >= 0 else f"33[32m{fl}33[0m"
        # res += f"{gp_dm.get(i)}:{content}"

        # tk修改颜色
        res += f"{name}:{fl}
"
    return res


a1 = datetime.strptime('09:15:00', '%H:%M:%S').time()
a2 = datetime.strptime('11:30:00', '%H:%M:%S').time()

p1 = datetime.strptime('13:00:00', '%H:%M:%S').time()
p2 = datetime.strptime('15:00:00', '%H:%M:%S').time()


def main():
    # 工作日
    tod = datetime.now().weekday()

    if 0 <= tod <= 4:
        # 开市时间
        s = datetime.now().time()

        if s.__lt__(a1):
            dt = datetime.now().strftime("%Y/%m/%d")
            st = datetime.strptime(f'{dt} 09:15:00', '%Y/%m/%d %H:%M:%S') - datetime.now()
            return f"{st.seconds}秒后开市
" + search(gp_list)
        elif s.__ge__(a1) and s.__le__(a2):
            return f"{datetime.now().strftime('%H:%M:%S')}
" + search(gp_list)
        elif s.__gt__(a2) and s.__lt__(p1):
            dt = datetime.now().strftime("%Y/%m/%d")
            st = datetime.strptime(f'{dt} 13:00:00', '%Y/%m/%d %H:%M:%S') - datetime.now()
            return f"{st.seconds}秒后开市
" + search(gp_list)
        elif s.__ge__(p1) and s.__le__(p2):
            return f"{datetime.now().strftime('%H:%M:%S')}
" + search(gp_list)
        elif s.__gt__(p2):
            return '今天已休市
' + search(gp_list)
    else:
        return '今天休市
' + search(gp_list)


def showtime():
    """
    定时展示res内容
    :return:
    """
    res = main().strip()
    lb.config(text=str(res))
    lb.after(2000, showtime)


def tk_exit(event):
    """
    退出函数
    :param event:
    :return:
    """
    # 1.关闭窗口
    root.destroy()


# def on_resize(evt):
#     root.configure(width=evt.width, height=evt.height)
#     cv.create_rectangle(0, 0, cv.winfo_width(), cv.winfo_height(), fill="gray", outline="gray")
#     print(cv.winfo_width())

class FloatingWindow:
    """
    移动窗口
    """

    def __init__(self, rt):
        self.rt = rt
        self.x = 0
        self.y = 0

        # 设置按键
        lb.bind("<ButtonPress-1>", self.start_move)
        lb.bind("<ButtonRelease-1>", self.stop_move)
        lb.bind("<B1-Motion>", self.on_motion)

    def start_move(self, event):
        self.x = event.x
        self.y = event.y

    def stop_move(self, event):
        self.x = None
        self.y = None

    def on_motion(self, event):
        deltax = event.x - self.x
        deltay = event.y - self.y
        x = self.rt.winfo_x() + deltax
        y = self.rt.winfo_y() + deltay
        self.rt.geometry("+%s+%s" % (x, y))


def validate_file():
    """
    校验配置文件是否存在,存在则读取
    :return:
    """
    # 校验是否存在代码配置文件
    if not os.path.exists('./config.txt'):
        assert False, "请在本程序下配置config.txt文件,内容为股票代码,多个代码用换行隔开"

    # 读取代码配置
    temp_gp_list = []
    f = open('./config.txt', 'r')
    for line in f:
        temp_code = line.strip()
        if temp_code[0].isalpha():  # 自行配置sz/sh开头,直接读取,注意要用小写
            temp_gp_list.append(temp_code)
        elif temp_code:
            if temp_code.startswith('60') or temp_code.startswith('68'):  # 沪指/科创
                gp_code = f'sh{temp_code}'
            elif temp_code.startswith('83'):  # 北证
                gp_code = f'bj{temp_code}'
            else:  # 深指39/创业板
                gp_code = f'sz{temp_code}'
            temp_gp_list.append(gp_code)
    if len(temp_gp_list) < 1:
        assert False, "config文件未配置股票代码"

    # 校验是否存在ui配置文件
    get_ui_config = {}
    if os.path.exists('./ui.txt'):
        f = open('./ui.txt', 'r', encoding='utf-8')
        for line in f:
            shuxing, value = line.strip().split(':')
            get_ui_config[shuxing] = value

    return temp_gp_list, get_ui_config


if __name__ == '__main__':
    # 读取代码配置
    gp_list, ui_config = validate_file()
    # GUI
    root = tk.Tk()
    root.overrideredirect(True)  # 无标题栏窗体
    # 透明度
    root.attributes('-alpha', int(ui_config.get('透明度'))/100 if ui_config.get('透明度') else 0.2)

    width = 90
    height = 5 + 16 * (len(gp_list) + 1)
    screen_width = root.winfo_screenwidth()
    x = int((screen_width - width) / 2)
    # screen_height = root.winfo_screenheight()
    # y = int(screen_height - height - 75)
    root.geometry(f'{width}x{height}+0+0')
    root.attributes("-topmost", 1)

    root.wm_attributes("-transparentcolor", "gray")
    root.bind("<ButtonRelease-3>", tk_exit)

    lb = tk.Label(root)
    lb.pack(fill='both', side='top')
    showtime()
    root.floater = FloatingWindow(root)
    root.mainloop()

exe文件9.59M上传不了
v1.1蓝奏云地址:

https://wwyd.lanzout.com/i3nTQ0pi5zpe

v1.2蓝奏云地址:

https://wwyd.lanzout.com/iTnav0pqy52d

v1.3蓝奏云地址:

https://wwyd.lanzout.com/iO2xe0qvv8kh

再次提醒!
要在exe文件同目录下,创建config.txt文件,里面写上你的股票代码即可,多个代码用回车隔开!

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 共49条

请登录后发表评论