增加剪贴板单选变多选工具并整合入工具面板 取消工具面板自动置顶
This commit is contained in:
parent
2b973339b7
commit
2649643b65
|
|
@ -108,6 +108,8 @@ def run_command1():
|
||||||
call(["python","统考数据导入.py"])
|
call(["python","统考数据导入.py"])
|
||||||
elif selectedtool == "合并使用记录并排序":
|
elif selectedtool == "合并使用记录并排序":
|
||||||
call(["python","合并使用记录并排序.py"])
|
call(["python","合并使用记录并排序.py"])
|
||||||
|
elif selectedtool == "剪贴板单选变多选":
|
||||||
|
call(["python","../文本处理工具/单选变为多选.py"])
|
||||||
LabelTool.config(text = selectedtool+"STEP1命令执行完毕")
|
LabelTool.config(text = selectedtool+"STEP1命令执行完毕")
|
||||||
button1.place_forget()
|
button1.place_forget()
|
||||||
|
|
||||||
|
|
@ -211,6 +213,7 @@ menubar.add_cascade(label = "其他", menu = OtherMenu)
|
||||||
OtherMenu.add_command(label = "剪贴板mathpix预处理", command = lambda: SetButton("mathpix预处理",1,[]))
|
OtherMenu.add_command(label = "剪贴板mathpix预处理", command = lambda: SetButton("mathpix预处理",1,[]))
|
||||||
OtherMenu.add_command(label = "剪贴板带圈数字处理", command = lambda: SetButton("带圈数字处理",1,[]))
|
OtherMenu.add_command(label = "剪贴板带圈数字处理", command = lambda: SetButton("带圈数字处理",1,[]))
|
||||||
OtherMenu.add_command(label = "剪贴板表格整理", command = lambda: SetButton("剪贴板表格整理",1,[]))
|
OtherMenu.add_command(label = "剪贴板表格整理", command = lambda: SetButton("剪贴板表格整理",1,[]))
|
||||||
|
OtherMenu.add_command(label = "剪贴板单选变多选", command = lambda: SetButton("剪贴板单选变多选",1,[]))
|
||||||
|
|
||||||
|
|
||||||
menubar.add_command(label = "退出", command = root.destroy)
|
menubar.add_command(label = "退出", command = root.destroy)
|
||||||
|
|
@ -218,7 +221,7 @@ menubar.add_command(label = "退出", command = root.destroy)
|
||||||
|
|
||||||
|
|
||||||
root.config(menu = menubar)
|
root.config(menu = menubar)
|
||||||
root.attributes("-topmost",1)
|
# root.attributes("-topmost",1)
|
||||||
root.iconbitmap("logo.ico")
|
root.iconbitmap("logo.ico")
|
||||||
|
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
@ -0,0 +1,52 @@
|
||||||
|
import os,re
|
||||||
|
import win32clipboard as wc
|
||||||
|
import win32con
|
||||||
|
|
||||||
|
# 获取剪切板内容
|
||||||
|
def getCopy():
|
||||||
|
wc.OpenClipboard()
|
||||||
|
t = wc.GetClipboardData(win32con.CF_UNICODETEXT)
|
||||||
|
wc.CloseClipboard()
|
||||||
|
return t
|
||||||
|
|
||||||
|
# 写入剪切板内容
|
||||||
|
def setCopy(str):
|
||||||
|
wc.OpenClipboard()
|
||||||
|
wc.EmptyClipboard()
|
||||||
|
wc.SetClipboardData(win32con.CF_UNICODETEXT, str)
|
||||||
|
wc.CloseClipboard()
|
||||||
|
|
||||||
|
def choicetoblankfilling(data):
|
||||||
|
choiceslist = re.findall(r"(\\(?:two|four|one)ch[\s\S]*?)(?:\n[\s]*\\item|$)",data)
|
||||||
|
for rawchoice in choiceslist:
|
||||||
|
leftcount = 0
|
||||||
|
rightcount = 0
|
||||||
|
choicestring = rawchoice
|
||||||
|
contentlist = [""]
|
||||||
|
while len(choicestring) > 0:
|
||||||
|
char = choicestring[0]
|
||||||
|
if char == "{":
|
||||||
|
leftcount += 1
|
||||||
|
if char == "}":
|
||||||
|
rightcount += 1
|
||||||
|
if leftcount > rightcount:
|
||||||
|
contentlist[-1]+=char
|
||||||
|
if leftcount == rightcount and contentlist[-1] != "":
|
||||||
|
contentlist[-1] += "}"
|
||||||
|
contentlist.append("")
|
||||||
|
choicestring = choicestring[1:]
|
||||||
|
contentlist = [c[1:-1] for c in contentlist if c.strip()!=""]
|
||||||
|
repstring = ""
|
||||||
|
for t in range(len(contentlist)):
|
||||||
|
repstring += r"\textcircled{"+str(t+1)+"} "+contentlist[t]+"; "
|
||||||
|
repstring= repstring[:-2]+"."
|
||||||
|
data = data.replace(rawchoice,repstring)
|
||||||
|
data = re.sub(r"bracket\{\d*?\}\.*",r"blank{50}.\\\\",data)
|
||||||
|
return data
|
||||||
|
|
||||||
|
data = getCopy()
|
||||||
|
modified_data = choicetoblankfilling(data)
|
||||||
|
setCopy(modified_data)
|
||||||
|
|
||||||
|
with open("临时文件/outputfile.txt","w",encoding = "utf8") as f:
|
||||||
|
f.write(modified_data)
|
||||||
Reference in New Issue