def __init__(self, person, **kwargs):
        super(AppSwitcher, self).__init__ (**kwargs)
        def logout(instance):
            """ A callback function that calls the logoutUser method from masterControl. Is the event handler for the Sign Out button."""
            self.clear_widgets()
            self.parent.logoutUser()

        def editHandle(instance):
            """ A callback function that sets the current screen to the profile edit appelt. """
            print("In EditHandle")
            sm.current = 'prof'


        prof = ProfileManager(person, name = 'prof')

        bar = F.ActionBar(pos_hint={'top': 1})
        av = F.ActionView()

        av.add_widget(F.ActionPrevious(title='Dash', with_previous=False))
        av.add_widget(F.ActionOverflow())

        testButton = ActionButton(text = 'testButton')
        dd = ActionGroup(text = 'Applets', mode = 'spinner')
        dd.add_widget(testButton)
        av.add_widget(dd)

        userdd = ActionGroup(text='Welcome ' + person.m_name, mode = 'spinner')
        logoutButton = ActionButton(text = 'Sign Out')
        logoutButton.bind(on_release = logout)
        editProfileButton = ActionButton(text = 'Edit Profile')
        editProfileButton.bind(on_release = editHandle)
        userdd.add_widget(editProfileButton)
        userdd.add_widget(logoutButton)
        av.add_widget(userdd)

        bar.add_widget(av)
        av.use_separator = True
        self.add_widget(bar)

        sm = ScreenManager()

        screen = Screen(name='Screen')
        screen.add_widget(Label(text='Screen'))

        screen2 = Screen(name='Screen 2')
        screen2.add_widget(Label(text = 'Screen 2'))
        

        sm.add_widget(screen)
        sm.add_widget(screen2)
        sm.add_widget(prof)

        self.add_widget(sm)
    def place_list(self, req):
        if req['data'] is None:
            self.ids.content_layout.add_widget(
                Label(text="No camera added yet"))
        else:
            # pprint.pprint(req)
            for x in req['data']:
                actionbar = F.ActionBar(pos_hint={'top': 1})

                av = F.ActionView()
                av.add_widget(
                    F.ActionPrevious(title=x['name'],
                                     with_previous=False,
                                     size=[0.5, 0.5]))
                av.add_widget(F.ActionOverflow())

                ag = F.ActionGroup(text='CV')
                ag.add_widget(
                    F.ActionPrevious(title=x['ip'], with_previous=False))

                class OffActionButton(Button, ActionItem):
                    def __init__(self, **kwargs):
                        super(OffActionButton, self).__init__(**kwargs)
                        self.camera_id = x['id']
                        self.text = "Delete"
                        self.size = [0.5, 1]
                        self.size_hint_x = .3
                        self.size_hint_y = 1

                    def on_release(self):
                        try:
                            URL = api_uri + '/gui/deletecamera/{0}'.format(
                                self.camera_id)
                            r = requests.get(URL)
                            rjson = r.json()
                            print rjson
                        except Exception as e:
                            print e

                ag.add_widget(OffActionButton())
                av.add_widget(ag)
                actionbar.add_widget(av)

                self.ids.content_layout.add_widget(actionbar)
Beispiel #3
0
    def __init__(self):
        super().__init__(orientation='vertical')
        # Set up action bar
        ribbon = F.ActionBar()
        ribbonView = F.ActionView()
        ap = F.ActionPrevious(title='hi', with_previous=False)
        ap.app_icon = ''

        ## Set up action bar buttons
        pencil = ActionButton(text='Pen')
        eraser = ActionButton(text='Eraser')

        ## Add components to GUI
        ribbonView.add_widget(ap)
        ribbonView.add_widget(pencil)
        ribbonView.add_widget(eraser)

        ribbon.add_widget(ribbonView)

        self.add_widget(ribbon)

        # Set up drawing canvas
        self.add_widget(Label(text="hi"))
