Beispiel #1
0
def main():
    #p = Project()
    #root = p.load('./example_project.py')
    #p.append(root, "root")
    #p.save(None)
    
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(Editor, debug=False, address='0.0.0.0', port=8082)
from remi import start, App


class MyApp(App):
    def __init__(self, *args):
        super(MyApp, self).__init__(*args)

    def main(self):
        container = gui.VBox(width=120, height=100)
        self.lbl = gui.Label('Hello world!')
        self.bt = gui.Button('Press me!')

        # setting the listener for the onclick event of the button
        self.bt.onclick.connect(self.on_button_pressed)

        # appending a widget to another, the first argument is a string key
        container.append(self.lbl)
        container.append(self.bt)

        # returning the root widget
        return container

    # listener function
    def on_button_pressed(self, widget):
        self.lbl.set_text('Button pressed!')
        self.bt.set_text('Hi!')


# starts the web server
start(MyApp)
Beispiel #3
0
class MyApp(App):
    def __init__(self, *args):
        res_path = os.path.join(os.path.dirname(__file__), 'res')
        super(MyApp, self).__init__(*args, static_file_path=res_path)

    def idle(self):
        pass

    def main(self):
        self.floatingPaneContainer = FloatingPanesContainer(width=800, height=600, margin='0px auto')
        self.floatingPaneContainer.append(gui.Label("Click a panel to select, than drag and stretch"))

        pane1 = gui.Widget(width=100, height=200)
        pane1.style['background-color'] = 'yellow'
        self.floatingPaneContainer.add_pane(pane1, 10, 100)
        pane1.append(gui.Label("Panel1, drag and stretch"))

        pane2 = gui.VBox(width=100, height=200)
        pane2.style['background-color'] = 'green'
        self.floatingPaneContainer.add_pane(pane2, 150, 100)
        pane2.append(gui.Label("Panel2, drag and stretch"))
        

        # returning the root widget
        return self.floatingPaneContainer


    
if __name__ == "__main__":
    start(MyApp, debug=False, address='0.0.0.0', port=8082, update_interval=2.0)
Beispiel #4
0
    def main(self, name='world'):
        # the arguments are	width - height - layoutOrientationOrizontal
        wid = gui.Widget(120, 100, False, 10)
        self.lbl = gui.Label(100, 30, 'Hello %s!' % name)
        self.bt = gui.Button(100, 30, 'Press me!')

        # setting the listener for the onclick event of the button
        self.npressed = 0
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        # appending a widget to another, the first argument is a string key
        wid.append(self.lbl)
        wid.append(self.bt)

        # returning the root widget
        return wid

    # listener function
    def on_button_pressed(self):
        self.npressed += 1
        self.lbl.set_text('Button pressed %s times' % self.npressed)
        self.bt.set_text('Hi!')


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=False)
Beispiel #5
0
    def conf_continue(self,result):
        if result is True:
            # print 'dialog confirm'
            result=self.t1field1.get_value()
            self.t1f1_field.set_text('Tab1 Field1: '+result)
            
            result=self.t2field1.get_value()
            self.t2f1_field.set_text('Tab2 Field1: '+result)
            self.tabbed_dialog.hide()
            OKDialog('Tabbed Editor','Saved').show(self)
        else:
            OKDialog('Tabbed Editor','Not Saved').show(self)
           


#
# ***************************************
# MAIN
# ***************************************

if __name__  ==  "__main__":
    # setting up remi debug level 
    #       2=all debug messages   1=error messages   0=no messages
    import remi.server
    remi.server.DEBUG_MODE = 2

    # start the web server to serve the App
    start(Tabbed,address='127.0.0.1', port=8082,
          multiple_instance=False,enable_file_cache=True,
          update_interval=0.1, start_browser=False)
Beispiel #6
0
        self.lbl.set_text('New color value: ' + value)

    def date_changed(self, widget, value):
        self.lbl.set_text('New date value: ' + value)

    def menu_save_clicked(self, widget):
        self.lbl.set_text('Menu clicked: Save')

    def menu_saveas_clicked(self, widget):
        self.lbl.set_text('Menu clicked: Save As')

    def menu_open_clicked(self, widget):
        self.lbl.set_text('Menu clicked: Open')

    def menu_view_clicked(self, widget):
        self.lbl.set_text('Menu clicked: View')

    def fileupload_on_success(self, widget, filename):
        self.lbl.set_text('File upload success: ' + filename)

    def fileupload_on_failed(self, widget, filename):
        self.lbl.set_text('File upload failed: ' + filename)


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)

    start(MyApp, debug=True, address='0.0.0.0', start_browser=True)
Beispiel #7
0
        b1 = gui.Button('Show second tab', width=200, height=30)
        
        tb = gui.TabBox(width='80%')
        tb.add_tab(b1, 'First', None)

        b2 = gui.Button('Show third tab', width=200, height=30)
        tb.add_tab(b2, 'Second', None)

        b3 = gui.Button('Show first tab', width=200, height=30)
        tb.add_tab(b3, 'Third', None)
        
        b1.onclick.do(self.on_bt1_pressed, tb, b2)
        b2.onclick.do(self.on_bt2_pressed, tb, 'Third')
        b3.onclick.do(self.on_bt3_pressed, tb, 0)

        return tb

    def on_bt1_pressed(self, widget, tabbox, refWidgetTab):
        tabbox.select_by_widget(refWidgetTab)

    def on_bt2_pressed(self, widget, tabbox, refWidgetTabName):
        tabbox.select_by_name(refWidgetTabName)
    
    def on_bt3_pressed(self, widget, tabbox, tabIndex):
        tabbox.select_by_index(tabIndex)

if __name__ == "__main__":
    start(MyApp, title="Tab Demo", standalone=False)

Beispiel #8
0
import remi.gui as gui
from remi import start, App
import os

class MyApp(App):
    def __init__(self, *args):
        res_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res')
        #static_file_path can be an array of strings allowing to define
        #  multiple resource path in where the resources will be placed
        super(MyApp, self).__init__(*args, static_file_path=res_path)

    def idle(self):
        """ Idle loop, you can place here custom code,
             avoid to use infinite iterations, it would stop gui update.
            This is a Thread safe method where you can update the 
             gui with information from external Threads.
        """
        pass

    def main(self):
        #creating a container VBox type, vertical (you can use also HBox or Widget)
        main_container = gui.VBox(width=300, height=200, style={'margin':'0px auto'})

        # returning the root widget
        return main_container


if __name__ == "__main__":
    # starts the webserver
    start(MyApp, address='0.0.0.0', port=0, start_browser=True, username=None, password=None)
