Re: [web2py] embed image from variable

2013-11-04 Thread Josh Myers
Thank you Massimo.  Everything is working now.  I misunderstood something.
 
Michele, thanks for the tip!
 

On Thursday, October 31, 2013 1:50:02 PM UTC-4, Michele Comitini wrote:

> 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:}}
> 
> {{pass}}
>
>
>
>
>
> 2013/10/31 Massimo Di Pierro >
>
>> 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:}}
>> 
>> {{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:
>>>
>>> 
>>>
>>> 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+un...@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.


Re: [web2py] embed image from variable

2013-10-31 Thread Michele Comitini
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:}}

{{pass}}





2013/10/31 Massimo Di Pierro 

> 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:}}
> 
> {{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:
>>
>> 
>>
>> 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.


Re: [web2py] embed image from variable

2013-10-30 Thread Massimo Di Pierro
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:}}

{{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:
>
> 
>
> 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.


Re: [web2py] embed image from variable

2013-10-30 Thread Josh Myers
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:



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.


Re: [web2py] embed image from variable

2013-01-29 Thread Massimo Di Pierro
You do not return the image that way. You need two actions, one only 
returns plot() (the binary data) and another would be a regular action 
which display a link to the other action.

def myimage(): return plot()

def Testing(): return dict() # in view  ...

On Tuesday, 29 January 2013 10:53:03 UTC-6, BlueShadow wrote:
>
> I did some experimenting the problem is putting the image into the return 
> dict() or into any variable.
> I got no clue how to fix it or why that is the problem.
>
> On Tuesday, January 29, 2013 5:07:16 PM UTC+1, BlueShadow wrote:
>>
>> I tried that but it doesn't show an image it puts the img tag in the html 
>> code and fills the src="binary" with the pinary stuff but no image is 
>> displayed
>>
>> On Tuesday, January 29, 2013 4:53:33 PM UTC+1, rochacbruno wrote:
>>>
>>> I guess you can try
>>>  
>>>
 {{=IMG(_src=plotimg)}}
>>>
>>>
>>> or 
>>>
>>>  
>>>
>>>
>>>

-- 

--- 
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.




Re: [web2py] embed image from variable

2013-01-29 Thread BlueShadow
I did some experimenting the problem is putting the image into the return 
dict() or into any variable.
I got no clue how to fix it or why that is the problem.

On Tuesday, January 29, 2013 5:07:16 PM UTC+1, BlueShadow wrote:
>
> I tried that but it doesn't show an image it puts the img tag in the html 
> code and fills the src="binary" with the pinary stuff but no image is 
> displayed
>
> On Tuesday, January 29, 2013 4:53:33 PM UTC+1, rochacbruno wrote:
>>
>> I guess you can try
>>  
>>
>>> {{=IMG(_src=plotimg)}}
>>
>>
>> or 
>>
>>  
>>
>>
>>

-- 

--- 
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.




Re: [web2py] embed image from variable

2013-01-29 Thread BlueShadow
I tried that but it doesn't show an image it puts the img tag in the html 
code and fills the src="" with the pinary stuff but no image is displayed

On Tuesday, January 29, 2013 4:53:33 PM UTC+1, rochacbruno wrote:
>
> I guess you can try
>  
>
>> {{=IMG(_src=plotimg)}}
>
>
> or 
>
>  
>
>
>

-- 

--- 
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.




Re: [web2py] embed image from variable

2013-01-29 Thread Bruno Rocha
I guess you can try


> {{=IMG(_src=plotimg)}}


or



-- 

--- 
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.