| 
 | 
 
注册登录后全站资源免费查看下载
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
×
 
0323update v1.3: 
更新了页面的源码。 
上证000001和平安000001冲突问题,自动识别无法实现,增加了手动配置方法: 
查看沪指可配置sh000001 
查看平安可配置sz000001 
注意,字母要小写!! 
另,如有其他识别错误的股票代码,也可自行配置前缀。 
下载地址在最/后。 
 
 
ps:最近加班严重,累得不行,更新和修复问题较慢请各位谅解。 
 
 
 
0310update v1.2: 
新增透明度配置化。 
兼容上证000001指数。 
透明度默认20%,不需要修改的可以不更新。 
主程序同目录下创建ui.txt文件,配置引号里面内容:“透明度:90” 
90为百分比,自己按需配置即可。 
 
 
 
 
0307update v1.1: 
新增兼容创业板、科创板、北证下的代码监控。 
 
update: 
上个版本链接有问题,更新了蓝奏云链接。 
 
话不多说,优先上图! 
休市展示:  
开市展示:  
开市前展示:剩余n秒开市,没图 
 
特性: 
1.启动后在桌面左上角,可自由拖动 
2.股票代码可配置到文件,高度自动调节 
3.右键点击窗口可以关闭程序! 
 
 
 
注意!注意!注意! 
要在exe文件同目录下,创建config.txt文件,里面写上你的股票代码即可,多个代码用回车隔开!否则会报错~ 
 
python写的,图形界面使用内置库tkinter,调用的是TX的接口,每2秒请求一次。 
exe文件使用pyinstaller直接生成的,怕有毒可以自己打包exe文件。 
源码如下,建议研读后自己写写,自己生成exe文件,不懂代码就直接拉到最/后拿exe。 
 
[Asm] [color=rgb(51, 102, 153) !important]纯文本查看 [color=rgb(51, 102, 153) !important]复制代码 
[backcolor=rgb(27, 36, 38) !important][color=rgb(255, 255, 255) !important][color=#ffffff !important] ? 
001  
002  
003  
004  
005  
006  
007  
008  
009  
010  
011  
012  
013  
014  
015  
016  
017  
018  
019  
020  
021  
022  
023  
024  
025  
026  
027  
028  
029  
030  
031  
032  
033  
034  
035  
036  
037  
038  
039  
040  
041  
042  
043  
044  
045  
046  
047  
048  
049  
050  
051  
052  
053  
054  
055  
056  
057  
058  
059  
060  
061  
062  
063  
064  
065  
066  
067  
068  
069  
070  
071  
072  
073  
074  
075  
076  
077  
078  
079  
080  
081  
082  
083  
084  
085  
086  
087  
088  
089  
090  
091  
092  
093  
094  
095  
096  
097  
098  
099  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
 | 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"\033[31m{fl}\033[0m" if float(fl) >= 0 else f"\033[32m{fl}\033[0m" 
        # res += f"{gp_dm.get(i)}:{content}" 
 
        # tk修改颜色 
        res += f"{name}:{fl}\n" 
    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}秒后开市\n" + search(gp_list) 
        elif s.__ge__(a1) and s.__le__(a2): 
            return f"{datetime.now().strftime('%H:%M:%S')}\n" + 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}秒后开市\n" + search(gp_list) 
        elif s.__ge__(p1) and s.__le__(p2): 
            return f"{datetime.now().strftime('%H:%M:%S')}\n" + search(gp_list) 
        elif s.__gt__(p2): 
            return '今天已休市\n' + search(gp_list) 
    else: 
        return '今天休市\n' + 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文件,里面写上你的股票代码即可,多个代码用回车隔开! 
 |  
  
2.png (142.6 KB, 下载次数: 1)  
 
 
 
 
 |   
 
 
 
 |