Beispiel #9
0
        choices=['dev', 'production'])
    parser.add_argument(
        "--port",
        help="specify the port number to launch on, only used in dev mode",
        default=8081)
    parser.add_argument(
        "--skip",
        help=
        "flag for specifying whether to skip the classifier if we get an error",
        action="store_true")
    args = parser.parse_args()

    if (args.skip):
        convert_transcript.skipClassifier = True
    #process all the transcripts waiting to be processed
    convert_transcript.batchProcessTranscripts(BASEPATH, METAPATH, True)
    if (args.launchMode == 'dev'):
        start(DTApp,
              debug=True,
              address='0.0.0.0',
              port=args.port,
              start_browser=False,
              multiple_instance=True)
    if (args.launchMode == 'production'):
        start(DTApp,
              debug=True,
              address='0.0.0.0',
              port=80,
              start_browser=False,
              multiple_instance=True)
Beispiel #10
0
        super(MyApp, self).__init__(*args)

    def main(self):
        wid = gui.VBox(width=320, height=320, margin='0px auto')
        wid.style['text-align'] = 'center'

        bt = gui.Button('Data', width=100, height=30)
        bt.style['margin'] = '10px'
        bt.onclick.do(self.on_button_pressed)

        self.plot_data = [0, 1]
        self.mpl = MatplotImage(width=250, height=250)
        self.mpl.style['margin'] = '10px'
        self.mpl.ax.set_title("test")
        self.mpl.ax.plot(self.plot_data)
        self.mpl.redraw()

        wid.append(bt)
        wid.append(self.mpl)

        return wid

    def on_button_pressed(self, widget):
        self.plot_data.append(random.random())
        self.mpl.ax.plot(self.plot_data)
        self.mpl.redraw()


if __name__ == "__main__":
    start(MyApp, debug=True, address='0.0.0.0', port=0)
Beispiel #11
0
    def main(self):
        #creating a container VBox type, vertical
        wid = gui.VBox(width=300, height=200)

        #creating a text label
        self.lbl = gui.Label('Hello', width='80%', height='50%')

        #a button for simple interaction
        bt = gui.Button('Press me!', width=200, height=30)

        #setting up the listener for the click event
        bt.onclick.connect(self.on_button_pressed)

        #adding the widgets to the main container
        wid.append(self.lbl)
        wid.append(bt)

        # returning the root widget
        return wid

    # listener function
    def on_button_pressed(self, emitter):
        self.lbl.set_text('Hello World!')


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=True)
        self.steamSwitch._checkbox.set_value(self.steam)
        time.sleep(0.25)
        self.switchContainer.remove_child(self.dummyUpdated)
        self.switchContainer.append(self.dummyUpdated)

    def display_counter(self):
        self.counter.set_text('Running Time: ' + str(self.count))
        self.count += 1
        threading.Timer(1, self.display_counter).start()

    def temperature_display(self):
        currentTemp = self.tempProbe.getTemp() + self.calibrationOffset
        self.boilerTemp = "{:.2f}".format(float(currentTemp))
        self.tempLabel.set_text(str(self.boilerTemp))
        threading.Timer(0.5, self.temperature_display).start()

    def on_button_pressed(self):
        self.lbl.set_text('Button pressed! ')
        self.bt.set_text('Hi!')

    def on_spin_change(self, newValue):
        self.lbl.set_text('SpinBox changed, new value: ' + str(newValue))

    def slider_changed(self, value):
        self.lbl.set_text('New slider value: ' + str(value))


if __name__ == "__main__":
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(Espresso, debug=True, address='0.0.0.0')
    def turn_on_button(self, emitter, tabIndex):
        self.onofflabel.set_text("Current status: On")


    def shutdown_button(self, _):
        self.process_label.set_text("Bye!")
        self.do_gui_update()
        self.close()


    def my_algorithm(self):
        while self.thread_alive_flag:
            self.my_thread_result = returntime()


    def my_2algorithm(self):
        while self.thread_alive_flag:
            self.my_thread_result2 = myrandomfunction()
            self.do_gui_update()


    def start_thread(self):
        self.thread_alive_flag = True
        self.my_thread_result = 'n/a'
        t = threading.Thread(target=self.my_algorithm)
        t.start()


if __name__ == "__main__":
    start(MyApp, debug=True, update_interval=.5)
Beispiel #14
0
        mainContainer.children['pulseWidthValue'].onclick.do(
            self.onclick_pulseWidthValue)

        self.mainContainer = mainContainer
        return self.mainContainer

    def onclick_pulseWidthValue(self, emitter):
        pass


#Configuration
configuration = {
    'config_project_name': 'timeCorrelatedMeasurements',
    'config_address': '0.0.0.0',
    'config_port': 8081,
    'config_multiple_instance': True,
    'config_enable_file_cache': True,
    'config_start_browser': True,
    'config_resourcepath': './res/'
}

if __name__ == "__main__":

    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(timeCorrelatedMeasurements,
          address=configuration['config_address'],
          port=configuration['config_port'],
          multiple_instance=configuration['config_multiple_instance'],
          enable_file_cache=configuration['config_enable_file_cache'],
          start_browser=configuration['config_start_browser'])
Beispiel #15
0
            u=u.reshape(int(bm_description['visible_height']),int(bm_description['buffer_width']))
            v=numpy.empty(bm_frame_size//2, dtype=numpy.uint8)
            v[0::2]=bm_raw_img[2::4]
            v[1::2]=bm_raw_img[2::4]
            v=v.reshape(int(bm_description['visible_height']),int(bm_description['buffer_width']))
            raw_yuv=numpy.dstack((y,u,v))[:,0:int(bm_description['visible_width']),:]
            bm_rgb=cv2.cvtColor(raw_yuv, cv2.COLOR_YUV2BGR)
        if bmo_description['data_start'] >0:
            bmo_raw_img=numpy.fromfile(myFile, dtype=numpy.int32, count=bmo_frame_size)
        myFile.close()
        if vp_rgb.shape[0]==408: # Workaround for video mode
            extension=numpy.zeros((480,720,3))
            extension[36:444, :, :]=vp_rgb # (480-408)/2:480-(480-408)/2, :, :
            vp_rgb=extension
        return vp_rgb, bm_rgb

    def exec_lua(self, widget, value):
        try:
            self.camera.lua_execute(str(self.lua_value.get_value())+'\n' \
                                        'press("shoot_half")\n' \
                                        'repeat\n' \
                                        '   sleep(10)\n' \
                                        'until get_shooting()\n' \
                                        'return')
            self.status_label.set_text('Done')
        except:
            self.status_label.set_text('Error executing LUA')

if __name__ == "__main__":
    start(M10GUI, address='0.0.0.0', port=8081, multiple_instance=False, enable_file_cache=True, start_browser=False, debug=False, update_interval = 0.01)
Beispiel #16
0
from remi import start, App

from simple_app import MyApp

if __name__ == "__main__":
    start(MyApp, standalone=True)
Beispiel #17
0
            self.dropdown.append(str(i), gui.DropDownItem(200, 20, s))
        step_selec.append('0', self.dropdown)

        self.img = gui.Image(300, 300, '/res/logo.png')
        step_selec.append('1', self.img)

        # Second row - Detect / Motor info
        motor_info = gui.Widget(350, 500, gui.Widget.LAYOUT_VERTICAL, 10)

        self.table = gui.Table(300, 200)
        self.table.from_2d_matrix([['ID', 'First Name', 'Last Name'],
                                   ['101', 'Danny', 'Young'],
                                   ['102', 'Christine', 'Holand'],
                                   ['103', 'Lars', 'Gordon'],
                                   ['104', 'Roberto', 'Robitaille'],
                                   ['105', 'Maria', 'Papadopoulos']])
        motor_info.append('0', self.table)

        self.configure_btn = gui.Button(200, 30, 'CONFIGURE')
        motor_info.append('1', self.configure_btn)

        mc.append('0', step_selec)
        mc.append('1', motor_info)

        self.wid.append('1', self.title_label)
        self.wid.append('2', mc)

        return self.wid

start(Werborist)
Beispiel #18
0
            qr_code_data = qr_code_list[0][0].decode('utf-8')
            self.qr_label.set_text(qr_code_data)
        return

    def main(self):
        self.video_widgets()
        screen = [self.video]
        start_button = gui.Button('Start Video')
        start_button.onclick.do(self.video_start, 'process_image')
        screen.append(start_button)
        stop_button = gui.Button('Stop Video')
        stop_button.onclick.do(self.video_stop)
        screen.append(stop_button)
        self.qr_label = gui.Label('No QR code detected')
        screen.append(self.qr_label)

        return gui.VBox(children=screen)


if __name__ == "__main__":
    start(Camera,
          certfile='./ssl_keys/fullchain.pem',
          keyfile='./ssl_keys/privkey.pem',
          ssl_version=ssl.PROTOCOL_TLSv1_2,
          address='0.0.0.0',
          port=2020,
          multiple_instance=True,
          enable_file_cache=True,
          start_browser=False,
          debug=False)
Beispiel #19
0
        print("tag deleted")
        
    def onkeydown(self, keypressed):
        if keypressed==46: #46 the delete keycode
            self.toolbar_delete_clicked()
        print("Key pressed: " + str(keypressed))

        
#function overload for widgets that have to be editable
#the normal onfocus function does not returns the widget instance
#def onfocus_with_instance(self):
#    return self.eventManager.propagate(self.EVENT_ONFOCUS, [self])
def onclick_with_instance(self):
    #return self.eventManager.propagate(self.EVENT_ON_WIDGET_SELECTION, [self])
    self.editor.on_widget_selection(self)
    
def on_dropped(self, left, top):
    self.style['left']=left
    self.style['top']=top

if __name__ == "__main__":
    #p = Project()
    #root = p.load('./example_project.py')
    #p.append(root, "root")
    #p.save(None)
    
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(Editor, debug=False, port=8082)
Beispiel #20
0
                    for coord in [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1],
                                  [1, -1], [1, 0], [1, 1]]:
                        _x, _y = coord
                        if not self.coord_in_map(cell.x + _x, cell.y + _y):
                            continue

                        if not self.mine_matrix[cell.y + _y][cell.x +
                                                             _x].opened:
                            self.mine_matrix[cell.y + _y][cell.x +
                                                          _x].check_mine(False)
                            checked_cells.append(
                                self.mine_matrix[cell.y + _y][cell.x + _x])

    def explosion(self, cell):
        print("explosion")
        self.mine_table = gui.Table()
        self.main_container.append(self.mine_table, key="mine_table")
        for x in range(0, len(self.mine_matrix[0])):
            for y in range(0, len(self.mine_matrix)):
                self.mine_matrix[y][x].style['background-color'] = 'red'
                self.mine_matrix[y][x].check_mine(False)
        self.mine_table.from_2d_matrix(self.mine_matrix, False)


if __name__ == "__main__":
    start(MyApp,
          multiple_instance=False,
          address='0.0.0.0',
          port=8081,
          debug=False)
Beispiel #21
0
    def fill_void_cells(self, cell):
        checked_cells = [cell, ]
        while len(checked_cells) > 0:
            for cell in checked_cells[:]:
                checked_cells.remove(cell)
                if (not self.mine_matrix[cell.y][cell.x].has_mine) and \
                        (self.mine_matrix[cell.y][cell.x].nearest_mine == 0):
                    for coord in [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]:
                        _x, _y = coord
                        if not self.coord_in_map(cell.x + _x, cell.y + _y):
                            continue

                        if not self.mine_matrix[cell.y + _y][cell.x + _x].opened:
                            self.mine_matrix[cell.y + _y][cell.x + _x].check_mine(None, False)
                            checked_cells.append(self.mine_matrix[cell.y + _y][cell.x + _x])

    def explosion(self, cell):
        print("explosion")
        self.mine_table = gui.Table(margin='0px auto')
        self.main_container.append(self.mine_table, key="mine_table")
        for x in range(0, len(self.mine_matrix[0])):
            for y in range(0, len(self.mine_matrix)):
                self.mine_matrix[y][x].style['background-color'] = 'red'
                self.mine_matrix[y][x].check_mine(None, False)
        self.mine_table.empty()
        self.mine_table.append_from_list(self.mine_matrix, False)


if __name__ == "__main__":
    start(MyApp, multiple_instance=False, address='0.0.0.0', port=8081, debug=False, start_browser=True )
Beispiel #22
0
    def onerror(self, emitter, message, source, lineno, colno):
        """ WebPage Event that occurs on webpage errors """
        super(MyApp, self).onerror(emitter, message, source, lineno, colno)

    def ononline(self, emitter):
        """ WebPage Event that occurs on webpage goes online after a disconnection """
        super(MyApp, self).ononline(emitter)

    def onpagehide(self, emitter):
        """ WebPage Event that occurs on webpage when the user navigates away """
        super(MyApp, self).onpagehide(emitter)

    def onpageshow(self, emitter, width, height):
        """ WebPage Event that occurs on webpage gets shown """
        super(MyApp, self).onpageshow(emitter, width, height)

    def onresize(self, emitter, width, height):
        """ WebPage Event that occurs on webpage gets resized """
        super(MyApp, self).onresize(emitter, width, height)


if __name__ == "__main__":
    # starts the webserver
    start(MyApp,
          debug=True,
          address='0.0.0.0',
          port=0,
          start_browser=True,
          username=None,
          password=None)
Beispiel #23
0
        self.projectConfiguration.show(self)

    def toolbar_delete_clicked(self, widget):
        if self.selectedWidget==self.project:
            return
        for drag_helper in self.drag_helpers:
            drag_helper.setup(None, None)
        parent = self.selectedWidget.get_parent()
        parent.remove_child(self.selectedWidget)
        self.instancesWidget.update(self.project, self.selectedWidget)
        self.selectedWidget = parent
        print("tag deleted")
        
    def onkeydown(self, emitter, key, keycode, ctrl, shift, alt):
        if str(keycode)=='46': #46 the delete keycode
            self.toolbar_delete_clicked(None)
        print("Key pressed: " + str(keycode))

        
def on_dropped(self, left, top):
    if len(left)<1:
        left='0px'
    if len(top)<1:
        top='0px'
    self.style['left']=left
    self.style['top']=top


if __name__ == "__main__":
    start(Editor, debug=False, address='0.0.0.0', port=8082, update_interval=0.01, multiple_instance=True)
        geoApi = GeolocationAPI()
        oriApi = OrientationAPI()
        accApi = AccelerometerAPI()
        wid.add_child("javascript_geo", geoApi)
        wid.add_child("javascript_ori", oriApi)
        wid.add_child("javascript_acc", accApi)

        geoApi.set_on_change_listener(self.onGeolocation, lblGeolocation)
        oriApi.set_on_change_listener(self.onOrientation, lblOrientation)
        accApi.set_on_change_listener(self.onAccelerometer, lblAccelerometer)

        # returning the root widget
        return wid

    # listener function
    def onGeolocation(self, widget, latitude, longitude, label):
        label.set_text("lat: %s, lon:%s"%(latitude, longitude))

    def onOrientation(self, widget, gamma, beta, alpha, label):
        label.set_text("gamma: %s, beta:%s, alpha:%s"%(gamma, beta, alpha))

    def onAccelerometer(self, widget, accelerationX, accelerationY, accelerationZ, label):
        label.set_text("accX: %s, accY:%s, accZ:%s"%(accelerationX, accelerationY, accelerationZ))


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=True, address='0.0.0.0', multiple_instance=True, certfile="server.crt", keyfile="server.key")#, ssl_version=ssl.PROTOCOL_TLSv1_2)
Beispiel #25
0
            time.sleep(1)

    def stop(self):
        self.running = False
        self.thread.join()

    # listener function
    def on_button_pressed(self, widget, settings):
        if not self.started:
            # self.plt.status.play()
            widget.set_text('Stop')
            widget.style['background-color'] = 'red'
            for idx in range(len(self.data)):
                self.data[idx]['x'] = []
                self.data[idx]['y'] = []
            self.running = True
            self.thread = threading.Thread(target=self.run)
            self.thread.start()
        else:
            # self.plt.status.stop()
            self.stop()
            widget.set_text('Start')
            widget.style['background-color'] = 'green'
        self.started = not self.started

if __name__ == "__main__":
    # starts the webserver
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,
    #        enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=False, port=8081, address='0.0.0.0', start_browser=True)
Beispiel #26
0
import remi.gui as gui
from remi import start, App

import sys


class Communicator(App):
    def __init__(self, *args):
        super(Communicator, self).__init__(*args)
        self.net_name = "Gellish semantic network"

    # Define the main window
    def main(self):
        print('Net name:', self.net_name)
        self.container = gui.Widget(margin='0px auto')
        self.container.set_size(1020, 600)
        return self.container


if __name__ == "__main__":
    sys.setrecursionlimit(100000)
    start(Communicator)
Beispiel #27
0
class MyApp(App):
    def __init__(self, *args):
        res_path = os.path.join(os.path.dirname(__file__), 'res')
        super(MyApp, self).__init__(*args, static_file_path=res_path)

    def idle(self):
        pass

    def main(self):
        self.floatingPaneContainer = FloatingPanesContainer(width=800, height=600, margin='0px auto')
        self.floatingPaneContainer.append(gui.Label("Click a panel to select, than drag and stretch"))

        pane1 = gui.Container(width=100, height=200)
        pane1.style['background-color'] = 'yellow'
        self.floatingPaneContainer.add_pane(pane1, 10, 100)
        pane1.append(gui.Label("Panel1, drag and stretch"))

        pane2 = gui.VBox(width=100, height=200)
        pane2.style['background-color'] = 'green'
        self.floatingPaneContainer.add_pane(pane2, 150, 100)
        pane2.append(gui.Label("Panel2, drag and stretch"))
        

        # returning the root widget
        return self.floatingPaneContainer


    
if __name__ == "__main__":
    start(MyApp, debug=False, address='0.0.0.0', port=0, update_interval=0.01)
Beispiel #28
0
    def change_save_location(self, widget, value, save_as):
        self.save_location = value
        self.save_location_label.set_text(f"Saving to {value}")
        if save_as:
            self._save()

    def cbk_save_as(self, widget):
        self._get_new_save_location(save_as=True)

    def cbk_select_pickle(self, widget):
        file_selector = gui.FileSelectionDialog("File Selection Dialog", "Select data pickle.", False, ".")
        file_selector.set_on_confirm_value_listener(self.cbk_load)
        file_selector.show(self)

    def _load(self, filename):
        with open(filename, "rb") as fin:
            self.users = pickle.load(fin)
        User.count = max(user.id_ for user in self.users) + 1
        self.update_table()
        self.update_user_list()

    def cbk_load(self, widget, filenames):
        if isinstance(filenames, list):
            filenames = filenames[0]
        self._load(filenames)


if __name__ == "__main__":
    start(MyApp, title="Dashboard | SPIRIT")
Beispiel #29
0
        self.lbl.set_text('New color value: ' + value)

    def date_changed(self, value):
        self.lbl.set_text('New date value: ' + value)

    def menu_save_clicked(self):
        self.lbl.set_text('Menu clicked: Save')

    def menu_saveas_clicked(self):
        self.lbl.set_text('Menu clicked: Save As')

    def menu_open_clicked(self):
        self.lbl.set_text('Menu clicked: Open')

    def menu_view_clicked(self):
        self.lbl.set_text('Menu clicked: View')

    def fileupload_on_success(self, filename):
        self.lbl.set_text('File upload success: ' + filename)

    def fileupload_on_failed(self, filename):
        self.lbl.set_text('File upload failed: ' + filename)


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)

    start(MyApp, debug=True, address='0.0.0.0')
Beispiel #30
0
            self.line.add_coord(x, y)

    def write_on(self, emitter, x, y):
        self.draw_element += 1
        self.line = SvgPolyline()
        self.line.set_stroke(width=2, color=self.color)
        self.line.set_fill(None)
        self.lines.append(self.line)
        self.svg.append(self.line, str(self.draw_element))
        self.write = True

    def write_off(self, emitter, x, y):
        global students
        self.write = False
        draw_element = 0
        for line in self.lines:
            draw_element += 1
            students['default']['svg'].append(line, str(draw_element))
        for IP in students:
            students[IP]['update'] = True


if __name__ == "__main__":
    start(Teach,
          address='0.0.0.0',
          port=8081,
          start_browser=False,
          username=None,
          password=None,
          multiple_instance=True)
        exit()

    options_file_path=editor_dir+os.sep+'pp_config'+os.sep+'pp_web.cfg'
    if not os.path.exists(options_file_path):
        print 'Web Editor - Cannot find Web Options file'
        exit()

    """reads options from options file to interface"""
    config=ConfigParser.ConfigParser()
    config.read(options_file_path)
        
    ip =config.get('network','ip',0)
    port=int(config.get('editor','port',0))
    username=config.get('editor','username',0)
    password=config.get('editor','password',0)
    print 'Web Editor Started'
    # print ip,port, username,password
    # setting up remi debug level 
    #       2=all debug messages   1=error messages   0=no messages
    import remi.server
    remi.server.DEBUG_MODE = 0

    # start the web server to serve the Web Editor App
    start(PPWebEditor,address=ip, port=port,username=username,password=password,
          multiple_instance=False,enable_file_cache=True,
          update_interval=0.1, start_browser=False)



    
Beispiel #32
0
            js = gui.Tag(_type='script')
            js.attributes["src"] = "/res/{}".format(js_file)
            vbox_main.add_child(js_file, js)

        return vbox_main

    def _build_middle_box(self):

        middle_container = gui.HBox(style=MainStyles['middle_container'])
        middle_container.style["align-items"] = "stretch"

        self.ipbox.refresh_ip_box()

        middle_container.append(self.servicesbox.build_services_box())
        self.servicesbox.refresh_service_table()

        middle_container.append(self.scriptbox.build_script_box())
        self.scriptbox.refresh_scripts_table()

        # returning the root widget
        return middle_container


if __name__ == "__main__":
    # Starts the remi web server
    start(RaspiCommander,
          address=IP,
          port=PORT,
          enable_file_cache=False,
          update_interval=0.1)
Beispiel #33
0
        self.svgplot.style['margin'] = '10px'
        self.plotData1 = gui.SvgPolyline(500)
        self.plotData1.set_stroke(2.0, 'rgba(255,0,0,0.8)')
        self.plotData2 = gui.SvgPolyline(500)
        self.plotData2.set_stroke(1.0, 'green')
        self.plotData3 = gui.SvgPolyline(300)
        self.plotData3.set_stroke(3.0, 'orange')
        self.svgplot.append_poly(self.plotData1)
        self.svgplot.append_poly(self.plotData2)
        self.svgplot.append_poly(self.plotData3)

        self.wid.append(self.svgplot)

        self.count = 0
        self.add_data()

        # returning the root widget
        return self.wid

    def add_data(self):
        self.plotData1.add_coord(self.count, math.atan(self.count / 180.0 * math.pi))
        self.plotData2.add_coord(self.count, math.cos(self.count / 180.0 * math.pi))
        self.plotData3.add_coord(self.count, math.sin(self.count / 180.0 * math.pi))
        self.svgplot.render()
        self.count += 1
        Timer(0.01, self.add_data).start()


if __name__ == "__main__":
    start(MyApp, address='0.0.0.0')
    def menu_open_clicked(self, widget):
        self.lbl.set_text('Menu clicked: Open')

    def menu_view_clicked(self, widget):
        self.lbl.set_text('Menu clicked: View')

    def fileupload_on_success(self, widget, filename):
        self.lbl.set_text('File upload success: ' + filename)

    def fileupload_on_failed(self, widget, filename):
        self.lbl.set_text('File upload failed: ' + filename)

    def on_close(self):
        """ Overloading App.on_close event to stop the Timer.
        """
        self.stop_flag = True
        super(MyApp, self).on_close()


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    import ssl
    start(MyApp,
          debug=True,
          address='0.0.0.0',
          port=0,
          start_browser=True,
          multiple_instance=True)
Beispiel #35
0
    # api function
    def api_set_text(self, value1, value2):
        self.set_text('parameters: %s - %s' % (value1, value2))
        headers = {'Content-type': 'text/plain'}
        return ['OK', headers]


class MyApp(App):
    def __init__(self, *args):
        super(MyApp, self).__init__(*args)

    def main(self):
        wid = gui.VBox()

        #the 'id' param allows to have an alias in the url to refer to the widget that will manage the call
        self.lbl = RemoteLabel('type in other page url "http://127.0.0.1:8082/label/api_set_text?value1=text1&value2=text2" !', width='80%', height='50%', id='label')
        self.lbl.style['margin'] = 'auto'

        # appending a widget to another, the first argument is a string key
        wid.append(self.lbl)

        # returning the root widget
        return wid


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=True, address='127.0.0.1', port=8082)
Beispiel #36
0
        self.count = 0
        self.add_data()

        bt = gui.Button("Zoom - ")
        bt.set_on_click_listener(self.zoom_out)
        self.wid.append(bt)

        # returning the root widget
        return self.wid

    def zoom_out(self, emitter):
        scale_factor_x = 0.5
        scale_factor_y = 100.0
        self.plotData1.scale(scale_factor_x, scale_factor_y)
        self.plotData2.scale(scale_factor_x, scale_factor_y)
        self.plotData3.scale(scale_factor_x, scale_factor_y)

    def add_data(self):
        with self.update_lock:
            #the scale factors are used to adapt the values to the view
            self.plotData1.add_coord(self.count, math.atan(self.count / 180.0 * math.pi))
            self.plotData2.add_coord(self.count, math.cos(self.count / 180.0 * math.pi))
            self.plotData3.add_coord(self.count, math.sin(self.count / 180.0 * math.pi))
            self.svgplot.render()
            self.count += 10
            Timer(0.1, self.add_data).start()


if __name__ == "__main__":
    start(MyApp, address='0.0.0.0', update_interval=0.1, multiple_instance=True)
        self.published_topics = [topic_name for topic_name, topic_type in self.published_topics_and_types]
        self.published_topics.sort()
        rospy.loginfo("Found topics:\n" +
                      str(self.published_topics))
        self.dropdown = gui.DropDown(-1, -1)
        choose_ddi = gui.DropDownItem(-1, -1, "Choose topic...")
        self.dropdown.append(0, choose_ddi)
        for idx, topic_name in enumerate(self.published_topics):
            ddi = gui.DropDownItem(-1, -1, topic_name)
            self.dropdown.append(idx+1, ddi)

        self.dropdown.set_on_change_listener(self, 'on_dropdown_change')
        # using ID 2 to update the dropdown
        self.hor_topics.append(2, self.dropdown)
        # This makes the dropdown not be left
        self.dropdown.style['display'] = 'block'
        self.dropdown.style['margin'] = '10px auto'
        self.dropdown.style['float'] = 'none'
        self.wid.append(1, self.hor_topics)

if __name__ == "__main__":
    rospy.init_node('web_topic_viewer')

    start(MyApp,
          address="0.0.0.0",
          port=8091,
          multiple_instance=True,
          update_interval=0.1,
          start_browser=False,
          debug=False)
Beispiel #38
0
        self.lbl.set_text('New color value: ' + value)

    def date_changed(self, value):
        self.lbl.set_text('New date value: ' + value)

    def menu_save_clicked(self):
        self.lbl.set_text('Menu clicked: Save')

    def menu_saveas_clicked(self):
        self.lbl.set_text('Menu clicked: Save As')

    def menu_open_clicked(self):
        self.lbl.set_text('Menu clicked: Open')

    def menu_view_clicked(self):
        self.lbl.set_text('Menu clicked: View')

    def fileupload_on_success(self, filename):
        self.lbl.set_text('File upload success: ' + filename)

    def fileupload_on_failed(self, filename):
        self.lbl.set_text('File upload failed: ' + filename)


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)

    start(MyApp, debug=True,address='192.168.1.108')
Beispiel #39
0
        res_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'res')
        #static_file_path can be an array of strings allowing to define
        #  multiple resource path in where the resources will be placed
        super(MyApp, self).__init__(*args, static_file_path=res_path, html_head=my_html_head, css_head=my_css_head, js_head=my_js_head)

    def idle(self):
        #idle loop, you can place here custom code
        # avoid to use infinite iterations, it would stop gui update
        pass

    def main(self):
        #creating a container VBox type, vertical (you can use also HBox or Widget)
        main_container = gui.VBox(width=300, height=200, style={'margin':'0px auto'})

        #add the following 3 lines to your app and the on_window_close method to make the console close automatically
        tag = gui.Tag(_type='script')
        tag.add_child("javascript", """window.onunload=function(e){sendCallback('%s','%s');return "close?";};""" % (str(id(self)), "on_window_close")) 
        main_container.add_child("onbeforeunloadevent", tag)

        # returning the root widget
        return main_container
                
    def on_window_close(self):
        #here you can handle the unload
        self.close()


if __name__ == "__main__":
    # starts the webserver
    start(MyApp, address='127.0.0.1', port=8081, websocket_port=0, host_name=None, start_browser=True, username=None, password=None)
Beispiel #40
0
        main_container = gui.VBox(width=400,
                                  height=140,
                                  style={
                                      'align': 'center',
                                      'border': '5px #FFAC55 solid'
                                  })
        btn_container = gui.HBox(width=300, height=30)
        link_to_github = gui.Link(
            'https://github.com/npes87184/PyM3UGenerator', 'Fork me here')

        self.lbl = gui.Label('Please choose a folder')
        self.select_bt = gui.Button('Select folder', width=100, height=30)
        self.go_bt = gui.Button('Go', width=100, height=30)

        self.select_bt.onclick.do(self.on_select_btn_pressed)
        self.go_bt.onclick.do(self.on_go_btn_pressed)

        btn_container.append(self.select_bt)
        btn_container.append(self.go_bt)

        main_container.append(self.lbl)
        main_container.append(btn_container)
        main_container.append(link_to_github)
        body.append(main_container)

        return body


if __name__ == '__main__':
    start(M3uGenerator)
Beispiel #41
0
        mainContainer.append(lblAlignItems,'lblAlignItems')
        mainContainer.children['comboJustifyContent'].onchange.do(self.onchange_comboJustifyContent,vbox,hbox)
        mainContainer.children['comboAlignItems'].onchange.do(self.onchange_comboAlignItems,vbox,hbox)

        lblTitle = gui.Label("The following example shows the two main layout style properties for the VBox and HBox containers. Change the value of the two combo boxes.",
                                    style='position:absolute; left:0px; top:0px')
        mainContainer.append(lblTitle)

        self.mainContainer = mainContainer
        return self.mainContainer
    
    def onchange_comboJustifyContent(self,emitter,new_value,vbox,hbox):
        vbox.style['justify-content'] = new_value
        hbox.style['justify-content'] = new_value

    def onchange_comboAlignItems(self,emitter,new_value,vbox,hbox):
        vbox.style['align-items'] = new_value
        hbox.style['align-items'] = new_value



#Configuration
configuration = {'config_enable_file_cache': True, 'config_multiple_instance': True, 'config_port': 0, 'config_address': '0.0.0.0', 'config_start_browser': True, 'config_project_name': 'untitled', 'config_resourcepath': './res/'}

if __name__ == "__main__":
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(untitled, address=configuration['config_address'], port=configuration['config_port'], 
                        multiple_instance=configuration['config_multiple_instance'], 
                        enable_file_cache=configuration['config_enable_file_cache'],
                        start_browser=configuration['config_start_browser'])
Beispiel #42
0
            "height": "480px",
            "top": "40px",
            "left": "0px",
            "position": "absolute",
            "overflow": "auto"
        })
        wheelStatus.append(img_wheelStatus, 'img_wheelStatus')

        self.wheelStatus = wheelStatus
        return self.wheelStatus


#Configuration
configuration = {
    'config_project_name': 'GrowBot',
    'config_address': '0.0.0.0',
    'config_port': 8081,
    'config_multiple_instance': True,
    'config_enable_file_cache': True,
    'config_start_browser': True
}  #, 'config_resourcepath': './'}

if __name__ == "__main__":
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(GrowBot,
          address=configuration['config_address'],
          port=configuration['config_port'],
          multiple_instance=configuration['config_multiple_instance'],
          enable_file_cache=configuration['config_enable_file_cache'],
          start_browser=configuration['config_start_browser'])
        self.client_connected = False

    def reconnection(self):
        rospy.logwarn("Reconnection of the client!")
        self.client_connected = True

    def joystick_moved(self, x, y):  # 0 <= x <= 1     0 <= y <= 1
        self.infoLabel.set_text("move x:%s  y:%s" % (x, y))
        self.last_x = x
        self.last_y = y

    def pub_twist(self, timerevent):
        if self.joystick.drag_state and self.client_connected:
            t = Twist()
            if self.last_y >= 0:
                t.linear.x = self.last_y * MAX_LINEAR_SPEED
            else:
                t.linear.x = self.last_y * MAX_ANGULAR_SPEED / 2.0
            t.angular.z = -self.last_x * MAX_ANGULAR_SPEED
            self.twist_pub.publish(t)


if __name__ == "__main__":
    rospy.init_node('remi_joy')
    start(MyApp,
          address='0.0.0.0',
          multiple_instance=True,
          port=8092,
          websocket_timeout_timer_ms=1000,
          pending_messages_queue_length=1000)
Beispiel #44
0
        # appending a widget to another, the first argument is a string key
        wid.append('1', self.lbl)

        self.sub = rospy.Subscriber('/test', Header, self.sub_cb, queue_size=1)

        print "Initialized app"

        # returning the root widget
        return wid


if __name__ == "__main__":
    if len(sys.argv) > 1:
        rate = float(sys.argv[1])
    else:
        rate = 0.1
    # Initialize ROS
    rospy.init_node('test')
    # starts the webserver
    # optional parameters
    start(MyApp,
          address='127.0.0.1',
          port=8081,
          multiple_instance=False,
          enable_file_cache=True,
          update_interval=rate,
          start_browser=True)

    #start(MyApp, debug=False)
Beispiel #45
0
        # returning the root widget
        return self.mainContainer

    def menu_open_clicked(self, widget):
        self.fileselectionDialog = gui.FileSelectionDialog('File Selection Dialog', 'Select an image file', False, '.')
        self.fileselectionDialog.confirm_value.do(
            self.on_image_file_selected)
        self.fileselectionDialog.cancel_dialog.do(
            self.on_dialog_cancel)
        # here is shown the dialog as root widget
        self.fileselectionDialog.show(self)

    def menu_save_clicked(self, widget):
        pass
        
    def menu_saveas_clicked(self, widget):
        pass
        
    def on_image_file_selected(self, widget, file_list):
        if len(file_list) < 1:
            return
        self.image_widget.load(file_list[0])
        self.set_root_widget(self.mainContainer)
    
    def on_dialog_cancel(self, widget):
        self.set_root_widget(self.mainContainer)


if __name__ == "__main__":
    start(MyApp, address='0.0.0.0', port=0, start_browser=True)
Beispiel #46
0
        lbl = gui.Label("Page 1. Press the button to change the page.",
                        style={'font-size': '20px'})
        bt1 = gui.Button("change page")
        page1 = gui.VBox(children=[lbl, bt1],
                         style={
                             'width': '300px',
                             'height': '200px',
                             'margin': '0px auto',
                             'background-color': 'white'
                         })

        bt1.onclick.connect(self.set_different_root_widget, page2)
        bt2.onclick.connect(self.set_different_root_widget, page1)

        # returning the root widget
        return page1

    def set_different_root_widget(self, emitter, page_to_be_shown):
        self.set_root_widget(page_to_be_shown)


if __name__ == "__main__":
    # starts the webserver
    start(MyApp,
          address='127.0.0.1',
          port=8081,
          host_name=None,
          start_browser=True,
          username=None,
          password=None)
Beispiel #47
0
                    for coord in [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]:
                        _x, _y = coord
                        if not self.coord_in_map(cell.x + _x, cell.y + _y):
                            continue

                        if not self.mine_matrix[cell.y + _y][cell.x + _x].opened:
                            self.mine_matrix[cell.y + _y][cell.x + _x].check_mine(None, False)
                            checked_cells.append(self.mine_matrix[cell.y + _y][cell.x + _x])

    def explosion(self, cell):
        print("explosion")
        self.mine_table = gui.Table(margin='0px auto')
        self.main_container.append(self.mine_table, key="mine_table")
        for x in range(0, len(self.mine_matrix[0])):
            for y in range(0, len(self.mine_matrix)):
                self.mine_matrix[y][x].style['background-color'] = 'red'
                self.mine_matrix[y][x].check_mine(None, False)
        self.mine_table.empty()

        #self.mine_table.append_from_list(self.mine_matrix, False)
        for x in range(0, len(self.mine_matrix[0])):
            row = gui.TableRow()
            for y in range(0, len(self.mine_matrix)):
                row.append(self.mine_matrix[y][x])
                self.mine_matrix[y][x].onclick.do(self.mine_matrix[y][x].check_mine)
            self.mine_table.append(row)


if __name__ == "__main__":
    start(MyApp, multiple_instance=True, address='0.0.0.0', port=0, debug=True, start_browser=True )
Beispiel #48
0
        bt.style['background-color'] = 'red'

        wid.append(self.lbl)
        wid.append(bt)

        self.thread_alive_flag = True
        self.my_thread_result = 0
        # Here I start a parallel thread that executes my algorithm for a long time
        t = threading.Thread(target=self.my_intensive_long_time_algorithm)
        t.start()

        bt.onclick.do(self.on_button_pressed)

        # returning the root widget
        return wid

    def my_intensive_long_time_algorithm(self):
        while self.thread_alive_flag:
            self.my_thread_result = self.my_thread_result + 1

    def on_button_pressed(self, emitter):
        self.thread_alive_flag = False

    def on_close(self):
        self.thread_alive_flag = False
        super(MyApp, self).on_close()


if __name__ == "__main__":
    start(MyApp, debug=True, address='0.0.0.0', port=0, update_interval=0.1)
Beispiel #49
0
    def fill_void_cells(self, cell):
        checked_cells = [cell, ]
        while len(checked_cells) > 0:
            for cell in checked_cells[:]:
                checked_cells.remove(cell)
                if (not self.mine_matrix[cell.y][cell.x].has_mine) and \
                        (self.mine_matrix[cell.y][cell.x].nearest_mine == 0):
                    for coord in [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]:
                        _x, _y = coord
                        if not self.coord_in_map(cell.x + _x, cell.y + _y):
                            continue

                        if not self.mine_matrix[cell.y + _y][cell.x + _x].opened:
                            self.mine_matrix[cell.y + _y][cell.x + _x].check_mine(False)
                            checked_cells.append(self.mine_matrix[cell.y + _y][cell.x + _x])

    def explosion(self, cell):
        print("explosion")
        self.mine_table = gui.Table()
        self.main_container.append(self.mine_table, key="mine_table")
        for x in range(0, len(self.mine_matrix[0])):
            for y in range(0, len(self.mine_matrix)):
                self.mine_matrix[y][x].style['background-color'] = 'red'
                self.mine_matrix[y][x].check_mine(False)
        self.mine_table.from_2d_matrix(self.mine_matrix, False)


if __name__ == "__main__":
    start(MyApp, multiple_instance=False, address='0.0.0.0', port=8081, debug=False)
Beispiel #50
0
    def onkeydown(self, emitter, key, keycode, ctrl, shift, alt):
        if str(keycode) == '46':  # 46 the delete keycode
            self.toolbar_delete_clicked(None)
        print("Key pressed: " + str(keycode))

    def show_error_dialog(self, title, message):
        error_dialog = gui.GenericDialog(title, message)
        error_dialog.children["title"].style['background-color'] = 'red'
        error_dialog.children["message"].style['white-space'] = 'pre'
        error_dialog.cancel.style['display'] = 'none'
        error_dialog.show(self)


def on_dropped(self, left, top):
    if len(left) < 1:
        left = '0px'
    if len(top) < 1:
        top = '0px'
    self.style['left'] = left
    self.style['top'] = top


if __name__ == "__main__":
    start(Editor,
          debug=False,
          address='0.0.0.0',
          port=8082,
          update_interval=0.05,
          multiple_instance=True)
        print "Dropdown changed to: " + value
        if value == "Choose topic...":
            if self.playing:
                self.rosvideo_widget.stop()
                self.playing = False
            return
        self.rosvideo_widget.subscribe(value)
        self.rosvideo_widget.play()
        self.playing = True

    def on_fps_dropdown_change(self, value):
        pass

    def pause_play(self):
        if self.playing:
            self.bt_pause.set_text("Play video")
            self.rosvideo_widget.stop()
            self.playing = False
        else:
            self.bt_pause.set_text("Stop video")
            self.rosvideo_widget.play()
            self.playing = True



if __name__ == "__main__":
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    rospy.init_node('view_topic_remi')
    start(MyApp, address='0.0.0.0', port=8093, debug=True)
