Open Sensor menu on top of existing frame
170297
def on_summary_menu_open(self, widget):
        """"""
        self.original_widget = urwid.Overlay(
            self.summary_menu.main_window,
            self.original_widget,
            ('relative', self.left_margin),
            self.summary_menu.get_size()[1],
            ('relative', self.top_margin),
            self.summary_menu.get_size()[0])
367510
def on_idle(self, event):
        ''''''
        state = self.state

        if state.close_window.acquire(False):
            self.state.app.ExitMainLoop()

        now = time.time()
        if now - self.last_layout_send > 1:
            self.last_layout_send = now
            state.event_queue.put(win_layout.get_wx_window_layout(self))

        # receive any display objects from the parent
        obj = None

        while not state.object_queue.empty():
            obj = state.object_queue.get()

            if isinstance(obj, win_layout.WinLayout):
                win_layout.set_wx_window_layout(self, obj)
                
            if isinstance(obj, SlipObject):
                self.add_object(obj)

            if isinstance(obj, SlipPosition):
                # move an object
                object = self.find_object(obj.key, obj.layer)
                if object is not None:
                    object.update_position(obj)
                    if getattr(object, 'follow', False):
                        self.follow(object)
                    if obj.label is not None:
                        object.label = obj.label
                    if obj.colour is not None:
                        object.colour = obj.colour
                    state.need_redraw = True

            if isinstance(obj, SlipDefaultPopup):
                state.default_popup = obj

            if isinstance(obj, SlipInformation):
                # see if its a existing one or a new one
                if obj.key in state.info:
#                    print('update %s' % str(obj.key))
                    state.info[obj.key].update(obj)
                else:
#                    print('add %s' % str(obj.key))
                    state.info[obj.key] = obj
                state.need_redraw = True

            if isinstance(obj, SlipCenter):
                # move center
                (lat,lon) = obj.latlon
                state.panel.re_center(state.width/2, state.height/2, lat, lon)
                state.need_redraw = True

            if isinstance(obj, SlipZoom):
                # change zoom
                state.panel.set_ground_width(obj.ground_width)
                state.need_redraw = True
                
            if isinstance(obj, SlipFollow):
                # enable/disable follow
                state.follow = obj.enable

            if isinstance(obj, SlipFollowObject):
                # enable/disable follow on an object
                for layer in state.layers:
                    if obj.key in state.layers[layer]:
                        if hasattr(state.layers[layer][obj.key], 'follow'):
                            state.layers[layer][obj.key].follow = obj.enable
                
            if isinstance(obj, SlipBrightness):
                # set map brightness
                state.brightness = obj.brightness
                state.need_redraw = True

            if isinstance(obj, SlipClearLayer):
                # remove all objects from a layer
                if obj.layer in state.layers:
                    state.layers.pop(obj.layer)
                state.need_redraw = True

            if isinstance(obj, SlipRemoveObject):
                # remove an object by key
                for layer in state.layers:
                    if obj.key in state.layers[layer]:
                        state.layers[layer].pop(obj.key)
                state.need_redraw = True

            if isinstance(obj, SlipHideObject):
                # hide an object by key
                for layer in state.layers:
                    if obj.key in state.layers[layer]:
                        state.layers[layer][obj.key].set_hidden(obj.hide)
                state.need_redraw = True

        if obj is None:
            time.sleep(0.05)
1067091
def set_popup_menu(self, menu):
        ''''''
        self.popup_menu = menu
        if menu is None:
            self.wx_popup_menu = None
        else:
            self.wx_popup_menu = menu.wx_menu()
            self.frame.Bind(wx.EVT_MENU, self.on_menu)
583654
def move_to_top(self):
        """"""
        self.current_item = self.root
        for f in self._hooks["top"]:
            f(self)
        return self
