Change image_viewer to Plugin property.

Raise an error when using Plugin.image_viewer before it is set. This error prevents other, more obscure, errors from getting raised.
This commit is contained in:
Tony S Yu
2012-07-23 00:45:11 -04:00
parent df18d40290
commit 977d17134d
+10
View File
@@ -48,6 +48,16 @@ class Plugin(QtGui.QDialog):
self.cids = []
self.artists = []
@property
def image_viewer(self):
if self._image_viewer is None:
raise RuntimeError("Plugin is not attached to ImageViewer")
return self._image_viewer
@image_viewer.setter
def image_viewer(self, image_viewer):
self._image_viewer = image_viewer
def attach(self, image_viewer):
self.setParent(image_viewer)
self.setWindowFlags(Qt.Dialog)