-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTETools.py
159 lines (144 loc) · 5.17 KB
/
TETools.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -*- coding: utf-8 -*-
from timeit import default_timer as timer
import argparse
from gooey import Gooey, GooeyParser
import Actions.sql_find_replace_class as find_replace
import Actions.qa_annotations as qa
@Gooey(program_name='TE Tools',
program_description='Translation Editor Toolbox',
tabbed_groups=False,
navigation='Sidebar',
sidebar_title='Choose Action to run',
show_sidebar=True,
optional_cols=4,
default_size=(1100,600),
advanced = True,
richtext_controls=True,
menu=[{
'name': 'File',
'items': [{
'type': 'AboutDialog',
'menuTitle': 'About',
'name': 'Gooey Layout Demo',
'description': 'An example of Gooey\'s layout flexibility',
'version': '0.12',
'copyright': '2021',
'website': 'https://github.com/makerling/TE-Tools',
'developer': 'Stevan Vanderwerf',
'license': 'GPL'
}]
}])
def main():
settings_msg = 'Example program to show how to place multiple argument groups as tabs'
parser = GooeyParser(description=settings_msg)
subs = parser.add_subparsers(help='commands', dest='command')
home = subs.add_parser('Home')
# home.add_argument(help='Option one')
# can't use add_argument_group to change "required arguments" text,
# that only works with ArgumentParser()
home.add_argument(
'Welcome to the Translation Editor Toolbox',
default='This is a collection of scripts written for use with the Ottoman Transcription Project\n\n\
Instructions:\n\
\t- Choose one of the Action scripts on the left\n\
\t- Select the options for the script in the interface\n\
\t- Cick the START button to run the script\n\
\t- The output and results will be shown in the program\n\
\t- Afterwards, click the EDIT button to run another script\n\n\
',
widget='Textarea',
gooey_options={
'height': 200,
'show_label': True,
'show_help': True,
'show_border': True
}
)
#using add_argument_group lets you eliminates/customize the 'option/required' headings
find_replace = subs.add_parser('Find/Bulk-Replace')
find_replace_group = find_replace.add_argument_group("Find/Bulk Replace")
find_replace_group.add_argument(
'-find', #what is seen by user in GUI, can't have spaces or will cause error
# '-find', #this is what is called by args to store user input e.g. args.find_what
type=str,
help='Find what:',
gooey_options={
# 'show_border': True,
# 'help_bg_color': '#d4193c',
# 'help_color': '#f2eded',
# 'columns': 4,
'full_width': True,
'show_help': True,
'show_label': False
}
)
find_replace_group.add_argument(
'-replace',
# '--replace',
help='Replace with (optional): ',
gooey_options={
# 'show_border': True,
# 'help_bg_color': '#d4193c',
# 'help_color': '#f2eded',
# 'columns': 4,
'full_width': True,
'show_help': True,
'show_label': False
}
)
#Search box options for Find/Replace screen
find_replace_group_2 = find_replace.add_argument_group(
"Search Options",
gooey_options={
'show_border': True,
'margin_top': 1
}
)
#using for loop to avoid having to have 5 of these!
"""TODO implement: 'Match case',
'NFC Search mode',
'Search Text + Notes',
'Search Notes only',
'Match whole word only',
'Begins with',
'Ends with'"""
options = ['Regex']
for i in options:
find_replace_group_2.add_argument(
'--' + i,
help=i,
action='store_true',
gooey_options={
'show_label': False,
'show_help': True,
'show_border': True
}
)
# left-nav toolbar name - can't contain spaces
qa = subs.add_parser('QA-for-.oxes-files')
# heading name
qa_group = qa.add_argument_group("QA for .oxes")
qa_group.add_argument(
'-QA', #what is seen by user in GUI, can't have spaces or will cause error
# '-find', #this is what is called by args to store user input e.g. args.find_what
help='Filename (.oxes):',
widget="FileChooser",
gooey_options={
# 'show_border': True,
# 'help_bg_color': '#d4193c',
# 'help_color': '#f2eded',
# 'columns': 4,
'full_width': True,
'show_help': True,
'show_label': False
}
)
args=parser.parse_args()
run(args)
def run(args):
if args.command == "Find/Bulk-Replace":
find_replace.main(args)
if args.command == "QA-for-.oxes-files":
qa.main(args)
if __name__ == "__main__":
main()