1093740
function (sensorInfo, options) {
  Actuator.call(this, sensorInfo, options);

  if (sensorInfo.device.address) {
    this.gpio = new Gpio(sensorInfo.device.address, 'out');
    logger.info('powerSwitch sensor is created at driver', sensorInfo);
  } else {
    logger.warn('powerSwitch sensor address is not provided');
  }
}
1150328
def setup_menus():
    ''''''
    global TopMenu
    TopMenu.add(MPMenuSubMenu('Display',
                           items=[MPMenuItem('Map', 'Map', '# map'),
                                  MPMenuItem('Save Graph', 'Save', '# save'),
                                  MPMenuItem('Reload Graphs', 'Reload', '# reload'),
                                  MPMenuItem('FFT', 'FFT', '# fft')]))
    TopMenu.add(graph_menus())
    TopMenu.add(MPMenuSubMenu('FlightMode', items=flightmode_menu()))

    mestate.console.set_menu(TopMenu, menu_callback)
399881
def topWindow():
    
    import_qt(globals())
    
    window = QtGui.QApplication.instance().activeWindow()
    if not window:
        return None
    
    parent = window.parent()
    
    while parent:
        window = parent
        parent = window.parent()
        
    return window
752749
def motion_sensor(self, enabled):
        """"""
        if enabled is True:
            value = CONST.SETTINGS_MOTION_POLICY_ON
        elif enabled is False:
            value = CONST.SETTINGS_MOTION_POLICY_OFF
        else:
            raise SkybellException(ERROR.INVALID_SETTING_VALUE,
                                   (CONST.SETTINGS_MOTION_POLICY, enabled))

        self._set_setting({CONST.SETTINGS_MOTION_POLICY: value})
1109170
public void switchToFrame(T iframe) {
        getTargetLocator().frame(iframe);
        setCurrentContext(null);
        currentIFramePath.add(iframe);
    }
175460
function _setMenuItemsVisible() {
        var file = MainViewManager.getCurrentlyViewedFile(MainViewManager.ACTIVE_PANE),
            cMenuItems = [Commands.FILE_SAVE, Commands.FILE_RENAME, Commands.NAVIGATE_SHOW_IN_FILE_TREE, Commands.NAVIGATE_SHOW_IN_OS],
            // Enable menu options when no file is present in active pane
            enable = !file || (file.constructor.name !== "RemoteFile");
        
            // Enable or disable commands based on whether the file is a remoteFile or not.
            cMenuItems.forEach(function (item) {
                CommandManager.get(item).setEnabled(enable);
            });
    }
1169261
def mouse_event_callback(self, window, xpos, ypos):
        
        # screen coordinates relative to the top-left corner
        self.example.mouse_position_event(xpos, ypos)
788524
public function bootMenus()
    {
        $name = 'menu.top.right';
        view()->composer('antares/foundation::*', function () use ($name) {
            if (!Registry::isRegistered('menu.' . $name)) {
                $this->app->instance($name, $this->app->make('antares.widget')->make($name));
                $selector = new ComponentsSelector($this->app, $name);
                $selector->handle();
                Registry::set('menu.' . $name, $selector);
            }
        });
    }
698029
def add_sensor(self, sensorid=None):
        """"""
        if sensorid is None:
            sensorid = self._get_next_id()
        if sensorid is not None and sensorid not in self.sensors:
            self.sensors[sensorid] = Sensor(sensorid)
        return sensorid if sensorid in self.sensors else None
763286
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private void setupActionBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            // Show the Up button in the action bar.
            getActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }
1070514
def click(self, x, y):
        '''
        
        '''
        self._run_nowait('target.tap({x: %d, y: %d})' % (x/self._scale, y/self._scale))
        return self
215387
public void switchToParentFrame() {
        if (!currentIFramePath.isEmpty()) {
            // copy path since substring creates a view, not a deep copy
            List<T> newPath = currentIFramePath.subList(0, currentIFramePath.size() - 1);
            newPath = new ArrayList<T>(newPath);
            // Safari and PhantomJs don't support switchTo.parentFrame, so we do this
            // it works for Phantom, but is VERY slow there (other browsers are slow but ok)
            switchToDefaultContent();
            for (T iframe : newPath) {
                switchToFrame(iframe);
            }
        }
    }
813047
def toggle_sensor(request, sensorname):
    
    if service.read_only:
        service.logger.warning("Could not perform operation: read only mode enabled")
        raise Http404
    source = request.GET.get('source', 'main')
    sensor = service.system.namespace[sensorname]
    sensor.status = not sensor.status
    service.system.flush()
    return HttpResponseRedirect(reverse(source))