Beispiel #1
0
def confirmation_dialog(msg, return_retval=False,
                        cancel=False, title='',
                        timeout=None, size=None,
                        timeout_ret=None, **kw):
    if size is None:
        size = (-1, -1)
    from pychron.core.ui.dialogs import myConfirmationDialog

    dlg = myConfirmationDialog(
        cancel=cancel,
        message=msg,
        title=title,
        style='modal',
        size=size, **kw)

    if timeout_ret is not None:
        dlg.timeout_return_code = timeout_ret

    # print dlg
    retval = dlg.open(timeout)
    from pyface.api import YES, OK

    if return_retval:
        return retval
    else:

        return retval in (YES, OK)
Beispiel #2
0
def confirmation_dialog(msg,
                        return_retval=False,
                        cancel=False,
                        title='',
                        timeout=None,
                        size=None,
                        timeout_ret=None,
                        **kw):
    if size is None:
        size = (-1, -1)
    from pychron.core.ui.dialogs import myConfirmationDialog

    dlg = myConfirmationDialog(cancel=cancel,
                               message=msg,
                               title=title,
                               style='modal',
                               size=size,
                               **kw)

    if timeout_ret is not None:
        dlg.timeout_return_code = timeout_ret

    # print dlg
    retval = dlg.open(timeout)
    from pyface.api import YES, OK

    if return_retval:
        return retval
    else:

        return retval in (YES, OK)
    def select_left_down(self, event):
        """

        """
        #        item = self.valves[self.active_item]
        item = self.active_item
        if item is None:
            return

        if not isinstance(item, BaseValve):
            return

        if item.soft_lock:
            return

        state = item.state
        if isinstance(item, RoughValve) and not state:
            event.handled = True

            from pychron.core.ui.dialogs import myConfirmationDialog
            from pyface.api import NO

            dlg = myConfirmationDialog(
                message='Are you sure you want to open {}'.format(item.name),
                title='Verfiy Valve Action',
                style='modal')
            retval = dlg.open()
            if retval == NO:
                return

        state = not state

        change = False
        ok = False
        if self.manager is not None:
            if state:
            #                if self.manager.open_valve(item.name, mode = 'manual'):
                ok, change = self.manager.open_valve(item.name, mode='normal')
            #                 if self.manager.open_valve(item.name, mode='normal'):
            #                     ok = True
            else:
            #                if self.manager.close_valve(item.name, mode = 'manual'):
                ok, change = self.manager.close_valve(item.name, mode='normal')
                #                 if self.manager.close_valve(item.name, mode='normal'):
                #                     ok = True
        else:
            ok = True

        #        ok = True
        if ok and not item.soft_lock:
            item.state = state

        if change:
            self.request_redraw()
    def select_left_down(self, event):
        """

        """
        #        item = self.valves[self.active_item]
        item = self.active_item
        if item is None:
            return

        if not isinstance(item, BaseValve):
            return

        if item.soft_lock:
            return

        state = item.state
        if isinstance(item, RoughValve) and not state:
            event.handled = True

            from pychron.core.ui.dialogs import myConfirmationDialog
            from pyface.api import NO

            dlg = myConfirmationDialog(
                message='Are you sure you want to open {}'.format(item.name),
                title='Verfiy Valve Action',
                style='modal')
            retval = dlg.open()
            if retval == NO:
                return

        state = not state

        change = False
        ok = False
        if self.manager is not None:
            if state:
                #                if self.manager.open_valve(item.name, mode = 'manual'):
                ok, change = self.manager.open_valve(item.name, mode='normal')
            #                 if self.manager.open_valve(item.name, mode='normal'):
            #                     ok = True
            else:
                #                if self.manager.close_valve(item.name, mode = 'manual'):
                ok, change = self.manager.close_valve(item.name, mode='normal')
                #                 if self.manager.close_valve(item.name, mode='normal'):
                #                     ok = True
        else:
            ok = True

        #        ok = True
        if ok and not item.soft_lock:
            item.state = state

        if change:
            self.request_redraw()
Beispiel #5
0
def confirmation_dialog(msg, return_retval=False,
                        cancel=False, title='', timeout=None, size=None):

    if size is None:
        size = (-1, -1)

    dlg = myConfirmationDialog(
        cancel=cancel,
        message=msg,
        title=title,
        style='modal',
        size=size)

    retval = dlg.open(timeout)
    if return_retval:
        return retval
    else:
        from pyface.api import YES

        return retval == YES
