master r1
JerryXiao 2021-09-30 15:12:04 +08:00
parent 9809bb55e5
commit 4bcd117e77
Signed by: Jerry
GPG Key ID: 22618F758B5BE2E5
2 changed files with 45 additions and 0 deletions

43 Normal file
View File

@ -0,0 +1,43 @@
from schemgen import assemble_nbtfile, read_text, read_imtuple
import gzip
from gooey import Gooey, GooeyParser, python_bindings, util
def apply_default_rewrites(spec):
getin = util.functional.getin
top_level_subgroups = list(spec['widgets'].keys())
for subgroup in top_level_subgroups:
path = ['widgets', subgroup, 'contents']
contents = getin(spec, path)
for group in contents:
if group['name'] == 'optional arguments':
group['name'] = 'Settings'
return spec
python_bindings.argparse_to_json.apply_default_rewrites = apply_default_rewrites
@Gooey(program_name="schemgen", navigation="TABBED", optional_cols=2, show_restart_button=False, advanced=True)
def main():
import argparse
parser = GooeyParser(description='schemgen')
s = parser.add_subparsers(help='', dest='')
g1 = s.add_parser("text")
g2 = s.add_parser("image")
g1.add_argument('-o', '--output', default='output.schem', help='output worldedit schema file', widget="FileSaver")
g2.add_argument('-o', '--output', default='output.schem', help='output worldedit schema file', widget="FileSaver")
g2.add_argument('-i', '--input', type=str, default="input.png", help='input image', widget="FileChooser")
g1.add_argument('-t', '--text', type=str, default="", help='input text')
g2.add_argument('-p', '--palette', type=str, default="minecraft.gpl", help='gimp palette file', widget="FileChooser")
args = parser.parse_args()
if getattr(args, 'text', None) is not None:
assert args.text
nbt = assemble_nbtfile(*read_text(args.text))
nbt = assemble_nbtfile(*read_imtuple(args.input, args.palette))
with, 'w') as f:
if __name__ == "__main__":

req-gooey.txt Normal file
View File

@ -0,0 +1,2 @@