Beispiel #4
0
    def place_list(self, req):
        print(type(req['status']))
        print self.format_status(req['status'])
        if req['status'] is 1 or self.pending:
            if not self.pending:
                self.pending = True
                self.counter = 20

            if self.pending:
                self.counter = -1
                if self.counter is 0:
                    self.pending = False

            if self.pending and req['status'] is 0:
                req['status'] = 3

            self.ids.scanner_list.add_widget(
                Label(text="Scanner status: {0}".format(
                    self.format_status(req['status']))))
            for x in req['ips']:
                actionbar = F.ActionBar(pos_hint={'top': 2})

                av = F.ActionView()
                av.add_widget(
                    F.ActionPrevious(title=x, with_previous=False, size=[1,
                                                                         1]))
                av.add_widget(F.ActionOverflow())

                print x

                class AddActionButton(Button, ActionItem):
                    def __init__(self, popup, **kwargs):
                        super(AddActionButton, self).__init__(**kwargs)
                        self.popup = popup
                        self.camera_id = x
                        self.ip = str(x)
                        print("Button IP:" + self.ip)
                        self.text = "Add Camera"
                        self.size = [0.5, 1]
                        self.size_hint_x = .3
                        self.size_hint_y = 1

                    def on_release(self):
                        try:
                            self.create_camera_post_request(
                                self.ip, self.ip, 'GembirdCamera')
                            self.popup.dismiss_popup()

                        except Exception as e:
                            print e

                    def create_camera_post_request(self, name, ip, libname):
                        try:
                            data = {"name": name, "ip": ip, "libname": libname}

                            req = urllib2.Request(api_uri +
                                                  '/gui/createcamera')
                            req.add_header('Content-Type', 'application/json')

                            response = urllib2.urlopen(req, json.dumps(data))
                            print(response)
                        except ValueError as e:
                            traceback.print_exc()
                            print(e)

                av.add_widget(AddActionButton(self))

                actionbar.add_widget(av)

                self.ids.scanner_list.add_widget(actionbar)
        else:
            self.ids.scanner_list.add_widget(
                Label(text="Scanner status: {0}".format(
                    self.format_status(req['status']))))
Beispiel #5
0
    def build(self):
        # -- Estructura de la pagina principal --
        Window.clearcolor = (219, 219, 219, 1)
        self.p1 = GridLayout(rows=50, spacing=10, size_hint_y=1)
        self.p1.bind(minimum_height=self.p1.setter('height'),
                     minimum_width=self.p1.setter('width'))

        # -- Menu princial --
        Color = [0, 4, 5, 1]
        self.menu1 = MenuBar.ActionBar(pos_hint={'top': 0},
                                       background_color=Color)
        self.previos = MenuBar.ActionPrevious(title='', with_previous=False)
        self.menu2 = MenuBar.ActionView()

        # --- Acciones de menu ---
        self.li1 = MenuBar.ActionButton(text="Acerca de",
                                        size_hint_y=None,
                                        height=120,
                                        on_release=lambda b1: self.acercade())
        self.li4 = MenuBar.ActionButton(
            text="Ocultar",
            size_hint_y=None,
            height=120,
            on_release=lambda b1: self.antiacercade())
        self.li2 = MenuBar.ActionButton(text="Limpiar",
                                        size_hint_y=None,
                                        height=120,
                                        on_release=lambda b1: self.limp())
        self.li3 = MenuBar.ActionButton(text="Salir",
                                        size_hint_y=None,
                                        height=120,
                                        on_release=lambda b1: self.salir())

        # --- Se activan para la visualizacion en la pantalla ---
        # -- Accciones de menu --
        self.menu2.add_widget(self.li2)
        self.menu2.add_widget(self.li1)
        self.menu2.add_widget(self.li4)
        self.menu2.add_widget(self.li3)
        self.menu2.add_widget(self.previos)
        self.menu1.add_widget(self.menu2)
        self.p1.add_widget(self.menu1)

        # --- Elementos en pantalla ---
        colorl = [0, 0, 0, 1]
        Colo = [1, 0, 0, 1]
        self.label1 = Label(
            text=
            ' Nota: Puede realizar las siguientes operaciones: \nSuma, Multiplicacion, Resta, Division y Factorial ',
            size_hint_y=None,
            height=180,
            color=colorl)
        self.p1.add_widget(self.label1)
        # --- cuadros de textos ---
        # -- Cuadro 1 --
        self.p1.add_widget(
            Label(text='Ingrese el primer numero:',
                  color=colorl,
                  size_hint_y=None,
                  height=80))
        self.num1 = TextInput(text='0',
                              multiline=False,
                              size_hint_y=None,
                              height=80,
                              input_filter="float")
        self.p1.add_widget(self.num1)
        # -- Cuadro 2 --
        self.p1.add_widget(
            Label(text='Ingrese el segundo numero:',
                  color=colorl,
                  size_hint_y=None,
                  height=80))
        self.num2 = TextInput(text='0',
                              multiline=False,
                              size_hint_y=None,
                              height=80,
                              input_filter="float")
        self.p1.add_widget(self.num2)
        self.resultaditos = Label(text='',
                                  size_hint_y=None,
                                  height=80,
                                  color=Colo)
        self.p1.add_widget(self.resultaditos)
        # --- Bottones ---
        self.S = Button(text='Sumar',
                        size_hint_y=None,
                        height=135,
                        on_release=lambda b1: self.validar("Suma"))
        self.p1.add_widget(self.S)
        self.R = Button(text='Restar',
                        size_hint_y=None,
                        height=135,
                        on_release=lambda b1: self.validar("Resta"))
        self.p1.add_widget(self.R)
        self.M = Button(text='Multiplicar',
                        size_hint_y=None,
                        height=135,
                        on_release=lambda b1: self.validar("Multiplicacion"))
        self.p1.add_widget(self.M)
        self.D = Button(text='Division',
                        size_hint_y=None,
                        height=135,
                        on_release=lambda b1: self.validar("Division"))
        self.p1.add_widget(self.D)
        self.F = Button(text='Factorial',
                        size_hint_y=None,
                        height=135,
                        on_release=lambda b1: self.validar("Factorial"))
        self.p1.add_widget(self.F)
        # -- info extra --
        self.info = Label(text='', size_hint_y=None, height=250, color=Colo)
        self.p1.add_widget(self.info)
        self.p1.add_widget(
            Image(source='logo1.png', size_hint_y=None, height=500))
        # -- retornamos la pantalla principal
        return self.p1
