def close(self): """Close this Picture's open PictureInspector window.""" try: # Cast it into the fire. Destroy it! mw.callRemote(mw.amp.StopInspect, inspector_id=self.inspector_id) except mw.exceptions.WindowDoesNotExistError: pass
def close(self): """Close this Picture's open PictureInspector window.""" try: # Cast it into the fire. Destroy it! mw.callRemote( mw.amp.StopInspect, inspector_id=self.inspector_id) except mw.exceptions.WindowDoesNotExistError: pass
def update(self): """Update this Picture's open PictureInspector window""" # TODO: check if the same problem plagues this .update # that did the old: will it update it if the picture # size changes? try: mw.callRemote(mw.amp.UpdateInspect, inspector_id=self.inspector_id, img=self.image) except mw.exceptions.WindowDoesNotExistError: # this is what the original .update() did. Is it right? # Should we not raise a ValueError or some such thing? # i.e. if not, why not just have a show() method and no # update method at all? Food for thought. self.show()
def update(self): """Update this Picture's open PictureInspector window""" # TODO: check if the same problem plagues this .update # that did the old: will it update it if the picture # size changes? try: mw.callRemote( mw.amp.UpdateInspect, inspector_id=self.inspector_id, img=self.image) except mw.exceptions.WindowDoesNotExistError: # this is what the original .update() did. Is it right? # Should we not raise a ValueError or some such thing? # i.e. if not, why not just have a show() method and no # update method at all? Food for thought. self.show()
def choose_color(): '''Prompt user to pick a color. Return a RGB Color object.''' try: colors = mw.callRemote(mw.amp.AskColor, r=255, g=255, b=255) except mw.exceptions.DialogCanceledException: return None else: return (colors['r'], colors['g'], colors['b'])
def inspect(self): """Inspect this Picture in a PictureInspector window, where inspection of specific pixels is possible.""" self.close() self.inspector_id = mw.callRemote(mw.amp.StartInspect, img=self.image, inspectable=True)['inspector_id']
def _choose_with_remote(command): global LAST_OPENED_DIRECTORY try: path = mw.callRemote(command, initialdir=LAST_OPENED_DIRECTORY)['path'] except mw.exceptions.DialogCanceledException: return None else: LAST_OPENED_DIRECTORY = os.path.dirname(path) return path
def inspect(self): """Inspect this Picture in a PictureInspector window, where inspection of specific pixels is possible.""" self.close() self.inspector_id = mw.callRemote( mw.amp.StartInspect, img=self.image, inspectable=True)['inspector_id']
def is_closed(self): """Return True if this Picture is not being displayed.""" return mw.callRemote( mw.amp.PollInspect, inspector_id=self.inspector_id)['is_closed']
def say(text): mw.callRemote(mw.amp.Say, text=text)
def test_Say(self): _print_loud("Please enter in the contents of the following window") text = "K" mw.callRemote(mw.amp.Say, text="K") self.assertEqual(raw_input('> '), text)
def stopInspect(self): return mw.callRemote(mw.amp.StopInspect, inspector_id=self.inspector_id)
def test_askOk(self): _print_loud("Please press OK.") self.assertEqual(mw.callRemote(mw.amp.AskColor, **self.c123), self.c123)
def test_askOk(self): _print_loud("Please press OK.") self.assertEqual( mw.callRemote(mw.amp.AskColor, **self.c123), self.c123)
def is_closed(self): """Return True if this Picture is not being displayed.""" return mw.callRemote(mw.amp.PollInspect, inspector_id=self.inspector_id)['is_closed']
def startInspect(self): res = mw.callRemote(mw.amp.StartInspect, img=self.image, inspectable=True) self.inspector_id = res['inspector_id'] return res
def test_askModify(self): _print_loud("Please increase each color value by 1.") self.assertEqual(mw.callRemote(mw.amp.AskColor, **self.c123), dict((k, v + 1) for k, v in self.c123.iteritems()))
def pollInspect(self): return mw.callRemote(mw.amp.PollInspect, inspector_id=self.inspector_id)
def test_askModify(self): _print_loud("Please increase each color value by 1.") self.assertEqual( mw.callRemote(mw.amp.AskColor, **self.c123), dict((k, v+1) for k, v in self.c123.iteritems()))
def updateInspect(self): return mw.callRemote(mw.amp.UpdateInspect, inspector_id=self.inspector_id, img=self.image)
def test_askInitialDir2(self): _print_loud("Please press OK") self.assertEqual( mw.callRemote(mw.amp.AskDirectory, initialdir='/')['path'], '/')