forked from imvanda/Tree_This_Folder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.int
88 lines (69 loc) · 2.56 KB
/
start.int
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import sys
import os
import subprocess
from configparser import ConfigParser
config = ConfigParser()
from PySide6.QtWidgets import (QWidget, QApplication)
from Ui_Tree_This_Folder import Ui_Tree_This_Folder
main_path = "C:\\Program Files\\Tree This Folder"
config_file_path = os.path.join(main_path, "config.ini")
treeignore_file_path = os.path.join(main_path, ".treeignore")
if getattr(sys, 'frozen', None):
basedir = sys._MEIPASS
else:
basedir = os.path.dirname(__file__)
def run_as_admin(command):
"需要vac"
subprocess.run(["powershell", "Start-Process", command, "-Verb", "RunAs"], shell=True)
def fun1():
run_as_admin(basedir + "\\复制文件夹结构\\add_treejustcopy.bat")
def fun2():
run_as_admin(basedir + "\\生成文件夹结构\\add_treegenerate.bat")
def fun3():
run_as_admin(basedir + "\\复制文件夹结构\\remove_treejustcopy.bat")
def fun4():
run_as_admin(basedir + "\\生成文件夹结构\\remove_treegenerate.bat")
def read_level_limit():
if os.path.exists(config_file_path):
global level_limit
config.read(config_file_path)
level_limit = int(config['DEFAULT']['level_limit'])
def save_level_limit(value):
global level_limit
level_limit = value
def set_level_limit(value):
global level_limit
config['DEFAULT']['level_limit'] = str(level_limit)
with open(config_file_path, 'w') as configfile:
config.write(configfile)
config.read(config_file_path, encoding='utf-8')
print('确定设置探索层级深度:', config['DEFAULT']['level_limit'])
def edit_treeignore():
print('编辑排除项')
os.system("notepad.exe " + treeignore_file_path)
def open_github():
print('打开GitHub')
os.system("start https://github.com/H1DDENADM1N/Tree_This_Folder")
class Tree_This_Folder(QWidget, Ui_Tree_This_Folder):
def __init__(self):
super().__init__()
self.setupUi(self)
self.pushButton_1.clicked.connect(fun1)
self.pushButton_2.clicked.connect(fun2)
self.pushButton_3.clicked.connect(fun3)
self.pushButton_4.clicked.connect(fun4)
read_level_limit()
self.spinBox.setValue(level_limit)
self.spinBox.valueChanged.connect(save_level_limit)
self.pushButton_5.clicked.connect(set_level_limit)
self.pushButton_6.clicked.connect(edit_treeignore)
self.pushButton_7.clicked.connect(open_github)
def main():
global level_limit
level_limit = 20
app = QApplication([])
w = Tree_This_Folder()
w.show()
sys.exit(app.exec())
if __name__ == '__main__':
main()