u
This commit is contained in:
parent
9809bb55e5
commit
4bcd117e77
2 changed files with 45 additions and 0 deletions
43
gui.py
Normal file
43
gui.py
Normal 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))
|
||||||
|
else:
|
||||||
|
nbt = assemble_nbtfile(*read_imtuple(args.input, args.palette))
|
||||||
|
print(nbt.pretty())
|
||||||
|
with gzip.open(args.output, 'w') as f:
|
||||||
|
nbt.save(f)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
2
req-gooey.txt
Normal file
2
req-gooey.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
gooey==1.0.3
|
||||||
|
wxPython==4.0.7.post2
|
Loading…
Reference in a new issue