Can't Save Bokeh Plot with Panel from PyViz Example - python

I have been working through the tutorials on pyviz.org. specifically the dashboard one
If I setup the example here: http://pyviz.org/tutorial/A2_Dashboard_Workflow.html
The save icon in the bokeh plot appears to be disabled. If I click area zoom, wheel zoom,or the reset icon they behave as expected. But the save button does nothing.
Is this intentional, able to be reset, or a bug on my side?
Ben

This is a fundamental limitation of browsers, the issue is that the map tiles in the background are making cross-origin requests to download the tiles. Browsers consider this a security issue and therefore mark the canvas as tainted. If you look at the browser console you'll see this error message when hitting save:
Uncaught DOMException: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
In recent versions of GeoViews we therefore automatically disable the save tool if a tile source is present, but the website was built using an older version.
TL;DR: It's a browser security issue and cannot be resolved afaik.

Related

Gain colour of a known coordinate on screen in python

I'm trying to automate a specific task using python. I need to execute a specific task when a specific colour pops up on the display. For example:
During the automation process, when the code to open a web browser is executed and a web browser pops up,I need to make sure that it actually worked, by detecting the colour at the exact coordinate where the logo of the browser is situated. So that it confirms the browser is open, then I need to use that information to execute another code.
As we know, when we try to open a browser, there will be a lag to open up the browser. Since that lag will be different, I need to execute the next code only after opening the browser.
I have gone too far with my explanation, but if you got any idea from what I have just explained, please help me with what you know?

To get web browser full size in python bokeh

I use Bokeh to plot some interactive charts for my project, the Bokeh app runs on server. I like these charts can be plotted in full size on clients' browsers no matter what local resolution would be. Could someone give me a clue on how to get remote screen's max size?
I tried selenium, which asks user install drivers on local computer. It is not a good idea.
Also I tried python win32 API, which gets server's not remote computer's resolution.
Thanks
I don't know how to get the screen's size, but I have made my bokeh figures take up the full browser window (not necessarily full screen, but would be if the browser was full screen).
Instead of:
figure(plot_width = ... , plot_height = ... , ...)
I used:
figure(sizing_mode="stretch_both", ...)
("scale_both" is an alternative, which keeps the height/width ratio if you set those too).
Info from bokeh documentation.

Resizing Window in Kivy Android App on softkeyboard with SDL2

I am currently working on an Android App using the Python and the Kivy Framework. The majority of the screen's real estate is used by a text_input widget. I would like to resize this text_input when the android soft keyboard pops ups so that the text_input ends right at the top of the keyboard.
To accomplish this I tried to use Window.softinput_mode='resize' and when that didn't work, reference the Window.keyboard_height to do my own resize and positioning. As per the documentation and comment in the Window source code I see that both are not supported when using SDL2 on Android (Kivy 1.9 - 1.10).
I tested Window.softinput_mode='below_target' which doesn't seem to do anything and Window.softinput_mode='pan' which works but doesn't give me the correct functionality.
The last thing I tried is to set Window.softinput_mode='pan' and with a function call that is bound to the on_keyboard event print out the value of Window.top so that if the panning simply shifted the Window location upward, I could use that point of reference to do my positioning and resizing. However the value of Window.top does not apear to change when panning up.
The only other stack flow that referenced this issue and gave a working example made use of resize mode which doesn't work using SDL2.
Properly resize main kivy window when soft keyboard appears on android
Is there any work-around to accomplish this functionality or a different provider than SDL2 that will work well on Android?
It seems to be a bug, so I think first step would be to report it here. May be someone will fix it or prompt you workaround.
While googling subject I found this get_keyboard_height() implementation. Since it's part of android module, try to add this recipe to your buildozer requirements. It may fix Window.keyboard_height or may just provide get_keyboard_height() function to get correct high manually.

Bokeh plots distorting nbviewer slides view

When using the web based iPython Notebook/Jupyter capability, i created a notebook with markdown cells of text and code cells to display the code and plots for matplotlib and bokeh. I then download that as .ipynb open with sublime, copy and paste to git, then access it on nbviewer through my git account. When looking at it here:
http://nbviewer.ipython.org/github/angisgrate/test/blob/master/pyohio3.ipynb
in notebook view, it works fine. the markdown, code, and plot steps are all there.
When switching to slides view, the intent of the creation needed for the presentation, this code blocks occurs first, blocking out the first 10 markdown steps and all the matplotlib steps, rendering this weird code without the plots:
http://nbviewer.ipython.org/format/slides/github/angisgrate/test/blob/master/pyohio3.ipynb
How can i fix this asap?? I've looked through and there was a similar problem in 2014 with slides, but it yielded an actual "Error" that i'm not seeing, just this contorted view
I can't say for certain. It's possible in the nbviewer slides view, the execution of JavaScript is suppressed (this happens on GitHub notebook previews, for instance). All of the rendering in Bokeh actually happens from the JavaScript library BokehJS, so if this is the case, then Bokeh will not function, and there is nothing really that can be done. This is probably a question bset directed towards the nbviewer team/community to find out the specifics of how the slides view behaves (and is intended to behave) with respect to executing embedded JavaScript.
Edit: Looks like this is a known/discussed issue. More information here: Issue #484: Jupyter>>nbviewer slides Fail, notebook view fine by angisgrate in jupyter/nbviewer on GitHub

A wx python application that uses Google maps

I intend to makea wx python application that can request and show the google map (or map from another similar map service) for a specific set of coordinates.
The application should:
Show a particular section of the map, rather than the whole screen.
Be able to adjust the resolution/magnification of image.
Be able to show map view and satelite image.
Where do I start?
Where to start:
import wx
Now that I have that out of my system :-) ... The first place you should start is to determine if wx can host a browser capable of displaying google maps. wxPython on windows can natively host IE so you could use that for displaying google maps on windows. (Dig around in the demo)
I am not sure if you can host Mozilla or Chrome inside a wx application. So, first determine if you can even display google maps in a wx app.
There is no pre-made widget that can do this for you. wxPython does have a WebView widget, starting in wxPython 2.9, that uses a web browser on the backend and is a bit more robust than the ActiveX version of the widget that was in older versions of wx. You could use that to display the map. Note that you will still need to figure out how to send Google API commands to the wrapped browser instance to manipulate the map.
You might also take a look at PySlip, which can be used to display large images in a tiled manner: https://code.google.com/p/pyslip/wiki/Introduction

Categories