Beispiel #6
0
    def place_list(self, req):
        print(type(req['status']))
        print self.format_status(req['status'])
        if req['status'] is 1 or self.pending:
            if not self.pending:
                self.pending = True
                self.counter = 20

            if self.pending:
                self.counter = - 1
                if self.counter is 0:
                    self.pending = False

            if self.pending and req['status'] is 0:
                req['status'] = 3

            self.ids.scanner_list.add_widget(
                Label(text="Scanner status: {0}".format(self.format_status(req['status']))))
            for x in req['ips']:
                actionbar = F.ActionBar(pos_hint={'top': 2})

                av = F.ActionView()
                av.add_widget(F.ActionPrevious(title=x, with_previous=False, size=[1, 1]))
                av.add_widget(F.ActionOverflow())

                print x

                class AddActionButton(Button, ActionItem):
                    def __init__(self, popup, **kwargs):
                        super(AddActionButton, self).__init__(**kwargs)
                        self.popup = popup
                        self.text = "Set as API"
                        self.size = [0.5, 1]
                        self.size_hint_x = .3
                        self.size_hint_y = 1

                    def on_press(self):
                        try:
                            self.set_api(x)
                            print 5
                            self.popup.dismiss_popup()
                            print 6


                        except Exception as e:
                            print e

                    def set_api(self, x):
                        api_url = 'http://{0}:3000'.format(x)

                        print(type(x))
                        print api_url

                        path_to_json = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'settings.json')
                        jsonFile = open(path_to_json, "r")
                        data = json.load(jsonFile)
                        jsonFile.close()

                        print 1

                        ## Working with buffered content
                        data["api_uri"] = api_url

                        JSONThread1 = JSONThread()
                        JSONThread1.data = data
                        JSONThread1.start()

                av.add_widget(AddActionButton(self))

                actionbar.add_widget(av)

                self.ids.scanner_list.add_widget(actionbar)
        else:
            self.ids.scanner_list.add_widget(
                Label(text="Scanner status: {0}".format(self.format_status(req['status']))))
    def place_list(self, req):
        try:
            if req['data'] is None:
                self.ids.content_layout.add_widget(
                    Label(text="No camera added yet"))

            else:
                # Print active camera list
                # pprint.pprint(req)

                for x in req['data']:
                    actionbar = F.ActionBar(pos_hint={'top': 1})

                    av = F.ActionView()
                    av.add_widget(
                        F.ActionPrevious(title=x['name'],
                                         with_previous=False,
                                         size=[0.5, 0.5]))
                    av.add_widget(F.ActionOverflow())

                    # Print CV STATUS of active camera list
                    # print 'CV assigned ' + str(x['cv_assigned'])
                    # print 'CV status   ' + str(x['cv_status'])

                    if x['cv_assigned'] is False:
                        titlestr = "Computer Vision: Not Assigned"
                    elif x['cv_status'] is False:
                        titlestr = "Computer Vision: OFF"
                    elif x['cv_status'] is True:
                        titlestr = "Computer Vision: ON"

                    ag = F.ActionGroup(text='CV')
                    ag.add_widget(
                        F.ActionPrevious(title=titlestr, with_previous=False))

                    class OffActionButton(Button, ActionItem):
                        def __init__(self, **kwargs):
                            super(OffActionButton, self).__init__(**kwargs)
                            self.camera_id = x['id']
                            self.text = "Off"
                            self.size = [0.5, 1]
                            self.size_hint_x = .3
                            self.size_hint_y = 1

                        def on_release(self):
                            try:
                                URL = api_uri + '/gui/disablecv/{0}'.format(
                                    self.camera_id)
                                r = requests.get(URL)
                                rjson = r.json()
                                print rjson
                            except Exception as e:
                                print e

                    class OnActionButton(Button, ActionItem):
                        def __init__(self, **kwargs):
                            super(OnActionButton, self).__init__(**kwargs)
                            self.camera_id = x['id']
                            self.text = "On"
                            self.size = [0.5, 1]
                            self.size_hint_x = .3
                            self.size_hint_y = 1

                        def on_release(self):
                            try:
                                URL = api_uri + '/gui/enablecv/{0}'.format(
                                    self.camera_id)
                                r = requests.get(URL)
                                rjson = r.json()
                                print rjson
                            except Exception as e:
                                print e

                    class ManualButton(Button, ActionItem):
                        def __init__(self, **kwargs):
                            super(ManualButton, self).__init__(**kwargs)
                            self.camera_id = x['id']
                            self.text = "Manual"
                            self.size = [0.5, 1]
                            self.size_hint_x = .3
                            self.size_hint_y = 1

                        def on_press(self):
                            try:
                                box = GridLayout(cols=3)
                                box.add_widget(
                                    Button(text='up_left',
                                           on_release=lambda *args: self.
                                           move_request('up_left', *args)))
                                box.add_widget(
                                    Button(text='up',
                                           on_release=lambda *args: self.
                                           move_request('up', *args)))
                                box.add_widget(
                                    Button(text='up_right',
                                           on_release=lambda *args: self.
                                           move_request('up_right', *args)))
                                box.add_widget(
                                    Button(text='left',
                                           on_release=lambda *args: self.
                                           move_request('left', *args)))
                                box.add_widget(
                                    Button(text='close',
                                           on_release=self.popup_close))
                                box.add_widget(
                                    Button(text='right',
                                           on_release=lambda *args: self.
                                           move_request('right', *args)))
                                box.add_widget(
                                    Button(text='down_left',
                                           on_release=lambda *args: self.
                                           move_request('down_left', *args)))
                                box.add_widget(
                                    Button(text='down',
                                           on_release=lambda *args: self.
                                           move_request('down', *args)))
                                box.add_widget(
                                    Button(text='down_right',
                                           on_release=lambda *args: self.
                                           move_request('down_right', *args)))
                                box.add_widget(Label(text='Size of margins'))
                                controlSlider = Slider(min=0.8,
                                                       max=1.05,
                                                       value=1)
                                box.add_widget(controlSlider)
                                box.add_widget(
                                    Button(text='Send Margins',
                                           on_release=lambda *args: self.
                                           send_slider_value(controlSlider.
                                                             value)))
                                self.popup = Popup(title='Manual Control',
                                                   content=box,
                                                   auto_dismiss=False,
                                                   size_hint=(.8, .8),
                                                   size=(400, 400))
                                self.popup.open()

                            except Exception as e:
                                traceback.print_exc()
                                print e

                        def send_slider_value(self, value):
                            URL = api_uri + '/get/slider/value={}'.format(
                                value)
                            r = requests.get(URL)
                            sleep(2)

                        def move_request(self, direction, *args):
                            print str(direction)
                            requests.get(
                                (api_uri +
                                 '/gui/move/manual/camera_id={}/direction={}'.
                                 format(self.camera_id, direction)))

                        def popup_close(self, *args):
                            self.popup.dismiss()

                    ag.add_widget(OffActionButton())
                    ag.add_widget(OnActionButton())
                    ag.add_widget(ManualButton())

                    av.add_widget(ag)

                    actionbar.add_widget(av)

                    self.ids.content_layout.add_widget(actionbar)
        except TypeError as e:
            traceback.print_exc()
            print(e)