Beispiel #52
0
        # returning the root widget
        return self.mainContainer

    def menu_open_clicked(self, widget):
        self.fileselectionDialog = gui.FileSelectionDialog('File Selection Dialog', 'Select an image file', False, '.')
        self.fileselectionDialog.set_on_confirm_value_listener(
            self.on_image_file_selected)
        self.fileselectionDialog.set_on_cancel_dialog_listener(
            self.on_dialog_cancel)
        # here is shown the dialog as root widget
        self.fileselectionDialog.show(self)

    def menu_save_clicked(self, widget):
        pass
        
    def menu_saveas_clicked(self, widget):
        pass
        
    def on_image_file_selected(self, widget, file_list):
        if len(file_list) < 1:
            return
        self.image_widget.load(file_list[0])
        self.set_root_widget(self.mainContainer)
    
    def on_dialog_cancel(self, widget):
        self.set_root_widget(self.mainContainer)


if __name__ == "__main__":
    start(MyApp, address='0.0.0.0', start_browser=True)
    def main(self):
        wid = gui.VBox(width=300, height=200, margin='0px auto')
        self.lbl = gui.Label('Press the button', width='80%', height='50%')
        self.lbl.style['margin'] = 'auto'
        self.bt = gui.Button('Press me!', width=200, height=30)
        self.bt.style['margin'] = 'auto 50px'

        # setting the listener for the onclick event of the button
        self.bt.onclick.do(self.on_button_pressed)

        # appending a widget to another, the first argument is a string key
        wid.append(self.lbl)
        wid.append(self.bt)

        # returning the root widget
        return wid

    # listener function
    def on_button_pressed(self, widget):
        self.lbl.set_text('A notification message should appear.')
        self.bt.set_text('Hi!')
        self.notification_message("Message title", "Hello world!", "")


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=True, address='0.0.0.0', port=0, )
Beispiel #54
0
 def __init__(self, *args, game=None, **kwargs):
     userdata = (game, )
     start(Connect4WebInterface_, *args, userdata=userdata, **kwargs)
Beispiel #55
0
		
		self.drop_status = gui.Label('')
		self.drop_btn = gui.Button('DROP')
		self.drop_btn.style['background'] = 'teal'
		self.buttons = {'drop_btn': False}
	
		# setting the listener for the onclick event of the button
		self.drop_btn.set_on_click_listener(self, 'on_button_pressed')
	
		# appending a widget to another, the first argument is a string key
		container.append(self.drop_status)
		container.append(self.drop_btn)
	
		# returning the root widget
		return container
	
	# listener function
	def on_button_pressed(self):
		if not self.buttons['drop_btn']:
			self.buttons['drop_btn'] = True
			self.drop_btn.style['background'] = 'red'
			self.on_button_pressed()
		else:
			xdot.dropIt()
			self.drop_btn.style['background'] = 'teal'
        

# starts the webserver
if __name__ == "__main__":
    start(MyApp, address='127.0.0.1', start_browser=False)
Beispiel #56
0
        self.error = gui.Label("",
                               width=300,
                               height=5,
                               style={"font-style": "italic"})
        self.button = gui.Button("TRANSLATE",
                                 width=300,
                                 height=40,
                                 margin="10px",
                                 style={
                                     "background-color": "#F16059",
                                     "font-weight": "bold",
                                     "font-size": "16px",
                                     "box-shadow": "none"
                                 })

        # Adds the elements to the GUI
        container.append(self.label)
        container.append(self.textinput)
        container.append(self.spanish)
        container.append(self.french)
        container.append(self.error)
        container.append(self.button)

        # When you click on button, call the function on_button_pressed
        self.button.onclick.connect(self.on_button_pressed)

        return container


start(MyApp, debug=False, address='0.0.0.0', port=0, multiple_instance=True)
Beispiel #57
0
        self.lbl.set_text('New date value: ' + value)

    def menu_save_clicked(self):
        self.lbl.set_text('Menu clicked: Save')

    def menu_saveas_clicked(self):
        self.lbl.set_text('Menu clicked: Save As')

    def menu_open_clicked(self):
        self.lbl.set_text('Menu clicked: Open')

    def menu_view_clicked(self):
        self.lbl.set_text('Menu clicked: View')
        
    def fileupload_on_success(self, filename):
        self.lbl.set_text('File upload success: ' + filename)

    def fileupload_on_failed(self, filename):
        self.lbl.set_text('File upload failed: ' + filename)
        
# setting up remi debug level 
#       2=all debug messages   1=error messages   0=no messages
#import remi.server
#remi.server.DEBUG_MODE = 2

# starts the webserver
# optional parameters   
#       start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)

start(MyApp)
Beispiel #58
0
class MyApp(App):
    def __init__(self, *args):
        super(MyApp, self).__init__(*args)

    def main(self, name='world'):
        # margin 0px auto allows to center the app to the screen
        wid = gui.VBox(width=300, height=200, margin='0px auto')

        lbl = gui.Label("Close the window, the console thread will stop automatically.")
        wid.append(lbl)

        #add the following 3 lines to your app and the on_window_close method to make the console close automatically
        tag = gui.Tag(_type='script')
        tag.add_child("javascript", """window.onunload=function(e){sendCallback('%s','%s');return "close?";};""" % (str(id(self)), "on_window_close")) 
        wid.add_child("onunloadevent", tag)
        
        # returning the root widget
        return wid
        
    def on_window_close(self):
        #here you can handle the unload
        print("app closing")
        self.close()


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=True, start_browser=True) #standalone=True)
Beispiel #59
0
        self._items = ("/test/1", "/test/7")

        self.dd = gui.DropDown.new_from_list(self._items, width='80%', height=40)
        self.list = gui.ListView.new_from_list(self._items, width='80%', height='50%')
        self.ent = gui.TextInput(width=200, height=30, hint='enter words')
        self.bt = gui.Button('Update Models', width=200, height=30)
        self.bt.style['margin'] = 'auto 50px'

        self.bt.set_on_click_listener(self.on_button_pressed)

        # appending a widget to another, the first argument is a string key
        wid.append([self.dd, self.list, self.ent, self.bt])

        # returning the root widget
        return wid

    # listener function
    def on_button_pressed(self, widget):
        txt = self.ent.get_text()
        if txt:
            self._items = tuple("/test/%s" % i for i in txt.split(' '))
        self.dd.synchronize_values(self._items)
        self.list.synchronize_values(self._items)


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(MyApp, debug=True)
Beispiel #60
0
    # listener function
    # 跳转到官网
    def on_img_clicked(self, widget):
        print('官网: http://www.yuanxiang.cn')

    def goto_tableocr_web(self, widget):
        print('go to table-ocr')

    def goto_dococr_web(self, widget):
        print('go to doc-ocr')

    def on_close(self):
        """ Overloading App.on_close event to stop the Timer.
        """
        self.stop_flag = True
        super(OCR_miniApp, self).on_close()


if __name__ == "__main__":
    # starts the webserver
    # optional parameters
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    import ssl

    start(OCR_miniApp,
          debug=True,
          address='0.0.0.0',
          port=8081,
          start_browser=True,
          multiple_instance=True)