for fun
This commit is contained in:
@@ -16,7 +16,8 @@ indexMap = {6: "A. ", 7: "B. ", 8: "C. ", 9: "D. "}
|
|||||||
# 全局
|
# 全局
|
||||||
bottom_options = ["未做过的题", "错过的题", ]
|
bottom_options = ["未做过的题", "错过的题", ]
|
||||||
instructions = f"""第二行啥也不选就是不过滤,全部的题
|
instructions = f"""第二行啥也不选就是不过滤,全部的题
|
||||||
题目是加权平均抽取,默认权重为3,对一次减1,错一次加2."""
|
题目是加权平均抽取,默认权重为3,对一次减1,错一次加2.
|
||||||
|
源代码https://v.zikai.wang/zikai/cyzg"""
|
||||||
|
|
||||||
# 样式
|
# 样式
|
||||||
# 创建字体
|
# 创建字体
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import webbrowser
|
||||||
from tkinter import ttk
|
from tkinter import ttk
|
||||||
from components import *
|
from components import *
|
||||||
|
|
||||||
@@ -56,9 +59,50 @@ class Page1:
|
|||||||
text_widget.insert(tk.END, instructions)
|
text_widget.insert(tk.END, instructions)
|
||||||
text_widget.config(state=tk.DISABLED)
|
text_widget.config(state=tk.DISABLED)
|
||||||
|
|
||||||
def setup_styles(self):
|
# just for fun
|
||||||
"""设置 ttk 样式"""
|
url = "https://v.zikai.wang/zikai/cyzg"
|
||||||
|
start_pos = instructions.find(url)
|
||||||
|
if start_pos != -1:
|
||||||
|
# 计算起始和结束索引(tkinter 使用 "行.列" 格式)
|
||||||
|
start_index = f"1.0 + {start_pos} chars"
|
||||||
|
end_index = f"{start_index} + {len(url)} chars"
|
||||||
|
|
||||||
|
# 创建一个超链接标签
|
||||||
|
text_widget.tag_add("link", start_index, end_index)
|
||||||
|
text_widget.tag_config("link",
|
||||||
|
foreground="blue",
|
||||||
|
underline=True,
|
||||||
|
font=(FONT_FAMILY, 12, "underline"))
|
||||||
|
|
||||||
|
# 定义点击事件
|
||||||
|
def open_link(event):
|
||||||
|
try:
|
||||||
|
webbrowser.open(url)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
try:
|
||||||
|
os_name = platform.system()
|
||||||
|
|
||||||
|
if os_name == "Windows":
|
||||||
|
os.system(f'echo {url} | clip')
|
||||||
|
elif os_name == "Darwin":
|
||||||
|
os.system(f'echo "{url}" | pbcopy')
|
||||||
|
else:
|
||||||
|
os.system(f'echo "{url}" | xclip -selection clipboard')
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
def on_enter(event):
|
||||||
|
text_widget.config(cursor="hand2")
|
||||||
|
|
||||||
|
def on_leave(event):
|
||||||
|
text_widget.config(cursor="")
|
||||||
|
|
||||||
|
# 绑定事件
|
||||||
|
text_widget.tag_bind("link", "<Button-1>", open_link) # 左键点击
|
||||||
|
text_widget.tag_bind("link", "<Enter>", on_enter) # 鼠标进入
|
||||||
|
text_widget.tag_bind("link", "<Leave>", on_leave) # 鼠标离开
|
||||||
|
|
||||||
def top_selected(self):
|
def top_selected(self):
|
||||||
"""返回第一行中被选中的项"""
|
"""返回第一行中被选中的项"""
|
||||||
|
|||||||
Reference in New Issue
Block a user