Esempio n. 1
0
    def home_screen(self):
        self.manager.get_screen(
            'main').ids.btn_camera.color = get_color_from_hex('#FFFFFF')
        self.manager.get_screen(
            'main').ids.btn_home.color = get_color_from_hex('#2196F3')
        self.manager.get_screen(
            'main').ids.btn_user.color = get_color_from_hex('#FFFFFF')

        self.manager.get_screen('main').ids.master.clear_widgets()

        home_layout = GridLayout()
        home_layout.id = 'home_layout'
        home_layout.spacing = (0, 0.5)
        home_layout.padding = 40, 10, 40, 10
        home_layout.cols = 1
        home_layout.row_default_height = self.height * 0.25
        home_layout.row_force_default = True

        lbl_home = Label()
        lbl_home.id = 'lbl_home'
        lbl_home.color = get_color_from_hex('#212121')
        lbl_home.text = 'Home Layout'

        self.manager.get_screen('main').ids[home_layout.id] = \
            WeakProxy(home_layout)

        self.manager.get_screen('main').ids[lbl_home.id] = \
            WeakProxy(home_layout)

        self.manager.get_screen('main').ids.master.\
            add_widget(home_layout)

        self.manager.get_screen('main').ids.lbl_home.\
            add_widget(lbl_home)
Esempio n. 2
0
    def user_screen(self):
        self.manager.get_screen(
            'main').ids.btn_camera.color = get_color_from_hex('#FFFFFF')
        self.manager.get_screen(
            'main').ids.btn_home.color = get_color_from_hex('#FFFFFF')
        self.manager.get_screen(
            'main').ids.btn_user.color = get_color_from_hex('#2196F3')

        self.manager.get_screen('main').ids.master.clear_widgets()

        user_layout = GridLayout()
        user_layout.id = 'user_layout'
        user_layout.spacing = (0, 0.5)
        user_layout.padding = 40, 10, 40, 10
        user_layout.cols = 1
        user_layout.row_default_height = self.height * 0.25
        user_layout.row_force_default = True

        lbl_user = Label()
        lbl_user.id = 'lbl_home'
        lbl_user.color = get_color_from_hex('#212121')
        lbl_user.text = 'User Layout'

        self.manager.get_screen('main').ids[user_layout.id] = \
            WeakProxy(user_layout)

        self.manager.get_screen('main').ids[lbl_user.id] = \
            WeakProxy(lbl_user)

        self.manager.get_screen('main').ids.master.\
            add_widget(user_layout)

        self.manager.get_screen('main').ids.user_layout.\
            add_widget(lbl_user)
Esempio n. 3
0
    def camera_screen(self):
        self.manager.get_screen(
            'main').ids.btn_camera.color = get_color_from_hex('#2196F3')
        self.manager.get_screen(
            'main').ids.btn_home.color = get_color_from_hex('#FFFFFF')
        self.manager.get_screen(
            'main').ids.btn_user.color = get_color_from_hex('#FFFFFF')

        self.manager.get_screen('main').ids.master.clear_widgets()

        camera_layout = GridLayout()
        camera_layout.id = 'camera_layout'
        camera_layout.spacing = (0, 0.5)
        camera_layout.padding = 40, 10, 40, 10
        camera_layout.cols = 1
        camera_layout.row_default_height = self.height * 0.25
        camera_layout.row_force_default = True

        lbl_camera = Label()
        lbl_camera.id = 'lbl_camera'
        lbl_camera.color = get_color_from_hex('#212121')
        lbl_camera.text = 'Camera Layout'

        self.manager.get_screen('main').ids[camera_layout.id] = \
            WeakProxy(camera_layout)

        self.manager.get_screen('main').ids[lbl_camera.id] = \
            WeakProxy(lbl_camera)

        self.manager.get_screen('main').ids.master.\
            add_widget(camera_layout)

        self.manager.get_screen('main').ids.camera_layout.\
            add_widget(lbl_camera)
Esempio n. 4
0
    def __init__(self): #A second argument '**kwargs' can be added here, but not needed.
        super(GUIlayout, self).__init__() #The same here.

        #Two layouts are going to be used. A 'small' one (a GridLayout named 'seclayout') that is going to contain the buttons,
        #and a 'big' one (a BoxLayout referred by 'self') that is going to contain the canvas and the small layout.
        self.orientation = 'vertical'
        self.spacing = (5,5)

        self.xdat=[]           #List with the measured values.

        #The small layout and its parameters.
        seclayout = GridLayout()
        seclayout.rows = 2
        seclayout.cols = 3
        seclayout.size_hint_y = .2 #The percentage of the big layout in the y direction that this layout covers.
        #This is for the canvas to be bigger than the buttons.
        seclayout.row_force_default = True
        seclayout.row_default_height = 50

        #Buttons
        self.measurebutton = Button(text="Measure!")
        self.measurebutton.bind(on_press=lambda x: self.measure(canvas,1,wavefun)) #Lambda x: in order to send arguments to the function and avoid
        seclayout.add_widget(self.measurebutton)                           #"TypeError: <lambda>() takes 0 positional arguments but 1 was given"

        self.measure10button = Button(text="Measure x10")
        self.measure10button.bind(on_press=lambda x: self.measure(canvas,10,wavefun))
        seclayout.add_widget(self.measure10button)

        self.measure100button = Button(text="Measure x100")
        self.measure100button.bind(on_press=lambda x: self.measure(canvas,100,wavefun))
        seclayout.add_widget(self.measure100button)

        self.PDFbutton = Button(text="Check!")
        self.PDFbutton.bind(on_press=lambda x:self.showPDF(canvas))
        seclayout.add_widget(self.PDFbutton)

        self.clearbutton = Button(text="Clear")
        self.clearbutton.bind(on_press=lambda x: self.clearall(canvas))
        seclayout.add_widget(self.clearbutton)

        self.add_widget(seclayout) #The small layout is attached to the big layout as a usual widget.

        canvas = FigureCanvasKivyAgg(f)
        self.add_widget(canvas)
        #self. because it is attached to the big layout.

        #Setting plot things that are shared by PDF and histogram.
        a.set_title('Measurements histogram')
        a.set_xlabel('x')
        a.set_ylabel('Frequency')
        a.axis([-L/2., L/2., 0., 1.])