Maybe you want "embed" in html which is much cooler it requires only one
single request/response:

def index():
   form  = SQLFORM.factory(Field('x')).process()

   img64 = None

   if form.accepted:
     img = myplotfunction(form.vars.x)
     img64 = embed64(data=img,extension='image/png') # <- ! if img not png
 then change extension !
   return locals()

{{=form}}
{{if form.accepted:}}
<img src="{{=img64}}" />
{{pass}}





2013/10/31 Massimo Di Pierro <massimo.dipie...@gmail.com>

> Not sure I understand. You have every piece you need.
>
> def index():
>    form  = SQLFORM.factory(Field('x')).process()
>    return locals()
>
> and in index.html()
>
> {{=form}}
> {{if form.accepted:}}
> <img src="{{=URL(f='myplotfunction'**, vars=dict(myvar=**
> form.vars.x))}}"/>
> {{pass}}
>
>
> On Wednesday, 30 October 2013 14:55:50 UTC-5, Josh Myers wrote:
>>
>> I have all this working the same way as Massimo suggested with
>> matplotlib, no problems.
>>
>> But, I can't for the life of me figure out how to pass a variable into
>> the controller plot function from the view.  This would be so I can, for
>> example, ask the user to choose a variable through a form and then produce
>> a histogram of that variable with matplotlib.  Right now I have it working
>> but only if the variable for the histogram is preset in the controller plot
>> function.
>>
>> I tried to set the variable with request.vars like so:
>>
>> <img src="{{=URL(f='myplotfunction'**, vars=dict(myvar=**
>> userselectedvar))}}"/>
>>
>> And then simply use request.vars.myvar in the function:
>>
>> def myplotfunction():
>>     ...
>>    return ...
>>
>> Where am I going wrong?  I am misunderstanding syntax or how request.vars
>> works?
>>
>> I would appreciate any help.
>>
>> - Josh
>>
>>  --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to