<PropertyLabel@Label>:
    halign: 'left'
    text_size: self.width, None
    #color: [0,0,0,1]
    font_size: 35

<EchoLabel@PropertyLabel>:
    halign: 'center'
    text_size: self.width, None
    #color: [0,0,0,1]
    font_size: 35



<CounterControl>:

    do_default_tab: False
    background_color: [0,0,0,0]
    TabbedPanelItem:
        text: 'Setup'
        Label:
            


      
        
            GridLayout:
                id: connection_box
                cols: 1
                x: root.width / 8
                width: root.width / 2
                top: root.height - root.height/8
                row_default_height: 70
                row_force_default: True
        
                PropertyLabel:
                    text: 'Serial port'
                
                Spinner:
                    id: connection_input
                    text: 'Select Serial Port'
                    values: root.serial_ports_android()
                    size_hint_y: None
                    
                
                
        
                Button:
                    text: 'connect' if not root.connected else 'disconnect'
                    on_release: root.connect_to_powermeter(connection_input.text)
        
            GridLayout:
                id: main_params
                cols: 2
                x: connection_box.x
                width: connection_box.width
                row_default_height: connection_box.row_default_height
                top: connection_box.y - self.row_default_height*2
                row_force_default: True

                PropertyLabel:
                    text: 'Serial'
        
                EchoLabel:
                    text: str(root.serial)         
        
        
                PropertyLabel:
                    text: 'Counts'
        
                EchoLabel:
                    text: str(root.counts.split()[0])

                PropertyLabel:
                    text: 'Current gate time'
        
                EchoLabel:
                    text: str(root.gate_time)  + ' ms'
        
                PropertyLabel:
                    text: 'Logic level'

                Spinner:
                    id: select_logic_level
                    text: str(root.logic_level)
                    values:('NIM','TTL')
                    size_hint_y: None
                    _on_dropdown_select:  root.set_logic_level(select_logic_level.text)
        
            AnchorLayout:
        
                anchor_x: 'left'
                anchor_y: 'bottom'
        
                x: root.x + 0.7*root.width
                y: root.y + 0.5*root.height
        
                width: 0.3 * root.width
                height: 0.3 * root.height        

        

                Image:
                    source: root.logo
                    size: [240,192]
                    size_hint: None, None


    TabbedPanelItem:
        text: 'Counts'
        Label: 
            GridLayout:
                id: power_pannel
                cols: 4
                x: root.width / 8
                width: root.width/1.2
                top: root.height - root.height / 6
                row_default_height: 50
                row_force_default: True
                spacing: [40,40]

                PropertyLabel:
                    text: 'Gate time'

                FloatInput:
                    id: gate_time
                    text: str(root.gate_time)
                    #value:780            
                    
                    font_size: 35

                PropertyLabel:
                    text: 'Logic level'

                Spinner:
                    id: select_logic_level_2
                    text: str(root.logic_level)
                    values:('TTL','NIM')
                    size_hint_y: None
                    _on_dropdown_select: root.set_logic_level(select_logic_level_2.text)



            GridLayout:
                id: power_pannel
                cols: 3
                x: root.width / 8
                width: root.width/1.2
                top: root.height - root.height / 3
                row_default_height: 50
                row_force_default: True
                spacing: [40,40]   

                PropertyLabel:
                    text: 'Channel 0'

                PropertyLabel:
                    text: 'Channel 1'

                PropertyLabel:
                    text: 'Channel 2'

                EchoLabel:
                    id: channel_0
                    text:  str(root.counts.split()[0])
                    font_size: 50

                EchoLabel:
                    id: channel_1
                    text:  str(root.counts.split()[1])
                    font_size: 50

                EchoLabel:
                    id: channel_2
                    text:  str(root.counts.split()[2])
                    font_size: 50

    TabbedPanelItem:
        text: 'Frequency'
        Label: 
            GridLayout:
                id: freq_pannel_1
                cols: 4
                x: root.width / 8
                width: root.width/1.2
                top: root.height - root.height / 6
                row_default_height: 50
                row_force_default: True
                spacing: [40,40]

                PropertyLabel:
                    text: 'Gate time'

                FloatInput:
                    id: gate_time
                    text: str(root.gate_time)
                    #value:780            
                    
                    font_size: 35

                PropertyLabel:
                    text: 'Logic level'

                Spinner:
                    id: select_logic_level_2
                    text: str(root.logic_level)
                    values:('TTL','NIM')
                    size_hint_y: None
                    _on_dropdown_select: root.set_logic_level(select_logic_level_2.text)



            GridLayout:
                id: freq_pannel_2
                cols: 3
                x: root.width / 8
                width: root.width/1.2
                top: root.height - root.height / 3
                row_default_height: 50
                row_force_default: True
                spacing: [40,40]   

                PropertyLabel:
                    text: 'Channel 0'

                PropertyLabel:
                    text: 'Channel 1'

                PropertyLabel:
                    text: 'Channel 2'

                EchoLabel:
                    id: channel_0
                    text:  str(float(root.counts.split()[0])/(1000*root.gate_time))
                    font_size: 50

                EchoLabel:
                    id: channel_1
                    text:  str(float(root.counts.split()[1])/(1000*root.gate_time))
                    font_size: 50

                EchoLabel:
                    id: channel_2
                    text:  str(float(root.counts.split()[2])/(1000*root.gate_time))
                    font_size: 50



 
    TabbedPanelItem:
        text: 'Counts plot'
        Label: 

            AnchorLayout:
        
                anchor_x: 'left'
                anchor_y: 'bottom'
        
                x: root.x + 0.1*root.width
                y: root.y + 0.1*root.height
        
                width: 0.8 * root.width
                height: 0.8 * root.height
        

                Graph:
                    id: graph1
                    xlabel: 'Time (Sec)'
                    ylabel: 'Counts (per Bin period)'
                    ymin: 0
                    ymax: 10
                    xmin: 0
                    xmax: 150
                    y_grid: True
                    y_ticks_major: 2
                    y_grid_label: 'True'
                    x_grid_label: 'True'
                    #x_grid: 'True'
                    x_ticks_major: 50
                    label_options: dict(color=[1,1,1,1],bold='True')
    TabbedPanelItem:
        text: 'Counts Log'
        Label: 
            text:'Coming in a future version'
