-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ More control over property setter for extended details
- Loading branch information
1 parent
94d928d
commit 9b36ae7
Showing
2 changed files
with
28 additions
and
2 deletions.
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
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,26 @@ | ||
from jurialmunkey.parser import try_type | ||
|
||
|
||
class PropertySetter(): | ||
@property | ||
def property_window(self): | ||
try: | ||
return self._property_window | ||
except AttributeError: | ||
import xbmcgui | ||
try: | ||
self._property_window = xbmcgui.Window(10000) | ||
except RuntimeError: # If window id does not exist | ||
return | ||
return self._property_window | ||
|
||
def get_property(self, name, set_property=None, clear_property=False, is_type=None): | ||
if not self.property_window: | ||
return | ||
name = f'TMDbHelper.{name}' | ||
ret_property = set_property or self.property_window.getProperty(name) | ||
if clear_property: | ||
self.property_window.clearProperty(name) | ||
if set_property is not None: | ||
self.property_window.setProperty(name, f'{set_property}') | ||
return try_type(ret_property, is_type or str) |