diff --git a/build/lib/gradio/interface.py b/build/lib/gradio/interface.py index 542927a096..0068b3b761 100644 --- a/build/lib/gradio/interface.py +++ b/build/lib/gradio/interface.py @@ -40,7 +40,8 @@ class Interface: def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None, live=False, show_input=True, show_output=True, capture_session=False, title=None, description=None, - thumbnail=None, server_port=None, server_name=networking.LOCALHOST_NAME): + thumbnail=None, server_port=None, server_name=networking.LOCALHOST_NAME, + allow_screenshot=True): """ Parameters: fn (Callable): the function to wrap an interface around. @@ -99,6 +100,7 @@ class Interface: self.examples = examples self.server_port = server_port self.simple_server = None + self.allow_screenshot = allow_screenshot Interface.instances.add(self) data = {'fn': fn, @@ -138,7 +140,8 @@ class Interface: "show_output": self.show_output, "title": self.title, "description": self.description, - "thumbnail": self.thumbnail + "thumbnail": self.thumbnail, + "allow_screenshot": self.allow_screenshot } try: param_names = inspect.getfullargspec(self.predict[0])[0] diff --git a/build/lib/gradio/static/css/gradio.css b/build/lib/gradio/static/css/gradio.css index d88acda2bf..83f07cae60 100644 --- a/build/lib/gradio/static/css/gradio.css +++ b/build/lib/gradio/static/css/gradio.css @@ -97,3 +97,6 @@ input.submit:hover { .invisible { display: none !important; } +.screenshot { + visibility: hidden; +} \ No newline at end of file diff --git a/build/lib/gradio/static/css/interfaces/output/textbox.css b/build/lib/gradio/static/css/interfaces/output/textbox.css index 04687c9285..cfaddb7191 100644 --- a/build/lib/gradio/static/css/interfaces/output/textbox.css +++ b/build/lib/gradio/static/css/interfaces/output/textbox.css @@ -2,7 +2,6 @@ width: 100%; font-size: 18px; outline: none; - height: 100%; background-color: white; border: solid 1px lightgray; border-radius: 2px; diff --git a/build/lib/gradio/static/js/gradio.js b/build/lib/gradio/static/js/gradio.js index 81d00621ec..47119835d3 100644 --- a/build/lib/gradio/static/js/gradio.js +++ b/build/lib/gradio/static/js/gradio.js @@ -18,7 +18,7 @@ function gradio(config, fn, target) {
- +
`); @@ -121,6 +121,9 @@ function gradio(config, fn, target) { io_master.last_input = null; io_master.last_output = null; }); + if (config["allow_screenshot"]) { + target.find(".screenshot").css("visibility", "visible"); + } target.find(".screenshot").click(function() { html2canvas(target[0]).then(function(canvas) { saveAs(canvas.toDataURL(), 'screenshot.png'); diff --git a/gradio/interface.py b/gradio/interface.py index 542927a096..0068b3b761 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -40,7 +40,8 @@ class Interface: def __init__(self, fn, inputs, outputs, saliency=None, verbose=False, examples=None, live=False, show_input=True, show_output=True, capture_session=False, title=None, description=None, - thumbnail=None, server_port=None, server_name=networking.LOCALHOST_NAME): + thumbnail=None, server_port=None, server_name=networking.LOCALHOST_NAME, + allow_screenshot=True): """ Parameters: fn (Callable): the function to wrap an interface around. @@ -99,6 +100,7 @@ class Interface: self.examples = examples self.server_port = server_port self.simple_server = None + self.allow_screenshot = allow_screenshot Interface.instances.add(self) data = {'fn': fn, @@ -138,7 +140,8 @@ class Interface: "show_output": self.show_output, "title": self.title, "description": self.description, - "thumbnail": self.thumbnail + "thumbnail": self.thumbnail, + "allow_screenshot": self.allow_screenshot } try: param_names = inspect.getfullargspec(self.predict[0])[0] diff --git a/gradio/static/css/gradio.css b/gradio/static/css/gradio.css index d88acda2bf..83f07cae60 100644 --- a/gradio/static/css/gradio.css +++ b/gradio/static/css/gradio.css @@ -97,3 +97,6 @@ input.submit:hover { .invisible { display: none !important; } +.screenshot { + visibility: hidden; +} \ No newline at end of file diff --git a/gradio/static/css/interfaces/output/textbox.css b/gradio/static/css/interfaces/output/textbox.css index 04687c9285..cfaddb7191 100644 --- a/gradio/static/css/interfaces/output/textbox.css +++ b/gradio/static/css/interfaces/output/textbox.css @@ -2,7 +2,6 @@ width: 100%; font-size: 18px; outline: none; - height: 100%; background-color: white; border: solid 1px lightgray; border-radius: 2px; diff --git a/gradio/static/js/gradio.js b/gradio/static/js/gradio.js index 81d00621ec..47119835d3 100644 --- a/gradio/static/js/gradio.js +++ b/gradio/static/js/gradio.js @@ -18,7 +18,7 @@ function gradio(config, fn, target) {
- +
`); @@ -121,6 +121,9 @@ function gradio(config, fn, target) { io_master.last_input = null; io_master.last_output = null; }); + if (config["allow_screenshot"]) { + target.find(".screenshot").css("visibility", "visible"); + } target.find(".screenshot").click(function() { html2canvas(target[0]).then(function(canvas) { saveAs(canvas.toDataURL(), 'screenshot.png');