Callback for the shot open button

        :returns: None
        :rtype: None
        :raises: None
491061
def shot_open_callback(self, *args, **kwargs):
        
        tf = self.browser.get_current_selection(1)
        if not tf:
            return
        if not os.path.exists(tf.path):
            msg = 'The selected shot does not exist: %s' % tf.path
            log.error(msg)
            self.statusbar.showMessage(msg)
            return
        js = JukeboxSignals.get()
        js.before_open_shot.emit(tf)
        self.open_shot(tf)
        js.after_open_shot.emit(tf)
126317
def button_clicked(self, button):
        
        if button is self.idx_ok:

            #new_format = self.new_format.get_value().lower()
            new_format = 'edf'
            chan = None
            beg = None
            end = None

            if not self.all_time.get_value():
                beg = self.times['beg'].get_value()
                end = self.times['end'].get_value()

            if not self.all_chan.get_value():
                chan = self.get_channels()

            self.parent.info.export(new_format, filename=self.filename,
                                    chan=chan, begtime=beg, endtime=end)

            self.accept()

        if button is self.idx_cancel:
            self.reject()
790781
def session_demo_alert_callback(n_clicks, session_state=None, **kwargs):
    ''
    if session_state is None:
        raise NotImplementedError("Cannot handle a missing session state")
    csf = session_state.get('bootstrap_demo_state', None)
    if not csf:
        csf = dict(clicks=0)
        session_state['bootstrap_demo_state'] = csf
    else:
        csf['clicks'] = n_clicks
    return "Button has been clicked %s times since the page was rendered" %n_clicks
745223
def capture(self, *args, **kwargs):
        
        if not self.is_enabled():
            return

        data = self.build_msg(*args, **kwargs)

        future = self.send(callback=kwargs.get('callback', None), **data)

        return (data['event_id'], future)
676943
def on_setButton_pressed(self):
        
        self.keyLabel.setText("Press a key or combination...")  # TODO: i18n
        logger.debug("User starts to record a key combination.")
        self.grabber = iomediator.KeyGrabber(self)
        self.grabber.start()
835189
def on_open(self, callback, timeout):
        
        super().on_open()
        self.callback = callback
        self.timeout = timeout
        self.revive_event = asyncio.Event(loop=self.loop)
208433
function( callback ) {

    var self = this

    // Close a previously opened handle
    if( this.fd != null ) {
      return this.close( function( error ) {
        if( error != null )
          return callback.call( self, error )
        self.open( callback )
      })
    }

    // Open a new fd handle
    debug( 'fs:open', this.mode, this.path )
    this.fs.open( this.path, this.mode, function( error, fd ) {

      if( error != null )
        return callback.call( self, error, fd )

      // Set file descriptor
      self.fd = fd

      // If no blockSize has been set, attempt to
      // detect it after opening the device
      if( self.blockSize == null || self.blockSize <= 0 ) {
        self.detectBlockSize( 0, 0, 0, function( error, blockSize ) {
          self.blockSize = blockSize || -1
          callback.call( self, error, self.fd )
        })
      } else {
        callback.call( self, error, fd )
      }

    })

    return this

  }
1225533
def u2opener(self):
        
        if self.urlopener is None:
            return urllib2.build_opener(*self.u2handlers())
        return self.urlopener
716192
def apply_clicked(self, button):
        
        if isinstance(self.model.state, LibraryState):
            logger.warning("It is not allowed to modify libraries.")
            self.view.set_text("")
            return

        # Ugly workaround to give user at least some feedback about the parser
        # Without the loop, this function would block the GTK main loop and the log message would appear after the
        # function has finished
        # TODO: run parser in separate thread
        while Gtk.events_pending():
            Gtk.main_iteration_do(False)

        # get script
        current_text = self.view.get_text()

        # Directly apply script if linter was deactivated
        if not self.view['pylint_check_button'].get_active():
            self.set_script_text(current_text)
            return

        logger.debug("Parsing execute script...")
        with open(self.tmp_file, "w") as text_file:
            text_file.write(current_text)

        # clear astroid module cache, see http://stackoverflow.com/questions/22241435/pylint-discard-cached-file-state
        MANAGER.astroid_cache.clear()
        lint_config_file = resource_filename(rafcon.__name__, "pylintrc")
        args = ["--rcfile={}".format(lint_config_file)]  # put your own here
        with contextlib.closing(StringIO()) as dummy_buffer:
            json_report = JSONReporter(dummy_buffer.getvalue())
            try:
                lint.Run([self.tmp_file] + args, reporter=json_report, exit=False)
            except:
                logger.exception("Could not run linter to check script")
        os.remove(self.tmp_file)

        if json_report.messages:
            def on_message_dialog_response_signal(widget, response_id):
                if response_id == 1:
                    self.set_script_text(current_text)
                else:
                    logger.debug("The script was not saved")
                widget.destroy()

            message_string = "Are you sure that you want to save this file?\n\nThe following errors were found:"

            line = None
            for message in json_report.messages:
                (error_string, line) = self.format_error_string(message)
                message_string += "\n\n" + error_string

            # focus line of error
            if line:
                tbuffer = self.view.get_buffer()
                start_iter = tbuffer.get_start_iter()
                start_iter.set_line(int(line)-1)
                tbuffer.place_cursor(start_iter)
                message_string += "\n\nThe line was focused in the source editor."
                self.view.scroll_to_cursor_onscreen()

            # select state to show source editor
            sm_m = state_machine_manager_model.get_state_machine_model(self.model)
            if sm_m.selection.get_selected_state() is not self.model:
                sm_m.selection.set(self.model)

            dialog = RAFCONButtonDialog(message_string, ["Save with errors", "Do not save"],
                               on_message_dialog_response_signal,
                               message_type=Gtk.MessageType.WARNING, parent=self.get_root_window())
            result = dialog.run()
        else:
            self.set_script_text(current_text)
