开始将全部程序的设置部分移动到同一个json文件中, 目前完成了基础结构和"批量讲义生成.py"的移动
This commit is contained in:
parent
52616794a7
commit
d904461d9b
|
|
@ -1198,7 +1198,13 @@ def GenerateSingleLessonPreparation(lessonid, outputdir, adict, prodict, objdict
|
||||||
return latex_data # 返回有错误的latex源代码
|
return latex_data # 返回有错误的latex源代码
|
||||||
|
|
||||||
|
|
||||||
|
def getlineindex(string,filepath): #返回字符串在文本文件中第一次出现的行数, 若未出现则返回1
|
||||||
|
with open(filepath,"r",encoding = "u8") as f:
|
||||||
|
lines = f.readlines()
|
||||||
|
for l in lines:
|
||||||
|
if string in l:
|
||||||
|
return lines.index(l)+1
|
||||||
|
return 1
|
||||||
|
|
||||||
def getCopy(): # 获取剪切板内容
|
def getCopy(): # 获取剪切板内容
|
||||||
wc.OpenClipboard()
|
wc.OpenClipboard()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from tkinter import *
|
from tkinter import *
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
import os
|
import os
|
||||||
|
from database_tools import *
|
||||||
|
|
||||||
root = Tk()
|
root = Tk()
|
||||||
|
|
||||||
|
|
@ -26,8 +27,14 @@ def SetButton(string,openfilelist):
|
||||||
LabelInfo.config(text = generate_info(string))
|
LabelInfo.config(text = generate_info(string))
|
||||||
button1.place(x = 10, y = 10)
|
button1.place(x = 10, y = 10)
|
||||||
button1.configure(bg = "green")
|
button1.configure(bg = "green")
|
||||||
|
configjson = load_dict("文本文件/config.json")
|
||||||
for f in openfilelist:
|
for f in openfilelist:
|
||||||
|
if not f in configjson:
|
||||||
os.system("code -w "+f)
|
os.system("code -w "+f)
|
||||||
|
else:
|
||||||
|
lineindex = getlineindex(f,"文本文件/config.json")
|
||||||
|
os.system(f"code -w -g 文本文件/config.json:{lineindex}")
|
||||||
|
|
||||||
|
|
||||||
# 按钮STEP1执行的命令
|
# 按钮STEP1执行的命令
|
||||||
def run_command1():
|
def run_command1():
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,20 @@
|
||||||
problems_dict = {
|
# problems_dict = {
|
||||||
"第一讲": "1:20",
|
# "第一讲": "1:20",
|
||||||
"第二讲": "50:60,70:80"
|
# "第二讲": "50:60,70:80"
|
||||||
} #题号字典, 每一项的key表示标题, 内容字符串表示题号
|
# } #题号字典, 每一项的key表示标题, 内容字符串表示题号
|
||||||
notetitle = "测试批量讲义" #讲义标题, 也是文件标题
|
# notetitle = "测试批量讲义" #讲义标题, 也是文件标题
|
||||||
answered = True #是否展示答案, True表示展示答案, False表示不展示答案
|
# answered = True #是否展示答案, True表示展示答案, False表示不展示答案
|
||||||
|
|
||||||
|
|
||||||
from database_tools import *
|
from database_tools import *
|
||||||
|
|
||||||
|
|
||||||
|
configjson = load_dict("文本文件/config.json")["批量讲义生成.py"]
|
||||||
|
|
||||||
|
problems_dict = configjson["标题与题号"]
|
||||||
|
notetitle = configjson["pdf标题"]
|
||||||
|
answered = configjson["提供答案"]
|
||||||
|
|
||||||
|
|
||||||
prodictpath = "../题库0.3/problems.json"
|
prodictpath = "../题库0.3/problems.json"
|
||||||
pro_dict = load_dict(prodictpath)
|
pro_dict = load_dict(prodictpath)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"说明": "程序的设置文件, 用于工具v2中各程序的主要变量赋值等",
|
||||||
|
"批量讲义生成.py": {
|
||||||
|
"标题与题号": {
|
||||||
|
"第一讲": "1:5",
|
||||||
|
"第二讲": "50:60,70:80"
|
||||||
|
},
|
||||||
|
"pdf标题": "测试批量讲义",
|
||||||
|
"提供答案": true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue