Skip to content

Commit e941ac2

Browse files
Build-1.11 菜单与设置配置更新
本次更新更新了如下内容: 菜单 设置系统
1 parent 39442af commit e941ac2

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

C++Tester.py

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
import glob
1313
print("\r正在导入库..... \\ shutil",end="")
1414
import shutil as sh
15+
print("\r正在导入库...... - webbrowser",end="")
16+
import webbrowser as wb
1517
print(" 库导入成功!")
1618

1719
# 开门见山
18-
print("C++测试器 Build-1.10 HelloWorldCoder(-China)制作 你只拥有此软件的永久使用、复制权\n详见软件目录下的LICENSE文件")
20+
print("""##########################################################################################################
21+
C++测试器 Build-1.10 HelloWorldCoder(-China)制作
22+
你只拥有此软件的永久使用、复制权详见软件目录下的LICENSE文件""")
1923
programdir=os.path.dirname(os.path.abspath(__file__))
2024
os.chdir(os.path.dirname(os.path.abspath(__file__)))
2125
print("你可以在{}下创建Tester.set配置文件以使用统一配置多次测试".format(os.path.dirname(os.path.abspath(__file__))))
2226
print("你可以在{}下创建MutiQuest.set配置文件以启用多试题并设置".format(os.path.dirname(os.path.abspath(__file__))))
23-
27+
2428
# 配置输入
2529
def infoinput():
2630
# 全局变量化
@@ -30,7 +34,7 @@ def infoinput():
3034
lines=linesdefult
3135
timebetwin=float(input("测试时间间隔:"))
3236
optype=input("请选择操作:输入1进行单次测试,输入2进行多次测试,输入其他退出:")
33-
ignore_end_n=input("是否要忽略末尾换行符(Y/N,务必大写):")
37+
ignore_end_n=input("是否要忽略末尾换行符(Y/N):").upper()
3438
run_file=int(input("是否需要编译、运行C++文件?输入1编译、运行,输入2不编译、不运行:"))
3539
if run_file==1:
3640
compiler=input("请输入编译器路径,若无特殊需求,请填写g++:")
@@ -40,6 +44,72 @@ def infoinput():
4044
if optype=="2":
4145
file_name=input("测试文件名格式(填序号的位置用{}替代,如:abc[1]->abc[{}],abc1->abc{}):")
4246
points=int(input("请输入样例点总数:"))
47+
48+
# 菜单
49+
def menu():
50+
print("""###########################################################################################################
51+
欢迎使用C++测试器,请输入你要执行的操作:
52+
1.开始测试
53+
2.设置多次测试参数
54+
3.打开本软件的官网
55+
4.退出""")
56+
choice=input("请输入你的选择:")
57+
if choice=="1":
58+
pass
59+
elif choice=="2":
60+
settingtype=input("请输入你的要编辑的配置文件(1.单题/2.多题): ")
61+
settingoptype=input("请选择操作(1.更改配置/2.删除配置)")
62+
if settingtype=="1":
63+
if settingoptype=="1":
64+
infoinput()
65+
with open(f"{os.path.dirname(os.path.abspath(__file__))}/Tester.set","w+",encoding="utf-8") as f:
66+
if run_file==1:
67+
if optype=="1":
68+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{compiler};{time_limit};{file_name}")
69+
if optype=="2":
70+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{compiler};{time_limit};{file_name};{points}")
71+
else:
72+
if optype=="1":
73+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{file_name}")
74+
if optype=="2":
75+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{file_name};{points}")
76+
else:
77+
os.remove(f"{os.path.dirname(os.path.abspath(__file__))}/Tester.set")
78+
print("配置文件已删除")
79+
elif settingtype=="2":
80+
if settingoptype=="1":
81+
quests=int(input("请输入要测试的题目数量: "))
82+
with open(f"{os.path.dirname(os.path.abspath(__file__))}/MutiQuest.set","w+",encoding="utf-8") as f:
83+
f.write(f"{quests}\n")
84+
for i in range(quests):
85+
infoinput()
86+
with open(f"{os.path.dirname(os.path.abspath(__file__))}/MutiQuest.set","a+",encoding="utf-8") as f:
87+
if run_file==1:
88+
if optype=="1":
89+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{compiler};{time_limit};{file_name}")
90+
if optype=="2":
91+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{compiler};{time_limit};{file_name};{points}")
92+
else:
93+
if optype=="1":
94+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{file_name}")
95+
if optype=="2":
96+
f.write(f"{path};{linesdefult};{timebetwin};{optype};{ignore_end_n};{run_file};{file_name};{points}")
97+
f.write("\n")
98+
else:
99+
os.remove(f"{os.path.dirname(os.path.abspath(__file__))}/MutiQuest.set")
100+
print("配置文件已删除")
101+
menu()
102+
elif choice=="3":
103+
wb.open_new_tab("https://github.com/HelloWorldCoder-China/Cpp-Tester")
104+
print("已打开官网")
105+
menu()
106+
elif choice=="4":
107+
print("程序已退出")
108+
exit(0)
109+
else:
110+
print("输入错误,请重新输入")
111+
menu()
112+
menu()
43113

44114
# 主测试函数
45115
def main_testing_process():

0 commit comments

Comments
 (0)