-
Notifications
You must be signed in to change notification settings - Fork 427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux ScreenShot feature added #319
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
34d6d1e
linux screenshot added
bhaveshAn 4359fae
readme change
bhaveshAn 2f4131d
pep8 fixes
bhaveshAn d26867c
pep8 in facade
bhaveshAn 8f040da
Merge remote-tracking branch 'upstream/master' into linux_screenshot
bhaveshAn 6e65e38
pep8 fixes in temperature facade
bhaveshAn 587cdf0
setting default_path to test.jpg
bhaveshAn 1399234
pep8 fix in screenshot facade
bhaveshAn 5928386
added screenshotdemo.kv file
bhaveshAn 6c9bf80
Merge remote-tracking branch 'upstream/master' into linux_screenshot
bhaveshAn 845f1e4
making example working without kv file
bhaveshAn e7d975e
pep8 in screenshot main.py
bhaveshAn 2b3ed6b
changing ScreenShot to Screenshot
bhaveshAn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,6 @@ venv | |
|
||
bin | ||
.buildozer | ||
.idea | ||
.idea | ||
*.jpg | ||
*.mp3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from kivy.app import App | ||
from kivy.lang import Builder | ||
from kivy.properties import NumericProperty | ||
from kivy.properties import ObjectProperty | ||
from kivy.uix.boxlayout import BoxLayout | ||
|
||
|
||
Builder.load_string(''' | ||
#:import screenshot plyer.screenshot | ||
<ScreenShotDemo>: | ||
screenshot: screenshot | ||
orientation: 'vertical' | ||
padding: '50dp' | ||
spacing: '20dp' | ||
Label: | ||
id: location_label | ||
size_hint_y: None | ||
height: sp(40) | ||
text: 'ScreenShot Location: ' + str(root.screenshot.file_path) | ||
|
||
Button: | ||
id: record_button | ||
text: 'Take Shot' | ||
on_release: root.shot() | ||
''') | ||
|
||
|
||
class ScreenShotDemo(BoxLayout): | ||
'''Root Widget.''' | ||
screenshot = ObjectProperty() | ||
|
||
def shot(self): | ||
self.screenshot.shot() | ||
|
||
|
||
class ScreenShotApp(App): | ||
|
||
def build(self): | ||
return ScreenShotDemo() | ||
|
||
def on_pause(self): | ||
return True | ||
|
||
if __name__ == "__main__": | ||
ScreenShotApp().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
''' | ||
Screenshot | ||
===== | ||
|
||
The :class:`Screenshot` is used for recording audio. | ||
|
||
Default path for taking screenshot is set in platform implementation. | ||
|
||
Simple Examples | ||
--------------- | ||
|
||
To get the file path:: | ||
|
||
>>> screenshot.file_path | ||
'/sdcard/test.jpg' | ||
|
||
To set the file path:: | ||
|
||
>>> import os | ||
>>> current_list = os.listdir('.') | ||
['/sdcard/testrecorder.jpg', '/sdcard/testrecorder1.jpg', | ||
'/sdcard/testrecorder2.jpg', '/sdcard/testrecorder3.jpg'] | ||
>>> file_path = current_list[2] | ||
>>> screenshot.file_path = file_path | ||
|
||
To take screenshot:: | ||
|
||
>>> from plyer import screenshot | ||
>>> screenshot.shot() | ||
''' | ||
|
||
|
||
class Screenshot(object): | ||
''' | ||
ScreenShot facade. | ||
''' | ||
_file_path = '' | ||
|
||
def __init__(self, file_path): | ||
super(Screenshot, self).__init__() | ||
self._file_path = file_path | ||
|
||
def shot(self): | ||
self._shot() | ||
|
||
@property | ||
def file_path(self): | ||
return self._file_path | ||
|
||
@file_path.setter | ||
def file_path(self, location): | ||
''' | ||
Location of the screenshot. | ||
''' | ||
assert isinstance(location, (basestring, unicode)), \ | ||
'Location must be string or unicode' | ||
self._file_path = location | ||
|
||
# private | ||
|
||
def _shot(self, **kwargs): | ||
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import subprocess | ||
from plyer.facades import Screenshot | ||
from plyer.utils import whereis_exe | ||
|
||
|
||
class GnomeScreenshot(Screenshot): | ||
def __init__(self, file_path=None): | ||
default_path = 'test.jpg' | ||
super(GnomeScreenshot, self).__init__(file_path or default_path) | ||
|
||
def _take_shot(self): | ||
subprocess.call(["gnome-screenshot", "-d", "2", self.file_path]) | ||
|
||
|
||
class ImportScreenshot(Screenshot): | ||
def __init__(self, file_path=None): | ||
default_path = 'test.jpg' | ||
super(ImportScreenshot, self).__init__(file_path or default_path) | ||
|
||
def _take_shot(self): | ||
subprocess.call(["import", "-window", "root", self.file_path]) | ||
|
||
|
||
def instance(): | ||
if whereis_exe('gnome-screenshot'): | ||
return GnomeScreenshot() | ||
elif whereis_exe('import'): | ||
return ImportScreenshot() | ||
return Screenshot() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't tried it yet, but this seems smelly to me. Have you tried it both with py2 and py3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is also have been used in the audio facade from long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely doesn't work on py3. To be more precise:
If there isn't some background magic going on, then I believe even the audio part is broken for py3, unfortunately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What say If I remove it. @KeyWeeUsr