git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SyntaxError: positional argument follows keyword argument


On 07/06/2019 19:43, Rich Shepard wrote:
> I understand positional and keyword arguments and the syntax for the
> ttk.Checkbutton as described on
> <https://www.tcl.tk/man/tcl/TkCmd/ttk_checkbutton.htm>.
> 
> $ python3 geochem.py
>  ? File "geochem.py", line 60
>  ??? ttk.Checkbutton(text='Censored?', variable=input_var),
>  ??? ^
> SyntaxError: positional argument follows keyword argument
> 
> I've provided only keyword arguments to the call to the ttk.Checkbutton
> widget and am not seeing the positional argument that follows. Please show
> me what I miss seeing here:

Context is everything!

> self.inputs['nondetect'] = LabelInput(
>  ??????????? self, 'Censored?',
>  ??????????? #input_var = tk.BooleanVar(),
>  ??????????? input_var = tk.IntVar,
>  ??????????? ttk.Checkbutton(text='Censored?', variable=input_var),
> )

Now we can see that Python isn't complaining about the arguments to 
tth.Checkbutton.  The call to ttk.Checkbutton() is itself a positional 
argument in the call to LabelInput, coming after the keyword argument 
"input_var = tk.IntVar".

-- 
Rhodri James *-* Kynesim Ltd