Beispiel #6
0
def confirmation_dialog(msg,
                        return_retval=False,
                        cancel=False,
                        title='',
                        timeout=None,
                        size=None):

    if size is None:
        size = (-1, -1)

    dlg = myConfirmationDialog(cancel=cancel,
                               message=msg,
                               title=title,
                               style='modal',
                               size=size)

    retval = dlg.open(timeout)
    if return_retval:
        return retval
    else:
        from pyface.api import YES

        return retval == YES
Beispiel #7
0
 def _test(self):
     dlg = myConfirmationDialog(message='Timeout Confirm Test')
     ret = dlg.open(timeout=10)
     print 'ret', ret
Beispiel #8
0
    def select_left_down(self, event):
        """
        """
        item = self.active_item
        if item is None:
            return

        if isinstance(item, Laser):
            self._toggle_laser_state(item)
            return

        if isinstance(item, Switch):
            state = item.state
            state = not state
            mode = 'normal'
            # try:
            if state:
                ok, change = self.manager.open_valve(item.name, mode=mode)
            else:
                ok, change = self.manager.close_valve(item.name, mode=mode)
                # except TypeError, e:
                # ok, change = True, True

        else:
            if not isinstance(item, BaseValve):
                return

            if item.soft_lock:
                return

            state = item.state
            if self.confirm_open:
                from pychron.core.ui.dialogs import myConfirmationDialog
                from pyface.api import NO

                if isinstance(item,
                              ManualSwitch) or (isinstance(item, RoughValve)
                                                and not state):
                    msg = 'Are you sure you want to {} {}'.format(
                        'open' if not state else 'close', item.name)
                    # event.handled = True

                    dlg = myConfirmationDialog(message=msg,
                                               title='Verfiy Valve Action',
                                               style='modal')
                    retval = dlg.open()
                    if retval == NO:
                        return

            state = not state

            change = False
            ok = True
            if self.manager is not None:
                mode = 'normal'
                if event.shift_down:
                    mode = 'shift_select'

                try:
                    if state:
                        ok, change = self.manager.open_valve(item.name,
                                                             mode=mode)
                    else:
                        ok, change = self.manager.close_valve(item.name,
                                                              mode=mode)
                except TypeError:
                    ok, change = True, True

        if ok:
            item.state = state

        if change and ok:
            self._select_hook(item)

        if change:
            self.invalidate_and_redraw()
    def select_left_down(self, event):
        """
        """
        item = self.active_item
        if item is None:
            return

        if isinstance(item, Laser):
            self._toggle_laser_state(item)
            return

        if isinstance(item, Switch):
            state = item.state
            state = not state
            mode = 'normal'
            # try:
            if state:
                ok, change = self.manager.open_valve(item.name, mode=mode)
            else:
                ok, change = self.manager.close_valve(item.name, mode=mode)
                # except TypeError, e:
                # ok, change = True, True

        else:
            if not isinstance(item, BaseValve):
                return

            if item.soft_lock:
                return

            state = item.state
            if self.confirm_open:
                from pychron.core.ui.dialogs import myConfirmationDialog
                from pyface.api import NO

                if isinstance(item, ManualSwitch) or (isinstance(item, RoughValve) and not state):
                    msg = 'Are you sure you want to {} {}'.format('open' if not state else 'close', item.name)
                    # event.handled = True

                    dlg = myConfirmationDialog(
                        message=msg,
                        title='Verfiy Valve Action',
                        style='modal')
                    retval = dlg.open()
                    if retval == NO:
                        return

            state = not state

            change = False
            ok = True
            if self.manager is not None:
                mode = 'normal'
                if event.shift_down:
                    mode = 'shift_select'

                try:
                    if state:
                        ok, change = self.manager.open_valve(item.name, mode=mode)
                    else:
                        ok, change = self.manager.close_valve(item.name, mode=mode)
                except TypeError:
                    ok, change = True, True

        if ok:
            item.state = state

        if change and ok:
            self._select_hook(item)

        if change:
            self.invalidate_and_redraw()
Beispiel #10
0
 def _test(self):
     dlg = myConfirmationDialog(message='Timeout Confirm Test')
     ret = dlg.open(timeout=10)
     print 'ret', ret