예제 #1
0
  def __init__(self):
    App.__init__(self, name="Lens. Widgets", inspector=True)

    self.namespaces = ['./sample-data/app']

    self.on('close', self._close_app_cb)
    self.on('get-hostname', self._get_hostname_cb)
    self.on('update-hostname', self._update_hostname_cb)
    self.on('toggle-window-fullscreen', self._fullscreen_cb)
    self.on('toggle-window-maximize', self._maximize_cb)
예제 #2
0
  def __init__(self):
    App.__init__(self, name="Lens. Widgets", inspector=True)

    self.namespaces = ['./sample-data/app']

    self.on('close', self._close_app_cb)
    self.on('get-hostname', self._get_hostname_cb)
    self.on('update-hostname', self._update_hostname_cb)
    self.on('toggle-window-fullscreen', self._fullscreen_cb)
    self.on('toggle-window-maximize', self._maximize_cb)
예제 #3
0
#! /usr/bin/env python3

import platform
from lens.app import App

app = App()


# bind to the 'close' signal
@app.bind('close')
def _close_app_cb(*args):
    app.close()


# bind to the 'get-hostname' signal
@app.bind('get-hostname')
def _get_hostname_cb(*args):
    app.emit('update-hostname', platform.node())


# start the app event loop
app.start("""
  <!DOCTYPE html>
  <html lang="en">
  <head>
    <link href="lens://css/lens.css" rel="stylesheet">
  </head>
  <body>
    <h1>Lens. Demo</h1>
    <p>This sample demonstrates simple communication between the Python and JS code paths.</p>
    <p>Hostname: <span id="hostname"></span></p>
예제 #4
0
    def __init__(self):
        Thread.__init__(self, daemon=True)

    def run(self):
        delta = random.uniform(0.05, 0.5)

        self.emit('started', self.uuid, time.time())

        for i in range(100):
            time.sleep(delta)
            self.emit('progress', self.uuid, i)

        self.emit('complete', self.uuid, time.time())


app = App(name="Lens. Threads")

# load the app entry page
app.namespaces.append('./sample-data/app-threads')


@app.bind('close')
def _close_app_cb(*args):
    app.close()


@app.bind('get-hostname')
def _get_hostname_cb(*args):
    app.emit('update-config', os.uname()[1])

예제 #5
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import platform

from lens.app import App

app = App()

# load the app entry page
app.namespaces.append('./sample-data/app-dbus')


@app.bind('close')
def _close_app_cb(*args):
    app.close()


@app.bind('get-hostname')
def _get_hostname_cb(*args):
    app.emit('update-config', platform.node())

예제 #6
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import os

from lens.app import App

app = App()

# load the app entry page
app.namespaces.append('./sample-data/app')

@app.bind('close')
def _close_app_cb(*args):
  app.close()

@app.bind('get-hostname')
def _get_hostname_cb(*args):
  app.emit('update-config', os.uname()[1])

@app.bind('update-hostname')
def _update_hostname_cb(message):
  print(message)
예제 #7
0
                        'mem_shared':
                        int(statm[2]),
                        'mem_percentage':
                        round(int(statm[1]) * 100.0 / int(meminfo[0]), 2)
                    })

                except:
                    # proc has already terminated
                    continue

            self.emit('proc-update', proc)

            time.sleep(5)


app = App(inspector=True, name='LensTop')

# load the app entry page
app.namespaces.append('./sample-data/app-top')


@app.bind('close')
def _close_app_cb(*args):
    app.close()


@app.bind('start-proc-watch')
def _start_proc_watch_cb(*args):
    t = ProcTask()
    t.daemon = True
    app.threads.add(t)
예제 #8
0
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import platform

from lens.app import App

app = App()

# load the app entry page
app.namespaces.append('./sample-data/app')


@app.bind('close')
def _close_app_cb(*args):
    app.close()


@app.bind('get-hostname')
def _get_hostname_cb(*args):
    app.emit('update-config', platform.node())

예제 #9
0
    def __init__(self):
        App.__init__(self, name="Lens. 3D", inspector=True)

        self.namespaces = ['./sample-data/app-3d']

        self.on('close', self._close_app_cb)