Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
 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()
Esempio n. 4
0
 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()
Esempio n. 5
0
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'])
Esempio n. 6
0
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'])
Esempio n. 7
0
    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']
Esempio n. 8
0
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
Esempio n. 9
0
    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']
Esempio n. 10
0
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
Esempio n. 11
0
 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']
Esempio n. 12
0
def say(text):
    mw.callRemote(mw.amp.Say, text=text)
Esempio n. 13
0
 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)
Esempio n. 14
0
 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)
Esempio n. 16
0
 def test_askOk(self):
     _print_loud("Please press OK.")
     self.assertEqual(
         mw.callRemote(mw.amp.AskColor, **self.c123),
         self.c123)
Esempio n. 17
0
 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']
Esempio n. 18
0
 def startInspect(self):
     res = mw.callRemote(mw.amp.StartInspect, img=self.image,
                         inspectable=True)
     self.inspector_id = res['inspector_id']
     return res
Esempio n. 19
0
def say(text):
    mw.callRemote(mw.amp.Say, text=text)
 def stopInspect(self):
     return mw.callRemote(mw.amp.StopInspect,
                          inspector_id=self.inspector_id)
 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 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 startInspect(self):
     res = mw.callRemote(mw.amp.StartInspect,
                         img=self.image,
                         inspectable=True)
     self.inspector_id = res['inspector_id']
     return res
Esempio n. 24
0
 def pollInspect(self):
     return mw.callRemote(mw.amp.PollInspect,
         inspector_id=self.inspector_id)
Esempio n. 25
0
 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()))
Esempio n. 26
0
 def updateInspect(self):
     return mw.callRemote(mw.amp.UpdateInspect, 
         inspector_id=self.inspector_id,
         img=self.image)
 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'], '/')
 def pollInspect(self):
     return mw.callRemote(mw.amp.PollInspect,
                          inspector_id=self.inspector_id)
Esempio n. 30
0
 def test_askInitialDir2(self):
     _print_loud("Please press OK")
     self.assertEqual(
         mw.callRemote(mw.amp.AskDirectory, initialdir='/')['path'],
         '/')