google-code-export / tovid

Automatically exported from code.google.com/p/tovid
1 stars 0 forks source link

tovid gui "Load script" fails to load FlagOpts or SpacedText #121

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In tovid gui, if a FlagOpt such as '-showcase' is set, and saved using
"Save script", then that script is later loaded with "Load script", the
FlagOpt is correctly checked (enabled), but its associated control isn't
filled with a value.

For example, here is a saved script with '-showcase' set:

#!/usr/bin/env bash

PATH=/usr/local/lib/tovid:$PATH

todisc \
-files \
/home/eric/Videos/bar.avi \
/home/eric/Videos/foo.mpg \
-titles \
bar \
foo \
-out \
test \
-showcase \
/home/eric/Videos/foo.mpg \
-from-gui

When loading this script in the gui, it complains about the argument being
provided to '-showcase':

$ tovid gui todisc_commands.bash 
Read options from /home/eric/.tovid/tovid.ini:

Loading style from config file: '/home/eric/.metagui/config'
Loading script file 'todisc_commands.bash'
Found option: -files
  Setting list to: ['/home/eric/Videos/bar.avi', '/home/eric/Videos/foo.mpg']
Found option: -titles
  Setting list to: ['bar', 'foo']
Found option: -out
  Setting value to: test
Found option: -showcase
  Setting flag to True
Unrecognized argument: /home/eric/Videos/foo.mpg
Found option: -from-gui
  Setting flag to True
Done reading 'todisc_commands.bash'
:-) Successfully loaded 'todisc_commands.bash'

Original issue reported on code.google.com by wapcaplet88 on 6 Jun 2010 at 3:56

GoogleCodeExporter commented 9 years ago
The root problem here is in gui.py, in the load_args method. This method 
naively sets
Control values based on their vartype--in this case, since FlagOpt is a bool 
type, it
simply sets the flag and moves on. This is a design flaw that might be better 
handled
if Controls were responsible for parsing their own arguments (since they are
responsible for setting them in the first place).

Consider adding a counterpart to get_args, called set_args. Currently, the
Application starts off the chain of get_args, by calling all the Panels' 
get_args
methods, which in turn call their Controls' get_args methods. A set_args method
should work in much the same way, starting with a list of args that will be 
processed
down the chain, until a Control finds options/arguments it's interested in, and 
pops
them off the list. This chain of set_args calls should completely replace the 
current
Application.load_args method.

Original comment by wapcaplet88 on 6 Jun 2010 at 4:41

GoogleCodeExporter commented 9 years ago

Original comment by wapcaplet88 on 7 Jun 2010 at 3:56

GoogleCodeExporter commented 9 years ago
Just a note that a SpacedText "list" will also fail the load_args test.
Example: tovid gui -files 1.mpg 2.mpg -rotate-thumbs 10 12
will produce a:
"1" "0"
in the text area,
and a "Unrecognized argument: 12" in the error output.

Original comment by grepper@gmail.com on 29 Aug 2010 at 1:52

GoogleCodeExporter commented 9 years ago

Original comment by grepper@gmail.com on 29 Aug 2010 at 1:54