553580
def on_click(self, event):
        
        button = event["button"]
        if button == self.button_toggle:
            self.toggled = True
            if self.mode == "ip":
                self.mode = "status"
            else:
                self.mode = "ip"
        elif button == self.button_refresh:
            self.idle_time = 0
        else:
            self.py3.prevent_refresh()
1081109
def u2opener(self):
        
        if self.urlopener is None:
            return u2.build_opener(*self.u2handlers())
        else:
            return self.urlopener
673494
def opened(self, *args):
        
        self._serial_open = True

        self.log("Opened: ", args, lvl=debug)
        self._send_command(b'l,1')  # Saying hello, shortly
        self.log("Turning off engine, pump and neutralizing rudder")
        self._send_command(b'v')
        self._handle_servo(self._machine_channel, 0)
        self._handle_servo(self._rudder_channel, 127)
        self._set_digital_pin(self._pump_channel, 0)
        # self._send_command(b'h')
        self._send_command(b'l,0')
        self._send_command(b'm,HFOS Control')
361590
def cancel_button_clicked(self):
        """"""
        # Change mode
        self.mode = CHOOSE_MODE
        # Enable all edit buttons and combo boxes
        for i in range(len(self.exposures)):
            if i == self.special_case_index:
                self.exposure_edit_buttons[i].setEnabled(False)
                self.exposure_combo_boxes[i].setEnabled(False)
                continue
            if self.get_classification(self.exposure_combo_boxes[i]):
                self.exposure_edit_buttons[i].setEnabled(True)
            else:
                self.exposure_edit_buttons[i].setEnabled(False)
            # self.exposure_edit_buttons[i].setText(tr('Edit'))
            self.exposure_combo_boxes[i].setEnabled(True)

        # Clear right panel
        clear_layout(self.right_layout)
        # Show current state
        self.show_current_state()
        # Unset active exposure
        self.active_exposure = None

        self.parent.pbnNext.setEnabled(self.is_ready_to_next_step())
997971
def on_widget__button_press_event(self, widget, event):
        '''
        
        '''
        if self.mode == 'register_video' and event.button == 1:
            self.start_event = event.copy()
            return
        elif self.mode == 'control':
            shape = self.canvas.find_shape(event.x, event.y)

            if shape is None: return
            state = event.get_state()
            if event.button == 1:
                # Start a new route.
                self._route = Route(self.device)
                self._route.append(shape)
                self.last_pressed = shape
                if not (state & gtk.gdk.MOD1_MASK):
                    # `<Alt>` key is not held down.
                    self.emit('route-electrode-added', shape)
1256339
def handleButtonClick(self, button):
        
        if ( self.signalsBlocked() ):
            return
        
        if ( button == self._buttonBox.button(QDialogButtonBox.Reset) ):
            self.resetRequested.emit()
        
        self.buttonClicked.emit(button)
138496
def open_camera(
        self, input_source: str, extra_cmd: Optional[str] = None
    ) -> Coroutine:
        
        command = ["-an", "-c:v", "mjpeg"]

        return self.open(
            cmd=command,
            input_source=input_source,
            output="-f mpjpeg -",
            extra_cmd=extra_cmd,
        )
559164
def open(self):
        '''
        
        '''
        args = Writer()
        args.write_shortstr('')
        self.send_frame(MethodFrame(self.channel_id, 20, 10, args))
        self.channel.add_synchronous_cb(self._recv_open_ok)