问:
content dynamically set in one boxlayout

test.py

```<code>import kivy

kivy.require('1.9.0')  # replace with your current kivy version !
import sqlite3 as lite
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import BooleanProperty, ListProperty, ObjectProperty,NumericProperty
from kivy.lang import Builder
from kivy.uix.dropdown import DropDown

from kivy.uix.recycleview.views import RecycleDataViewBehavior
from kivy.uix.button import Button
from kivy.uix.recyclegridlayout import RecycleGridLayout
from kivy.uix.behaviors import FocusBehavior
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
from kivy.uix.popup import Popup
from kivy.core.window import Window
Window.maximize()
from kivy.clock import Clock
from kivy.uix.treeview import TreeView, TreeViewLabel, TreeViewNode

class EditStatePopup(Popup):
    col_data = ListProperty(["?", "?", "?"])
    index = NumericProperty(0)

    def __init__(self, obj, **kwargs):
        super(EditStatePopup, self).__init__(**kwargs)
        self.index = obj.index
        self.col_data[0] = obj.rv_data[self.index]["StateId"]
        self.col_data[1] = obj.rv_data[self.index]["StateName"]
        self.col_data[2] = obj.rv_data[self.index]["StateCode"]

    def package_changes(self, stateName, stateCode):
        self.col_data[1] = stateName
        self.col_data[2] = stateCode

class SelectableRecycleGridLayout(FocusBehavior, LayoutSelectionBehavior,
                                  RecycleGridLayout):
    ''' Adds selection and focus behaviour to the view. '''

class SelectableButton(RecycleDataViewBehavior, Button):
    ''' Add selection support to the Button '''
    index = None
    selected = BooleanProperty(False)
    selectable = BooleanProperty(True)
    rv_data = ObjectProperty(None)
    start_point = NumericProperty(0)

    def __init__(self, **kwargs):
        super(SelectableButton, self).__init__(**kwargs)
        Clock.schedule_interval(self.update, .0005)

    def update(self, *args):
        self.text = self.rv_data[self.index][self.key]

    def refresh_view_attrs(self, rv, index, data):
        ''' Catch and handle the view changes '''
        self.index = index
        return super(SelectableButton, self).refresh_view_attrs(rv, index, data)

    def on_touch_down(self, touch):
        ''' Add selection on touch down '''
        if super(SelectableButton, self).on_touch_down(touch):
            return True
        if self.collide_point(*touch.pos) and self.selectable:
            return self.parent.select_with_touch(self.index, touch)

    def apply_selection(self, rv, index, is_selected):
        self.selected = is_selected
        self.rv_data = rv.data

    def on_press(self):
        popup = EditStatePopup(self)
        popup.open()

class RV(BoxLayout):
    data_items = ListProperty([])
    col1 = ListProperty()
    col2 = ListProperty()
    col3 = ListProperty()

    def __init__(self, **kwargs):
        super(RV, self).__init__(**kwargs)
        self.get_states()

    def update(self):
        self.col1 = [{'StateId': str(x[0]), 'StateName': x[1], 'StateCode': str(x[2]), 'key': 'StateId'} for x in self.data_items]
        self.col2 = [{'StateId': str(x[0]), 'StateName': x[1], 'StateCode': str(x[2]), 'key': 'StateName'} for x in self.data_items]
        self.col3 = [{'StateId': str(x[0]), 'StateName': x[1], 'StateCode': str(x[2]), 'key': 'StateCode'} for x in self.data_items]

    def get_states(self):

        rows = [(1, 'Andaman and Nicobar Islands ', 35), (2, 'Andhra Pradesh', 28), (3, 'Arunachal Pradesh', 12), (4, 'Assam', 18), (5, 'Bihar', 10), (6, 'Chandigarh', 4), (7, 'Chattisgarh', 22)]

        i = 0
        for row in rows:
            self.data_items.append([row[0], row[1], row[2], i])
            i += 1
        print(self.data_items)
        self.update()

def populate_tree_view(tree_view, parent, node):
    if parent is None:
        tree_node = tree_view.add_node(TreeViewLabel(text=node['node_id'],
                                                     is_open=True))
    else:
        tree_node = tree_view.add_node(TreeViewLabel(text=node['node_id'],
                                                     is_open=True), parent)

    for child_node in node['children']:
        populate_tree_view(tree_view, tree_node, child_node)

rows = [(1, 'Andaman and Nicobar Islands ', 35), (2, 'Andhra Pradesh', 28), (3, 'Arunachal Pradesh', 12), (4, 'Assam', 18), (5, 'Bihar', 10), (6, 'Chandigarh', 4), (7, 'Chattisgarh', 22)]

tree = []

for r in rows:
    tree.append({'node_id': r[1], 'children': []})

class TreeviewGroup(Popup):
    treeview = ObjectProperty(None)
    tv = ObjectProperty(None)
    h = NumericProperty(0)
    #ti = ObjectProperty()

    def __init__(self, **kwargs):
        super(TreeviewGroup, self).__init__(**kwargs)
        self.tv = TreeView(root_options=dict(text=""),
                       hide_root=False,
                       indent_level=4)
        for branch in tree:
            populate_tree_view(self.tv, None, branch)
        #self.remove_widgets()
        self.treeview.add_widget(self.tv)
        Clock.schedule_once(self.update, 1)

    def remove_widgets(self):
        for child in [child for child in self.treeview.children]:
            self.treeview.remove_widget(child)

    def update(self, *args):
        self.h = len([child for child in self.tv.children]) * 24

class EditCityPopup(Popup):
    col_data = ListProperty(["?", "?", "?", "?", "?"])
    index = NumericProperty(0)
    popup = ObjectProperty(None)

    def __init__(self, obj, **kwargs):
        super(EditCityPopup, self).__init__(**kwargs)
        self.index = obj.index
        self.col_data[0] = obj.rv_data_city[self.index]["cityId"]
        self.col_data[1] = obj.rv_data_city[self.index]["stateId"]
        self.col_data[2] = obj.rv_data_city[self.index]["cityName"]
        self.col_data[3] = obj.rv_data_city[self.index]["shortName"]
        self.col_data[4] = obj.rv_data_city[self.index]["pinCode"]

    def package_changes(self, stateId, cityName, shortName, pinCode):
        self.col_data[1] = stateId
        self.col_data[2] = cityName
        self.col_data[3] = shortName
        self.col_data[4] = pinCode

    def display_states_treeview(self, instance):
        if len(instance.text) > 0:
            if self.popup is None:
                self.popup = TreeviewGroup()
            self.popup.open()

class SelectableButtonCity(RecycleDataViewBehavior, Button):
    ''' Add selection support to the Button '''
    index = None
    selected = BooleanProperty(False)
    selectable = BooleanProperty(True)
    rv_data_city = ObjectProperty(None)
    start_point = NumericProperty(0)

    def __init__(self, **kwargs):
        super(SelectableButtonCity, self).__init__(**kwargs)
        Clock.schedule_interval(self.update, .0005)

    def update(self, *args):
        self.text = self.rv_data_city[self.index][self.key]

    def refresh_view_attrs(self, rv, index, data):
        ''' Catch and handle the view changes '''
        self.index = index
        return super(SelectableButtonCity, self).refresh_view_attrs(rv, index, data)

    def on_touch_down(self, touch):
        ''' Add selection on touch down '''
        if super(SelectableButtonCity, self).on_touch_down(touch):
            return True
        if self.collide_point(*touch.pos) and self.selectable:
            return self.parent.select_with_touch(self.index, touch)

    def apply_selection(self, rv, index, is_selected):
        ''' Respond to the selection of items in the view. '''
        self.selected = is_selected
        self.rv_data_city = rv.data

    def on_press(self):
        popup = EditCityPopup(self)
        popup.open()

class RVCITY(BoxLayout):
    data_items_city = ListProperty([])
    col1 = ListProperty()
    col2 = ListProperty()
    col3 = ListProperty()
    col4 = ListProperty()
    col5 = ListProperty()

    def __init__(self, **kwargs):
        super(RVCITY, self).__init__(**kwargs)
        self.get_cities()

    def update(self):
        self.col1 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'cityId'} for x in self.data_items_city]
        self.col2 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'stateId'} for x in self.data_items_city]
        self.col3 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'cityName'} for x in self.data_items_city]
        self.col4 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'shortName'} for x in self.data_items_city]
        self.col5 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'pinCode'} for x in self.data_items_city]

    def get_cities(self):

        rows = [(1, 'Bihar', 'Patna', 'Patna', 801108), (2, 'Andaman and Nicobar Islands ', 'Port Blair', 'PB', 744101), (3, 'Assam', 'Guwahati', 'Guwahati', 781001), (4, 'Assam', 'Nagaon', 'Nagaon', 782120), (5, 'Chandigarh', 'Amritsar', 'Amritsar', 143502), (6, 'Andhra Pradesh', 'Visakhapatnam', 'VP', 531219), (7, 'Chattisgarh', 'Bilaspur', 'Bilaspur', 495001)]
        i = 0
        for row in rows:
            self.data_items_city.append([row[0], row[1], row[2], row[3], row[4], i])
            i += 1
        print(self.data_items_city)
        self.update()

class EditAreaPopup(Popup):
    col_data = ListProperty(["?", "?", "?"])
    index = NumericProperty(0)
    popup = ObjectProperty(None)

    def __init__(self, obj, **kwargs):
        super(EditAreaPopup, self).__init__(**kwargs)
        self.index = obj.index
        self.col_data[0] = obj.rv_data_area[self.index]["areaId"]
        self.col_data[1] = obj.rv_data_area[self.index]["cityId"]
        self.col_data[2] = obj.rv_data_area[self.index]["areaName"]

    def package_changes(self, stateId, cityName):
        self.col_data[1] = stateId
        self.col_data[2] = cityName

    def display_city_treeview(self, instance):
        if len(instance.text) > 0:
            if self.popup is None:
                self.popup = TreeviewGroup()
            #self.popup.filter(instance.text)
            self.popup.open()

class SelectableButtonArea(RecycleDataViewBehavior, Button):
    ''' Add selection support to the Button '''
    index = None
    selected = BooleanProperty(False)
    selectable = BooleanProperty(True)
    rv_data_area = ObjectProperty(None)
    start_point = NumericProperty(0)

    def __init__(self, **kwargs):
        super(SelectableButtonArea, self).__init__(**kwargs)
        Clock.schedule_interval(self.update, .0005)

    def update(self, *args):
        self.text = self.rv_data_area[self.index][self.key]

    def refresh_view_attrs(self, rv, index, data):
        ''' Catch and handle the view changes '''
        self.index = index
        return super(SelectableButtonArea, self).refresh_view_attrs(rv, index, data)

    def on_touch_down(self, touch):
        ''' Add selection on touch down '''
        if super(SelectableButtonArea, self).on_touch_down(touch):
            return True
        if self.collide_point(*touch.pos) and self.selectable:
            return self.parent.select_with_touch(self.index, touch)

    def apply_selection(self, rv, index, is_selected):
        ''' Respond to the selection of items in the view. '''
        self.selected = is_selected
        self.rv_data_area = rv.data
        #print("selection changed to {0}".format(rv.data[1]))

    def on_press(self):
        popup = EditAreaPopup(self)
        popup.open()

class RVAREA(BoxLayout):
    data_items_area = ListProperty([])
    col1 = ListProperty()
    col2 = ListProperty()
    col3 = ListProperty()

    def __init__(self, **kwargs):
        super(RVAREA, self).__init__(**kwargs)
        self.get_areas()

    def update(self):
        self.col1 = [{'areaId': str(x[0]), 'cityId': str(x[1]), 'areaName': str(x[2]),  'key': 'areaId'} for x in self.data_items_area]
        self.col2 = [{'areaId': str(x[0]), 'cityId': str(x[1]), 'areaName': str(x[2]),  'key': 'cityId'} for x in self.data_items_area]
        self.col3 = [{'areaId': str(x[0]), 'cityId': str(x[1]), 'areaName': str(x[2]),  'key': 'areaName'} for x in self.data_items_area]

    def get_areas(self):

        rows = [(1, 'Amritsar', 'area1')]
        i = 0
        for row in rows:
            self.data_items_area.append([row[0], row[1], row[2], i])
            i += 1
        print(self.data_items_area)
        self.update()

class CustDrop(DropDown):
    def __init__(self, **kwargs):
        super(CustDrop, self).__init__(**kwargs)
        self.select('')

class MainMenu(BoxLayout):
    states_cities_or_areas = ObjectProperty()
    rv = ObjectProperty(None)
    dropdown = ObjectProperty(None)
    #Define City Variable
    rvcity = ObjectProperty(None)
    #Area City Variable
    rvarea = ObjectProperty(None)

    def display_states(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rv = RV()
        self.states_cities_or_areas.add_widget(self.rv)

    def display_cities(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvcity = RVCITY()
        self.states_cities_or_areas.add_widget(self.rvcity)

    def display_areas(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvarea = RVAREA()
        self.states_cities_or_areas.add_widget(self.rvarea)

    def remove_widgets(self):
        self.states_cities_or_areas.clear_widgets()

class FactApp(App):
    title = "test"

    def build(self):
        self.root = Builder.load_file('test.kv')
        return MainMenu()

if __name__ == '__main__':
    FactApp().run()
</code>```

test.kv

```<code>#:kivy 1.10.0
#:import CoreImage kivy.core.image.Image
#:import os os

<EditStatePopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 200
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "Id"
            Label:
                id: stateId
                text: root.col_data[0]
            Label:
                text: "State Name"
            TextInput:
                id: stateName
                text: root.col_data[1]
            Label:
                text: "State Code"
            TextInput:
                id: stateCode
                text: root.col_data[2]

            Button:
                size_hint: 1, 1
                text: "Ok"
                on_release:
                    root.package_changes(stateName.text, stateCode.text)
                    app.root.update_states(root)
                    root.dismiss()

            Button:
                size_hint: 1, 1
                text: "Cancel"
                on_release: root.dismiss()

<TreeViewLabel>:
    size_hint_y: None
    height: 24
    on_touch_down:
        app.root.stateName.text = self.text
        app.root.popup.dismiss()

<TreeviewGroup>:
    id: treeview
    treeview: treeview
    title: "Select State"
    size_hint: .3,.3
    size: 800, 800
    auto_dismiss: False

    BoxLayout
        orientation: "vertical"
        ScrollView:
            size_hint: 1, .9
            BoxLayout:
                size_hint_y: None
                id: treeview
                height: root.h
        Button:
            size_hint: 1, 0.1
            text: "Close"
            on_release: root.dismiss()

<SelectableButton>:
    canvas.before:
        Color:
            rgba: (0, 0.517, 0.705, 1) if self.selected else (0, 0.517, 0.705, 1)
        Rectangle:
            pos: self.pos
            size: self.size

<MyRV@RecycleView>:
    viewclass: 'SelectableButton'
    SelectableRecycleGridLayout:
        cols: 1
        default_size: None, dp(26)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        multiselect: True
        touch_multiselect: True

<RV>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 3

            Label:
                size_hint_x: .1
                text: "Id"
            Label:
                size_hint_x: .5
                text: "State Name"
            Label:
                size_hint_x: .4
                text: "State Code"

        BoxLayout:
            MyRV:
                size_hint_x: .1
                data: root.col1
            MyRV:
                size_hint_x: .5
                data: root.col2
            MyRV:
                size_hint_x: .4
                data: root.col3

<EditCityPopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 400
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "City Id"
            Label:
                id: cityId
                text: root.col_data[0]
            Label:
                text: "State Id"
            TextInput:
                id: stateId
                text: root.col_data[1]
                on_focus: root.display_states_treeview(self)
            Label:
                text: "city Name"
            TextInput:
                id: cityName
                text: root.col_data[2]
            Label:
                text: "Short Name"
            TextInput:
                id: shortName
                text: root.col_data[3]
            Label:
                text: "Pin Code"
            TextInput:
                id: pinCode
                text: root.col_data[4]

            Button:
                size_hint: 1, 1
                text: "Ok"
                on_release:
                    root.package_changes(stateId.text, cityName.text, shortName.text, pinCode.text)
                    app.root.update_cities(root)
                    root.dismiss()

            Button:
                size_hint: 1, 1
                text: "Cancel"
                on_release: root.dismiss()

<MyRvCity@RecycleView>:
    viewclass: 'SelectableButtonCity'
    SelectableRecycleGridLayout:
        cols: 1
        default_size: None, dp(26)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        multiselect: True
        touch_multiselect: True

<RVCITY>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y:None
            height: 25
            cols: 5

            Label:
                size_hint_x: .1
                text: "City Id"
            Label:
                size_hint_x: .2
                text: "State Name"
            Label:
                size_hint_x: .3
                text: "City Name"
            Label:
                size_hint_x: .2
                text: "Short Name"
            Label:
                size_hint_x: .2
                text: "Pin Code"

        BoxLayout:
            MyRvCity:
                size_hint_x: .1
                data: root.col1
            MyRvCity:
                size_hint_x: .2
                data: root.col2
            MyRvCity:
                size_hint_x: .3
                data: root.col3
            MyRvCity:
                size_hint_x: .2
                data: root.col4
            MyRvCity:
                size_hint_x: .2
                data: root.col5

<EditAreaPopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 400
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "City Id"
            Label:
                id: cityId
                text: root.col_data[0]
            Label:
                text: "State Id"
            TextInput:
                id: stateId
                text: root.col_data[1]
                on_focus: root.display_states_treeview(self)
            Label:
                text: "city Name"
            TextInput:
                id: cityName
                text: root.col_data[2]

            Button:
                size_hint: 1, 1
                text: "Ok"
                on_release:
                    root.package_changes(stateId.text, cityName.text, shortName.text, pinCode.text)
                    app.root.update_cities(root)
                    root.dismiss()

            Button:
                size_hint: 1, 1
                text: "Cancel"
                on_release: root.dismiss()

<MyRvArea@RecycleView>:
    viewclass: 'SelectableButtonArea'
    SelectableRecycleGridLayout:
        cols: 1
        default_size: None, dp(26)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        multiselect: True
        touch_multiselect: True

<RVAREA>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 3

            Label:
                size_hint_x: .1
                text: "Area Id"
            Label:
                size_hint_x: .5
                text: "City Name"
            Label:
                size_hint_x: .4
                text: "Area Name"

        BoxLayout:
            MyRvArea:
                size_hint_x: .1
                data: root.col1
            MyRvArea:
                size_hint_x: .5
                data: root.col2
            MyRvArea:
                size_hint_x: .4
                data: root.col3

<DropdownButton@Button>:
    border: (0, 16, 0, 16)
    text_size: self.size
    valign: "middle"
    padding_x: 5
    size_hint_y: None
    height: '30dp'
    background_color: 90 , 90, 90, 90
    color: 0, 0.517, 0.705, 1

<MenuButton@Button>:
    text_size: self.size
    valign: "middle"
    padding_x: 5
    size : (80,30)
    size_hint : (None, None)
    background_color: 90 , 90, 90, 90
    background_normal: ''
    color: 0, 0.517, 0.705, 1
    border: (0, 10, 0, 0)

<MainMenu>:
    states_cities_or_areas: states_cities_or_areas
    dropdown: dropdown

    BoxLayout:
        orientation: 'vertical'
        #spacing : 10

        BoxLayout:
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

            size_hint_y: 1

            MenuButton:
                id: btn
                text: 'Test'
                size : (60,30)
                on_release: dropdown.open(self)

            CustDrop:
                id: dropdown
                auto_width: False
                width: 150

                DropdownButton:
                    text: 'Test1'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_states()

                DropdownButton:
                    text: 'Test2'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_cities()
                DropdownButton:
                    text: 'Test3'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_areas()

        BoxLayout:
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

                Color:
                    rgb: (1,1,1)

            Label:
                size_hint_x: 45

        BoxLayout:
            id: states_cities_or_areas
            size_hint_y: 10

        Label:
            size_hint_y: 1
</code>```

Can anyone help me?

When i click on test then sub menu will be open.When i click on state then it look like good.But i click on city then distance increase between 'Test' and Row.

when i click on 'city' then show rows of city.when i click on any row then it looks Select state(treeview) show behind of 'update state'

I want it up on update state when anyone type anything in 'state Id'

i am using treeview in select state.how to add scrollbar in select state.when state increase then scroll will be good option

After update code I have a more error.

1. When i select state from select state then it's not put that string in state Name.Its showing error

   File "/usr/share/kivy-examples/gst_fact/test.kv", line 50, in

app.root.stateName.text = self.text

AttributeError: 'MainMenu' object has no attribute 'stateName'

答:
I want to when i click on anyone(state,city,area) then row show top position like Image_1.

It's because you have set the rules of your main menu in your kv to reserve the space for each box city, state and area. You can remove these rules and add only one box which I called states_cities_or_areas:

```<code>...

<MainMenu>:
    states_cities_or_areas: states_cities_or_areas
    dropdown: dropdown

    BoxLayout:
        orientation: 'vertical'
        #spacing : 10
        BoxLayout:
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

            size_hint_y: 5

            MenuButton:
                id: btn
                text: 'Test'
                size : (60,30)
                on_release: dropdown.open(self)

            CustDrop:
                id: dropdown
                auto_width: False
                width: 150

                DropdownButton:
                    text: 'State'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_states()

                DropdownButton:
                    text: 'City'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_cities()
                DropdownButton:
                    text: 'Area'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_areas()

        BoxLayout:
            size_hint_y: 2.5
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

                Color:
                    rgb: (1,1,1)

            Label:
                size_hint_x: 45

        BoxLayout:
            id: states_cities_or_areas
            size_hint_y: 89
        Label:
            size_hint_y: 1

...
</code>```

then change some methods and attributes of the mainmenu in the .py:

```<code>...
class MainMenu(BoxLayout):
    states_cities_or_areas = ObjectProperty()
    rv = ObjectProperty(None)
    dropdown = ObjectProperty(None)
    #Define City Variable
    rvcity = ObjectProperty(None)
    #Area City Variable
    rvarea = ObjectProperty(None)

    def display_states(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rv = RV()
        self.states_cities_or_areas.add_widget(self.rv)

    def display_cities(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvcity = RVCITY()
        self.states_cities_or_areas.add_widget(self.rvcity)

    def display_areas(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvarea = RVAREA()
        self.states_cities_or_areas.add_widget(self.rvarea)

    def remove_widgets(self):
        self.states_cities_or_areas.clear_widgets()

...
</code>```

I have noticed that the tiles of colums of city was not displayed, you can display it with this in the kv:

```<code>...

<RVCITY>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 5
...
</code>```

when i click on 'city' then show rows of city.when i click on any row then it looks Select state(treeview) show behind of 'update state' like image_4 I want it up on update state when anyone type anything in 'state Id' like image_5

It's because the StateId text input is already on_text before the the popup opens. I suggest you to replace on_text with on_focus:

```<code>...
<EditCityPopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 400
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "City Id"
            Label:
                id: cityId
                text: root.col_data[0]
            Label:
                text: "State Id"
            TextInput:
                id: stateId
                text: root.col_data[1]
                on_focus: root.display_states_treeview(self)
...
</code>```

i am using treeview in select state.how to add scrollbar in select state.when state increase then scroll will be good option

You just have to put the treeview in a scrollview:

```<code>...
<TreeViewLabel>:
size_hint_y: None
    height: 24
    on_touch_down:
        app.root.stateName.text = self.text
        app.root.select_node(self)
        app.root.popup.dismiss()

<TreeviewGroup>:
    treeview: treeview
    title: "Select State"
    size_hint: .3,.3
    auto_dismiss: False
    BoxLayout
        orientation: "vertical"
        ScrollView:
            size_hint: 1, .9
            BoxLayout:
                size_hint_y: None
                id: treeview
                height: root.h
        Button:
            size_hint: 1, 0.1
            text: "Close"
            on_release: root.dismiss()
</code>```

and in the .py:

```<code>...

class TreeviewGroup(Popup):
    treeview = ObjectProperty(None)
    tv = ObjectProperty(None)
    h = NumericProperty(0)
    #ti = ObjectProperty()

    def __init__(self, **kwargs):
        super(TreeviewGroup, self).__init__(**kwargs)
        self.tv = TreeView(root_options=dict(text=""),
                   hide_root=True,
                   indent_level=4)
        for branch in tree:
            populate_tree_view(self.tv, None, branch)
        #self.remove_widgets()
        self.treeview.add_widget(self.tv)
        Clock.schedule_once(self.update, 1)

    def remove_widgets(self):
        for child in [child for child in self.treeview.children]:
            self.treeview.remove_widget(child)

    def update(self, *args):
        self.h = len([child for child in self.tv.children]) * 24
</code>```

Update

FOR THE 4TH POINT;

to pass the stateName to the other popup,keep the instance of the first popup when you create the 2nd:

```<code>...
class TreeviewGroup(Popup):
    treeview = ObjectProperty(None)
    tv = ObjectProperty(None)
    h = NumericProperty(0)
    #ti = ObjectProperty()
    popup = ObjectProperty()
...

class EditCityPopup(Popup):

...

def display_states_treeview(self, instance):
    if len(instance.text) > 0:
        if self.popup is None:
            self.popup = TreeviewGroup()
            self.popup.popup = self
        self.popup.open()
</code>```

To reach the first popup in the kv make those changes:

in the .py:

```<code>...
class MyBoxLayout(BoxLayout):
    rooot = ObjectProperty()
...
</code>```

In the kv:

```<code>...
<TreeViewLabel>:
    size_hint_y: None
    height: 24
    on_touch_down:
        root.parent.parent.rooot.popup.col_data[1] = self.text
        #app.root.select_node(self)
        root.parent.parent.rooot.popup.popup.dismiss()

<TreeviewGroup>:
    id: treeview
    treeview: treeview
    title: "Select State"
    size_hint: .3,.3
    size: 800, 800
    auto_dismiss: False

    BoxLayout
        orientation: "vertical"
        ScrollView:
            size_hint: 1, .9
            MyBoxLayout:
                size_hint_y: None
                id: treeview
                height: root.h
                rooot: root
...
</code>```

Body:
test.py

import kivy

kivy.require('1.9.0')  # replace with your current kivy version !
import sqlite3 as lite
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import BooleanProperty, ListProperty, ObjectProperty,NumericProperty
from kivy.lang import Builder
from kivy.uix.dropdown import DropDown

from kivy.uix.recycleview.views import RecycleDataViewBehavior
from kivy.uix.button import Button
from kivy.uix.recyclegridlayout import RecycleGridLayout
from kivy.uix.behaviors import FocusBehavior
from kivy.uix.recycleview.layout import LayoutSelectionBehavior
from kivy.uix.popup import Popup
from kivy.core.window import Window
Window.maximize()
from kivy.clock import Clock
from kivy.uix.treeview import TreeView, TreeViewLabel, TreeViewNode

class EditStatePopup(Popup):
    col_data = ListProperty(["?", "?", "?"])
    index = NumericProperty(0)

    def __init__(self, obj, **kwargs):
        super(EditStatePopup, self).__init__(**kwargs)
        self.index = obj.index
        self.col_data[0] = obj.rv_data[self.index]["StateId"]
        self.col_data[1] = obj.rv_data[self.index]["StateName"]
        self.col_data[2] = obj.rv_data[self.index]["StateCode"]

    def package_changes(self, stateName, stateCode):
        self.col_data[1] = stateName
        self.col_data[2] = stateCode

class SelectableRecycleGridLayout(FocusBehavior, LayoutSelectionBehavior,
                                  RecycleGridLayout):
    ''' Adds selection and focus behaviour to the view. '''

class SelectableButton(RecycleDataViewBehavior, Button):
    ''' Add selection support to the Button '''
    index = None
    selected = BooleanProperty(False)
    selectable = BooleanProperty(True)
    rv_data = ObjectProperty(None)
    start_point = NumericProperty(0)

    def __init__(self, **kwargs):
        super(SelectableButton, self).__init__(**kwargs)
        Clock.schedule_interval(self.update, .0005)

    def update(self, *args):
        self.text = self.rv_data[self.index][self.key]

    def refresh_view_attrs(self, rv, index, data):
        ''' Catch and handle the view changes '''
        self.index = index
        return super(SelectableButton, self).refresh_view_attrs(rv, index, data)

    def on_touch_down(self, touch):
        ''' Add selection on touch down '''
        if super(SelectableButton, self).on_touch_down(touch):
            return True
        if self.collide_point(*touch.pos) and self.selectable:
            return self.parent.select_with_touch(self.index, touch)

    def apply_selection(self, rv, index, is_selected):
        self.selected = is_selected
        self.rv_data = rv.data

    def on_press(self):
        popup = EditStatePopup(self)
        popup.open()

class RV(BoxLayout):
    data_items = ListProperty([])
    col1 = ListProperty()
    col2 = ListProperty()
    col3 = ListProperty()

    def __init__(self, **kwargs):
        super(RV, self).__init__(**kwargs)
        self.get_states()

    def update(self):
        self.col1 = [{'StateId': str(x[0]), 'StateName': x[1], 'StateCode': str(x[2]), 'key': 'StateId'} for x in self.data_items]
        self.col2 = [{'StateId': str(x[0]), 'StateName': x[1], 'StateCode': str(x[2]), 'key': 'StateName'} for x in self.data_items]
        self.col3 = [{'StateId': str(x[0]), 'StateName': x[1], 'StateCode': str(x[2]), 'key': 'StateCode'} for x in self.data_items]

    def get_states(self):

        rows = [(1, 'Andaman and Nicobar Islands ', 35), (2, 'Andhra Pradesh', 28), (3, 'Arunachal Pradesh', 12), (4, 'Assam', 18), (5, 'Bihar', 10), (6, 'Chandigarh', 4), (7, 'Chattisgarh', 22)]

        i = 0
        for row in rows:
            self.data_items.append([row[0], row[1], row[2], i])
            i += 1
        print(self.data_items)
        self.update()

def populate_tree_view(tree_view, parent, node):
    if parent is None:
        tree_node = tree_view.add_node(TreeViewLabel(text=node['node_id'],
                                                     is_open=True))
    else:
        tree_node = tree_view.add_node(TreeViewLabel(text=node['node_id'],
                                                     is_open=True), parent)

    for child_node in node['children']:
        populate_tree_view(tree_view, tree_node, child_node)

rows = [(1, 'Andaman and Nicobar Islands ', 35), (2, 'Andhra Pradesh', 28), (3, 'Arunachal Pradesh', 12), (4, 'Assam', 18), (5, 'Bihar', 10), (6, 'Chandigarh', 4), (7, 'Chattisgarh', 22)]

tree = []

for r in rows:
    tree.append({'node_id': r[1], 'children': []})

class TreeviewGroup(Popup):
    treeview = ObjectProperty(None)
    tv = ObjectProperty(None)
    h = NumericProperty(0)
    #ti = ObjectProperty()

    def __init__(self, **kwargs):
        super(TreeviewGroup, self).__init__(**kwargs)
        self.tv = TreeView(root_options=dict(text=""),
                       hide_root=False,
                       indent_level=4)
        for branch in tree:
            populate_tree_view(self.tv, None, branch)
        #self.remove_widgets()
        self.treeview.add_widget(self.tv)
        Clock.schedule_once(self.update, 1)

    def remove_widgets(self):
        for child in [child for child in self.treeview.children]:
            self.treeview.remove_widget(child)

    def update(self, *args):
        self.h = len([child for child in self.tv.children]) * 24

class EditCityPopup(Popup):
    col_data = ListProperty(["?", "?", "?", "?", "?"])
    index = NumericProperty(0)
    popup = ObjectProperty(None)

    def __init__(self, obj, **kwargs):
        super(EditCityPopup, self).__init__(**kwargs)
        self.index = obj.index
        self.col_data[0] = obj.rv_data_city[self.index]["cityId"]
        self.col_data[1] = obj.rv_data_city[self.index]["stateId"]
        self.col_data[2] = obj.rv_data_city[self.index]["cityName"]
        self.col_data[3] = obj.rv_data_city[self.index]["shortName"]
        self.col_data[4] = obj.rv_data_city[self.index]["pinCode"]

    def package_changes(self, stateId, cityName, shortName, pinCode):
        self.col_data[1] = stateId
        self.col_data[2] = cityName
        self.col_data[3] = shortName
        self.col_data[4] = pinCode

    def display_states_treeview(self, instance):
        if len(instance.text) > 0:
            if self.popup is None:
                self.popup = TreeviewGroup()
            self.popup.open()

class SelectableButtonCity(RecycleDataViewBehavior, Button):
    ''' Add selection support to the Button '''
    index = None
    selected = BooleanProperty(False)
    selectable = BooleanProperty(True)
    rv_data_city = ObjectProperty(None)
    start_point = NumericProperty(0)

    def __init__(self, **kwargs):
        super(SelectableButtonCity, self).__init__(**kwargs)
        Clock.schedule_interval(self.update, .0005)

    def update(self, *args):
        self.text = self.rv_data_city[self.index][self.key]

    def refresh_view_attrs(self, rv, index, data):
        ''' Catch and handle the view changes '''
        self.index = index
        return super(SelectableButtonCity, self).refresh_view_attrs(rv, index, data)

    def on_touch_down(self, touch):
        ''' Add selection on touch down '''
        if super(SelectableButtonCity, self).on_touch_down(touch):
            return True
        if self.collide_point(*touch.pos) and self.selectable:
            return self.parent.select_with_touch(self.index, touch)

    def apply_selection(self, rv, index, is_selected):
        ''' Respond to the selection of items in the view. '''
        self.selected = is_selected
        self.rv_data_city = rv.data

    def on_press(self):
        popup = EditCityPopup(self)
        popup.open()

class RVCITY(BoxLayout):
    data_items_city = ListProperty([])
    col1 = ListProperty()
    col2 = ListProperty()
    col3 = ListProperty()
    col4 = ListProperty()
    col5 = ListProperty()

    def __init__(self, **kwargs):
        super(RVCITY, self).__init__(**kwargs)
        self.get_cities()

    def update(self):
        self.col1 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'cityId'} for x in self.data_items_city]
        self.col2 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'stateId'} for x in self.data_items_city]
        self.col3 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'cityName'} for x in self.data_items_city]
        self.col4 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'shortName'} for x in self.data_items_city]
        self.col5 = [{'cityId': str(x[0]), 'stateId': str(x[1]), 'cityName': str(x[2]), 'shortName': str(x[3]), 'pinCode': str(x[4]), 'key': 'pinCode'} for x in self.data_items_city]

    def get_cities(self):

        rows = [(1, 'Bihar', 'Patna', 'Patna', 801108), (2, 'Andaman and Nicobar Islands ', 'Port Blair', 'PB', 744101), (3, 'Assam', 'Guwahati', 'Guwahati', 781001), (4, 'Assam', 'Nagaon', 'Nagaon', 782120), (5, 'Chandigarh', 'Amritsar', 'Amritsar', 143502), (6, 'Andhra Pradesh', 'Visakhapatnam', 'VP', 531219), (7, 'Chattisgarh', 'Bilaspur', 'Bilaspur', 495001)]
        i = 0
        for row in rows:
            self.data_items_city.append([row[0], row[1], row[2], row[3], row[4], i])
            i += 1
        print(self.data_items_city)
        self.update()

class EditAreaPopup(Popup):
    col_data = ListProperty(["?", "?", "?"])
    index = NumericProperty(0)
    popup = ObjectProperty(None)

    def __init__(self, obj, **kwargs):
        super(EditAreaPopup, self).__init__(**kwargs)
        self.index = obj.index
        self.col_data[0] = obj.rv_data_area[self.index]["areaId"]
        self.col_data[1] = obj.rv_data_area[self.index]["cityId"]
        self.col_data[2] = obj.rv_data_area[self.index]["areaName"]

    def package_changes(self, stateId, cityName):
        self.col_data[1] = stateId
        self.col_data[2] = cityName

    def display_city_treeview(self, instance):
        if len(instance.text) > 0:
            if self.popup is None:
                self.popup = TreeviewGroup()
            #self.popup.filter(instance.text)
            self.popup.open()

class SelectableButtonArea(RecycleDataViewBehavior, Button):
    ''' Add selection support to the Button '''
    index = None
    selected = BooleanProperty(False)
    selectable = BooleanProperty(True)
    rv_data_area = ObjectProperty(None)
    start_point = NumericProperty(0)

    def __init__(self, **kwargs):
        super(SelectableButtonArea, self).__init__(**kwargs)
        Clock.schedule_interval(self.update, .0005)

    def update(self, *args):
        self.text = self.rv_data_area[self.index][self.key]

    def refresh_view_attrs(self, rv, index, data):
        ''' Catch and handle the view changes '''
        self.index = index
        return super(SelectableButtonArea, self).refresh_view_attrs(rv, index, data)

    def on_touch_down(self, touch):
        ''' Add selection on touch down '''
        if super(SelectableButtonArea, self).on_touch_down(touch):
            return True
        if self.collide_point(*touch.pos) and self.selectable:
            return self.parent.select_with_touch(self.index, touch)

    def apply_selection(self, rv, index, is_selected):
        ''' Respond to the selection of items in the view. '''
        self.selected = is_selected
        self.rv_data_area = rv.data
        #print("selection changed to {0}".format(rv.data[1]))

    def on_press(self):
        popup = EditAreaPopup(self)
        popup.open()

class RVAREA(BoxLayout):
    data_items_area = ListProperty([])
    col1 = ListProperty()
    col2 = ListProperty()
    col3 = ListProperty()

    def __init__(self, **kwargs):
        super(RVAREA, self).__init__(**kwargs)
        self.get_areas()

    def update(self):
        self.col1 = [{'areaId': str(x[0]), 'cityId': str(x[1]), 'areaName': str(x[2]),  'key': 'areaId'} for x in self.data_items_area]
        self.col2 = [{'areaId': str(x[0]), 'cityId': str(x[1]), 'areaName': str(x[2]),  'key': 'cityId'} for x in self.data_items_area]
        self.col3 = [{'areaId': str(x[0]), 'cityId': str(x[1]), 'areaName': str(x[2]),  'key': 'areaName'} for x in self.data_items_area]

    def get_areas(self):

        rows = [(1, 'Amritsar', 'area1')]
        i = 0
        for row in rows:
            self.data_items_area.append([row[0], row[1], row[2], i])
            i += 1
        print(self.data_items_area)
        self.update()

class CustDrop(DropDown):
    def __init__(self, **kwargs):
        super(CustDrop, self).__init__(**kwargs)
        self.select('')

class MainMenu(BoxLayout):
    states_cities_or_areas = ObjectProperty()
    rv = ObjectProperty(None)
    dropdown = ObjectProperty(None)
    #Define City Variable
    rvcity = ObjectProperty(None)
    #Area City Variable
    rvarea = ObjectProperty(None)

    def display_states(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rv = RV()
        self.states_cities_or_areas.add_widget(self.rv)

    def display_cities(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvcity = RVCITY()
        self.states_cities_or_areas.add_widget(self.rvcity)

    def display_areas(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvarea = RVAREA()
        self.states_cities_or_areas.add_widget(self.rvarea)

    def remove_widgets(self):
        self.states_cities_or_areas.clear_widgets()

class FactApp(App):
    title = "test"

    def build(self):
        self.root = Builder.load_file('test.kv')
        return MainMenu()

if __name__ == '__main__':
    FactApp().run()

test.kv

#:kivy 1.10.0
#:import CoreImage kivy.core.image.Image
#:import os os

<EditStatePopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 200
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "Id"
            Label:
                id: stateId
                text: root.col_data[0]
            Label:
                text: "State Name"
            TextInput:
                id: stateName
                text: root.col_data[1]
            Label:
                text: "State Code"
            TextInput:
                id: stateCode
                text: root.col_data[2]

            Button:
                size_hint: 1, 1
                text: "Ok"
                on_release:
                    root.package_changes(stateName.text, stateCode.text)
                    app.root.update_states(root)
                    root.dismiss()

            Button:
                size_hint: 1, 1
                text: "Cancel"
                on_release: root.dismiss()

<TreeViewLabel>:
    size_hint_y: None
    height: 24
    on_touch_down:
        app.root.stateName.text = self.text
        app.root.popup.dismiss()

<TreeviewGroup>:
    id: treeview
    treeview: treeview
    title: "Select State"
    size_hint: .3,.3
    size: 800, 800
    auto_dismiss: False

    BoxLayout
        orientation: "vertical"
        ScrollView:
            size_hint: 1, .9
            BoxLayout:
                size_hint_y: None
                id: treeview
                height: root.h
        Button:
            size_hint: 1, 0.1
            text: "Close"
            on_release: root.dismiss()

<SelectableButton>:
    canvas.before:
        Color:
            rgba: (0, 0.517, 0.705, 1) if self.selected else (0, 0.517, 0.705, 1)
        Rectangle:
            pos: self.pos
            size: self.size

<MyRV@RecycleView>:
    viewclass: 'SelectableButton'
    SelectableRecycleGridLayout:
        cols: 1
        default_size: None, dp(26)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        multiselect: True
        touch_multiselect: True

<RV>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 3

            Label:
                size_hint_x: .1
                text: "Id"
            Label:
                size_hint_x: .5
                text: "State Name"
            Label:
                size_hint_x: .4
                text: "State Code"

        BoxLayout:
            MyRV:
                size_hint_x: .1
                data: root.col1
            MyRV:
                size_hint_x: .5
                data: root.col2
            MyRV:
                size_hint_x: .4
                data: root.col3

<EditCityPopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 400
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "City Id"
            Label:
                id: cityId
                text: root.col_data[0]
            Label:
                text: "State Id"
            TextInput:
                id: stateId
                text: root.col_data[1]
                on_focus: root.display_states_treeview(self)
            Label:
                text: "city Name"
            TextInput:
                id: cityName
                text: root.col_data[2]
            Label:
                text: "Short Name"
            TextInput:
                id: shortName
                text: root.col_data[3]
            Label:
                text: "Pin Code"
            TextInput:
                id: pinCode
                text: root.col_data[4]

            Button:
                size_hint: 1, 1
                text: "Ok"
                on_release:
                    root.package_changes(stateId.text, cityName.text, shortName.text, pinCode.text)
                    app.root.update_cities(root)
                    root.dismiss()

            Button:
                size_hint: 1, 1
                text: "Cancel"
                on_release: root.dismiss()

<MyRvCity@RecycleView>:
    viewclass: 'SelectableButtonCity'
    SelectableRecycleGridLayout:
        cols: 1
        default_size: None, dp(26)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        multiselect: True
        touch_multiselect: True

<RVCITY>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y:None
            height: 25
            cols: 5

            Label:
                size_hint_x: .1
                text: "City Id"
            Label:
                size_hint_x: .2
                text: "State Name"
            Label:
                size_hint_x: .3
                text: "City Name"
            Label:
                size_hint_x: .2
                text: "Short Name"
            Label:
                size_hint_x: .2
                text: "Pin Code"

        BoxLayout:
            MyRvCity:
                size_hint_x: .1
                data: root.col1
            MyRvCity:
                size_hint_x: .2
                data: root.col2
            MyRvCity:
                size_hint_x: .3
                data: root.col3
            MyRvCity:
                size_hint_x: .2
                data: root.col4
            MyRvCity:
                size_hint_x: .2
                data: root.col5

<EditAreaPopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 400
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "City Id"
            Label:
                id: cityId
                text: root.col_data[0]
            Label:
                text: "State Id"
            TextInput:
                id: stateId
                text: root.col_data[1]
                on_focus: root.display_states_treeview(self)
            Label:
                text: "city Name"
            TextInput:
                id: cityName
                text: root.col_data[2]

            Button:
                size_hint: 1, 1
                text: "Ok"
                on_release:
                    root.package_changes(stateId.text, cityName.text, shortName.text, pinCode.text)
                    app.root.update_cities(root)
                    root.dismiss()

            Button:
                size_hint: 1, 1
                text: "Cancel"
                on_release: root.dismiss()

<MyRvArea@RecycleView>:
    viewclass: 'SelectableButtonArea'
    SelectableRecycleGridLayout:
        cols: 1
        default_size: None, dp(26)
        default_size_hint: 1, None
        size_hint_y: None
        height: self.minimum_height
        orientation: 'vertical'
        multiselect: True
        touch_multiselect: True

<RVAREA>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 3

            Label:
                size_hint_x: .1
                text: "Area Id"
            Label:
                size_hint_x: .5
                text: "City Name"
            Label:
                size_hint_x: .4
                text: "Area Name"

        BoxLayout:
            MyRvArea:
                size_hint_x: .1
                data: root.col1
            MyRvArea:
                size_hint_x: .5
                data: root.col2
            MyRvArea:
                size_hint_x: .4
                data: root.col3

<DropdownButton@Button>:
    border: (0, 16, 0, 16)
    text_size: self.size
    valign: "middle"
    padding_x: 5
    size_hint_y: None
    height: '30dp'
    background_color: 90 , 90, 90, 90
    color: 0, 0.517, 0.705, 1

<MenuButton@Button>:
    text_size: self.size
    valign: "middle"
    padding_x: 5
    size : (80,30)
    size_hint : (None, None)
    background_color: 90 , 90, 90, 90
    background_normal: ''
    color: 0, 0.517, 0.705, 1
    border: (0, 10, 0, 0)

<MainMenu>:
    states_cities_or_areas: states_cities_or_areas
    dropdown: dropdown

    BoxLayout:
        orientation: 'vertical'
        #spacing : 10

        BoxLayout:
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

            size_hint_y: 1

            MenuButton:
                id: btn
                text: 'Test'
                size : (60,30)
                on_release: dropdown.open(self)

            CustDrop:
                id: dropdown
                auto_width: False
                width: 150

                DropdownButton:
                    text: 'Test1'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_states()

                DropdownButton:
                    text: 'Test2'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_cities()
                DropdownButton:
                    text: 'Test3'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_areas()

        BoxLayout:
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

                Color:
                    rgb: (1,1,1)

            Label:
                size_hint_x: 45

        BoxLayout:
            id: states_cities_or_areas
            size_hint_y: 10

        Label:
            size_hint_y: 1

Can anyone help me?

When i click on test then sub menu will be open.When i click on state then it look like good.But i click on city then distance increase between 'Test' and Row.

when i click on 'city' then show rows of city.when i click on any row then it looks Select state(treeview) show behind of 'update state'

I want it up on update state when anyone type anything in 'state Id'

i am using treeview in select state.how to add scrollbar in select state.when state increase then scroll will be good option

After update code I have a more error.

1. When i select state from select state then it's not put that string in state Name.Its showing error

   File "/usr/share/kivy-examples/gst_fact/test.kv", line 50, in

app.root.stateName.text = self.text

AttributeError: 'MainMenu' object has no attribute 'stateName'

Body:
I want to when i click on anyone(state,city,area) then row show top position like Image_1.

It's because you have set the rules of your main menu in your kv to reserve the space for each box city, state and area. You can remove these rules and add only one box which I called states_cities_or_areas:

...

<MainMenu>:
    states_cities_or_areas: states_cities_or_areas
    dropdown: dropdown

    BoxLayout:
        orientation: 'vertical'
        #spacing : 10
        BoxLayout:
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

            size_hint_y: 5

            MenuButton:
                id: btn
                text: 'Test'
                size : (60,30)
                on_release: dropdown.open(self)

            CustDrop:
                id: dropdown
                auto_width: False
                width: 150

                DropdownButton:
                    text: 'State'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_states()

                DropdownButton:
                    text: 'City'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_cities()
                DropdownButton:
                    text: 'Area'
                    size_hint_y: None
                    height: '32dp'
                    on_release: root.display_areas()

        BoxLayout:
            size_hint_y: 2.5
            canvas.before:
                Rectangle:
                    pos: self.pos
                    size: self.size

                Color:
                    rgb: (1,1,1)

            Label:
                size_hint_x: 45

        BoxLayout:
            id: states_cities_or_areas
            size_hint_y: 89
        Label:
            size_hint_y: 1

...

then change some methods and attributes of the mainmenu in the .py:

...
class MainMenu(BoxLayout):
    states_cities_or_areas = ObjectProperty()
    rv = ObjectProperty(None)
    dropdown = ObjectProperty(None)
    #Define City Variable
    rvcity = ObjectProperty(None)
    #Area City Variable
    rvarea = ObjectProperty(None)

    def display_states(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rv = RV()
        self.states_cities_or_areas.add_widget(self.rv)

    def display_cities(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvcity = RVCITY()
        self.states_cities_or_areas.add_widget(self.rvcity)

    def display_areas(self):
        self.dropdown.dismiss()
        self.remove_widgets()
        self.rvarea = RVAREA()
        self.states_cities_or_areas.add_widget(self.rvarea)

    def remove_widgets(self):
        self.states_cities_or_areas.clear_widgets()

...

I have noticed that the tiles of colums of city was not displayed, you can display it with this in the kv:

...

<RVCITY>:
    BoxLayout:
        orientation: "vertical"

        GridLayout:
            size_hint: 1, None
            size_hint_y: None
            height: 25
            cols: 5
...

when i click on 'city' then show rows of city.when i click on any row then it looks Select state(treeview) show behind of 'update state' like image_4 I want it up on update state when anyone type anything in 'state Id' like image_5

It's because the StateId text input is already on_text before the the popup opens. I suggest you to replace on_text with on_focus:

...
<EditCityPopup>:
    title: "Update State"
    size_hint: None, None
    size: 500, 400
    auto_dismiss: False

    BoxLayout:
        orientation: "vertical"
        GridLayout:
            cols: 2
            backgroun_color: 0, 0.517, 0.705, 1
            spacing: 10, 10
            Label:
                text: "City Id"
            Label:
                id: cityId
                text: root.col_data[0]
            Label:
                text: "State Id"
            TextInput:
                id: stateId
                text: root.col_data[1]
                on_focus: root.display_states_treeview(self)
...

i am using treeview in select state.how to add scrollbar in select state.when state increase then scroll will be good option

You just have to put the treeview in a scrollview:

...
<TreeViewLabel>:
size_hint_y: None
    height: 24
    on_touch_down:
        app.root.stateName.text = self.text
        app.root.select_node(self)
        app.root.popup.dismiss()

<TreeviewGroup>:
    treeview: treeview
    title: "Select State"
    size_hint: .3,.3
    auto_dismiss: False
    BoxLayout
        orientation: "vertical"
        ScrollView:
            size_hint: 1, .9
            BoxLayout:
                size_hint_y: None
                id: treeview
                height: root.h
        Button:
            size_hint: 1, 0.1
            text: "Close"
            on_release: root.dismiss()

and in the .py:

...

class TreeviewGroup(Popup):
    treeview = ObjectProperty(None)
    tv = ObjectProperty(None)
    h = NumericProperty(0)
    #ti = ObjectProperty()

    def __init__(self, **kwargs):
        super(TreeviewGroup, self).__init__(**kwargs)
        self.tv = TreeView(root_options=dict(text=""),
                   hide_root=True,
                   indent_level=4)
        for branch in tree:
            populate_tree_view(self.tv, None, branch)
        #self.remove_widgets()
        self.treeview.add_widget(self.tv)
        Clock.schedule_once(self.update, 1)

    def remove_widgets(self):
        for child in [child for child in self.treeview.children]:
            self.treeview.remove_widget(child)

    def update(self, *args):
        self.h = len([child for child in self.tv.children]) * 24

Update

FOR THE 4TH POINT;

to pass the stateName to the other popup,keep the instance of the first popup when you create the 2nd:

...
class TreeviewGroup(Popup):
    treeview = ObjectProperty(None)
    tv = ObjectProperty(None)
    h = NumericProperty(0)
    #ti = ObjectProperty()
    popup = ObjectProperty()
...

class EditCityPopup(Popup):

...

def display_states_treeview(self, instance):
    if len(instance.text) > 0:
        if self.popup is None:
            self.popup = TreeviewGroup()
            self.popup.popup = self
        self.popup.open()

To reach the first popup in the kv make those changes:

in the .py:

...
class MyBoxLayout(BoxLayout):
    rooot = ObjectProperty()
...

In the kv:

...
<TreeViewLabel>:
    size_hint_y: None
    height: 24
    on_touch_down:
        root.parent.parent.rooot.popup.col_data[1] = self.text
        #app.root.select_node(self)
        root.parent.parent.rooot.popup.popup.dismiss()

<TreeviewGroup>:
    id: treeview
    treeview: treeview
    title: "Select State"
    size_hint: .3,.3
    size: 800, 800
    auto_dismiss: False

    BoxLayout
        orientation: "vertical"
        ScrollView:
            size_hint: 1, .9
            MyBoxLayout:
                size_hint_y: None
                id: treeview
                height: root.h
                rooot: root
...


来源: stackexchange

问:
How to guarantee that camel logs in ASCII text not in decimals?
In one of my camel route, i use camel's log eip as:

```<code>from("direct:someSourceWithBodyOfTypeMap")
    .marshal().json(JsonLibrary.Jackson)
    .to("direct:logHandler");

// on a separate route builder
from("direct:logForFilebeat")
    .convertBodyTo(String.class, "UTF-8")
    .log(LoggingLevel.INFO, "jsonLogger","${body}");
</code>```

This route's purpose is to marshal a source  of type Map to json and log the body which is later on picked up by a log aggregator. Im using logback for the logging. a portion of the logback-spring.xml looks like this:

```<code>   <appender name="JSON_TX" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>${BASE_LOG_PATH}/json.log</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
         <fileNamePattern>${BASE_LOG_PATH}/json.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
         <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>100MB</maxFileSize>
         </timeBasedFileNamingAndTriggeringPolicy>
      </rollingPolicy>
      <encoder>
         <charset>UTF-8</charset>
         <pattern>%msg%n</pattern>
      </encoder>
   </appender>
   <appender name="ASYNC_JSON_TX" class="ch.qos.logback.classic.AsyncAppender">
      <appender-ref ref="JSON_TX" />
   </appender>
   <logger name="jsonLogger" level="INFO">
      <appender-ref ref="ASYNC_FILEBEAT_TX" />
   </logger>
</code>```

In a normal flow, it gets properly logged as a json string like:

```<code>{"id":2456,"name":"foo","gender":"MALE"}
</code>```

but there are instances that it gets logged as:

```<code>123 34 105 100 34 58 50 52 53 54 44 34 110 97 109 101 34 58 34 102 111 111 34 44 34 103 101 110 100 101 114 34 58 34 77 65 76 69 34 125
</code>```

This decimals logs are generated when there are messages being processed by the route and the spring-boot up is triggered for shutdown. (I was able to replicate this locally by placing a breakpoint into processor before the source route, then shutting down spring-boot app while messages are routed to 'someSourceWithBodyOfTypeMap'.)

How do i enforce that the what gets appended to the log file should be in ASCII Text format not in decimal? And what triggers the logs to be in decimal in the first place?

答: Its not decimals its because your message body is marshalled as a stream of bytes. You can convert the message body to a String first by adding .convertBodyTo(String) after the marshal, or specify that the logger should convert to string via ${bodyAs(String)}.

ContentLicense: CC BY-SA 3.0

Body:
In one of my camel route, i use camel's log eip as:

from("direct:someSourceWithBodyOfTypeMap")
    .marshal().json(JsonLibrary.Jackson)
    .to("direct:logHandler");

// on a separate route builder
from("direct:logForFilebeat")
    .convertBodyTo(String.class, "UTF-8")
    .log(LoggingLevel.INFO, "jsonLogger","${body}");

This route's purpose is to marshal a source  of type Map to json and log the body which is later on picked up by a log aggregator. Im using logback for the logging. a portion of the logback-spring.xml looks like this:

   <appender name="JSON_TX" class="ch.qos.logback.core.rolling.RollingFileAppender">
      <file>${BASE_LOG_PATH}/json.log</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
         <fileNamePattern>${BASE_LOG_PATH}/json.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
         <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>100MB</maxFileSize>
         </timeBasedFileNamingAndTriggeringPolicy>
      </rollingPolicy>
      <encoder>
         <charset>UTF-8</charset>
         <pattern>%msg%n</pattern>
      </encoder>
   </appender>
   <appender name="ASYNC_JSON_TX" class="ch.qos.logback.classic.AsyncAppender">
      <appender-ref ref="JSON_TX" />
   </appender>
   <logger name="jsonLogger" level="INFO">
      <appender-ref ref="ASYNC_FILEBEAT_TX" />
   </logger>

In a normal flow, it gets properly logged as a json string like:

{"id":2456,"name":"foo","gender":"MALE"}

but there are instances that it gets logged as:

123 34 105 100 34 58 50 52 53 54 44 34 110 97 109 101 34 58 34 102 111 111 34 44 34 103 101 110 100 101 114 34 58 34 77 65 76 69 34 125

This decimals logs are generated when there are messages being processed by the route and the spring-boot up is triggered for shutdown. (I was able to replicate this locally by placing a breakpoint into processor before the source route, then shutting down spring-boot app while messages are routed to 'someSourceWithBodyOfTypeMap'.)

How do i enforce that the what gets appended to the log file should be in ASCII Text format not in decimal? And what triggers the logs to be in decimal in the first place?


问:
Create new column to identify the first value >0 across different columns
I have the following data frame

```<code>df <- data.frame(col1 = c(0,0,1,1),col2 = c(1,0,0,3),col2 = c(1,0,0,3))
</code>```

How can I identify the the first value of each value which is greater than 0.
The expected output is like this

```<code>df <- data.frame(col1 = c(0,0,1,1),col2 = c(1,0,0,3),col3 = c(1,0,0,3),col4 = c(1,0,1,1))
</code>```

And I have tried the followings

```<code>for (i in 1:3){
  df$col4 <- apply(df[,c(0:i)],1,sum)
  if (df$col4>0)
    break
  }
</code>```

答:
We can use max.col() for this.

```<code>df[cbind(1:nrow(df), max.col(df > 0, "first"))]
# [1] 1 0 1 1
</code>```

Body:
I have the following data frame

df <- data.frame(col1 = c(0,0,1,1),col2 = c(1,0,0,3),col2 = c(1,0,0,3))

How can I identify the the first value of each value which is greater than 0.
The expected output is like this

df <- data.frame(col1 = c(0,0,1,1),col2 = c(1,0,0,3),col3 = c(1,0,0,3),col4 = c(1,0,1,1))

And I have tried the followings

for (i in 1:3){
  df$col4 <- apply(df[,c(0:i)],1,sum)
  if (df$col4>0)
    break
  }

Body:
We can use max.col() for this.

df[cbind(1:nrow(df), max.col(df > 0, "first"))]
# [1] 1 0 1 1


问:
Does Treeview use command bindings for expand/collapse?
The WPF Treeview responds to + and - keystrokes to expand and collapse nodes in the tree.  Great!

Is there an existing command I can bind my toolbar buttons or menu items to to perform the same actions in the treeview?  I don't see anything related to expand/collapse in the stock command constants.

答:
The TreeView handles the expansion of a TreeViewItem with the mouse by binding ToggleButton.IsChecked to TreeViewItem.IsExpanded in the ControlTemplate and handles expansion with the keyboard in an override TreeViewItem.OnKeyDown.  So, no, it doesn't use commands in its implementation.

But you can add your own commands without much effort.  In this example, I've added a behavior to a TreeView so that it responds to the standard Open and Close application commands:

```<code><DockPanel>
    <Menu DockPanel.Dock="Top">
        <MenuItem Header="Open" CommandTarget="{Binding ElementName=treeView1}" Command="Open"/>
        <MenuItem Header="Close" CommandTarget="{Binding ElementName=treeView1}" Command="Close"/>
    </Menu>
    <TreeView>
        <i:Interaction.Behaviors>
            <local:TreeViewCommandsBehavior/>
        </i:Interaction.Behaviors>
        <TreeViewItem Header="Root">
            <TreeViewItem Header="Item1">
                <TreeViewItem Header="Subitem1"/>
                <TreeViewItem Header="Subitem2"/>
            </TreeViewItem>
            <TreeViewItem Header="Item2">
                <TreeViewItem Header="Subitem3"/>
                <TreeViewItem Header="Subitem4"/>
            </TreeViewItem>
        </TreeViewItem>
    </TreeView>
</DockPanel>
</code>```

and here is the behavior that makes that work:

```<code>public class TreeViewCommandsBehavior : Behavior<TreeView>
{
    private TreeViewItem selectedTreeViewItem;

    protected override void OnAttached()
    {
        AssociatedObject.AddHandler(TreeViewItem.SelectedEvent, new RoutedEventHandler(TreeViewItem_Selected));
        AssociatedObject.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, CommandExecuted));
        AssociatedObject.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CommandExecuted));
    }

    private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
    {
        selectedTreeViewItem = e.OriginalSource as TreeViewItem;
    }

    private void CommandExecuted(object sender, ExecutedRoutedEventArgs e)
    {
        bool expand = e.Command == ApplicationCommands.Open;
        if (selectedTreeViewItem != null)
            selectedTreeViewItem.IsExpanded = expand;
    }
}
</code>```

If you are not familiar with behaviors, first add this namespace:

```<code>xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
</code>```

and add the corresponding reference to your project.

Body:
The TreeView handles the expansion of a TreeViewItem with the mouse by binding ToggleButton.IsChecked to TreeViewItem.IsExpanded in the ControlTemplate and handles expansion with the keyboard in an override TreeViewItem.OnKeyDown.  So, no, it doesn't use commands in its implementation.

But you can add your own commands without much effort.  In this example, I've added a behavior to a TreeView so that it responds to the standard Open and Close application commands:

<DockPanel>
    <Menu DockPanel.Dock="Top">
        <MenuItem Header="Open" CommandTarget="{Binding ElementName=treeView1}" Command="Open"/>
        <MenuItem Header="Close" CommandTarget="{Binding ElementName=treeView1}" Command="Close"/>
    </Menu>
    <TreeView>
        <i:Interaction.Behaviors>
            <local:TreeViewCommandsBehavior/>
        </i:Interaction.Behaviors>
        <TreeViewItem Header="Root">
            <TreeViewItem Header="Item1">
                <TreeViewItem Header="Subitem1"/>
                <TreeViewItem Header="Subitem2"/>
            </TreeViewItem>
            <TreeViewItem Header="Item2">
                <TreeViewItem Header="Subitem3"/>
                <TreeViewItem Header="Subitem4"/>
            </TreeViewItem>
        </TreeViewItem>
    </TreeView>
</DockPanel>

and here is the behavior that makes that work:

public class TreeViewCommandsBehavior : Behavior<TreeView>
{
    private TreeViewItem selectedTreeViewItem;

    protected override void OnAttached()
    {
        AssociatedObject.AddHandler(TreeViewItem.SelectedEvent, new RoutedEventHandler(TreeViewItem_Selected));
        AssociatedObject.CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, CommandExecuted));
        AssociatedObject.CommandBindings.Add(new CommandBinding(ApplicationCommands.Close, CommandExecuted));
    }

    private void TreeViewItem_Selected(object sender, RoutedEventArgs e)
    {
        selectedTreeViewItem = e.OriginalSource as TreeViewItem;
    }

    private void CommandExecuted(object sender, ExecutedRoutedEventArgs e)
    {
        bool expand = e.Command == ApplicationCommands.Open;
        if (selectedTreeViewItem != null)
            selectedTreeViewItem.IsExpanded = expand;
    }
}

If you are not familiar with behaviors, first add this namespace:

xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"

and add the corresponding reference to your project.

ContentLicense: CC BY-SA 2.5


问:
Code snippet "cw" is gone
Suddenly I found, that code snippet I used in past not work anymore in my VS2017 C#.

I write cw and press tab two times. I was expecting Console.WriteLine(); to be written, but got chat after first tab pressed.

How to brink back cw code snippet?

答:
Put the following code in a file named cw.snippet and place it in:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC#\Snippets\1033\Visual C#\

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">

            <Title>cw</Title>
            <Shortcut>cw</Shortcut>
            <Description>Code snippet for Console.WriteLine</Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>

        <Snippet>
            <Declarations>
                <Literal Editable="false">
                    <ID>SystemConsole</ID>
                    <Function>SimpleTypeName(global::System.Console)</Function>
                </Literal>
            </Declarations>
            <![CDATA[$SystemConsole$.WriteLine($end$);]]>

        </Snippet>
    </CodeSnippet>
</CodeSnippets>
```

Title: Code snippet "cw" is gone

Body:
Put the following code in a file named cw.snippet and place it in:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC#\Snippets\1033\Visual C#\

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>cw</Title>
            <Shortcut>cw</Shortcut>
            <Description>Code snippet for Console.WriteLine</Description>
            <Author>Microsoft Corporation</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal Editable="false">
                    <ID>SystemConsole</ID>
                    <Function>SimpleTypeName(global::System.Console)</Function>
                </Literal>
            </Declarations>
            <Code Language="csharp"><![CDATA[$SystemConsole$.WriteLine($end$);]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

ContentLicense: CC BY-SA 4.0


问:
Rebase detached HEAD to master
Hi can you help me solve that problem? I am on a branch **(HEAD detached from refs/heads/master) where I have some new commits and I need add these changes into my master branch. an you tell me how to do that? Here is my output from terminal after entering git branch and git status
**

```<code>denis@N56VJ:~/Workspace/ita-javaee-04$ git status
HEAD detached from refs/heads/master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        src/main/webapp/package-lock.json

nothing added to commit but untracked files present (use "git add" to track)
denis@N56VJ:~/Workspace/ita-javaee-04$ git branch
* (HEAD detached from refs/heads/master)
  master
denis@N56VJ:~/Workspace/ita-javaee-04$
</code>```

答:
You could delete your old master and create a new one at your current HEAD.

```<code>git branch -D master
git checkout -b master
git branch --set-upstream-to=origin/master
</code>```

If you're worried aboud making a mistake, then be sure to git show HEAD, git show master, and save the sha1 hashes as a backup.  Alternatively, you can rely on git reflog.

Title: Rebase detached HEAD to master

Body:
Hi can you help me solve that problem? I am on a branch **(HEAD detached from refs/heads/master) where I have some new commits and I need add these changes into my master branch. an you tell me how to do that? Here is my output from terminal after entering git branch and git status
**

denis@N56VJ:~/Workspace/ita-javaee-04$ git status
HEAD detached from refs/heads/master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        src/main/webapp/package-lock.json

nothing added to commit but untracked files present (use "git add" to track)
denis@N56VJ:~/Workspace/ita-javaee-04$ git branch
* (HEAD detached from refs/heads/master)
  master
denis@N56VJ:~/Workspace/ita-javaee-04$

Body:
You could delete your old master and create a new one at your current HEAD.

git branch -D master
git checkout -b master
git branch --set-upstream-to=origin/master

If you're worried aboud making a mistake, then be sure to git show HEAD, git show master, and save the sha1 hashes as a backup.  Alternatively, you can rely on git reflog.


问:
append column in dataframe to dictionary python
I want to set two columns from my dataframe (EisDat_cvs) as dictionary key and value in python, and everything works fine using this code:

```<code>dict_EisukeID_HMDB = EisDat_cvs.set_index('Unnamed: 28')['Unnamed: 26'].to_dict()
</code>```

However now I want to append two columns as values and one as key in the dictionary, and I tried to modify the previous one as:

```<code>dict_EisukeID_HMDB = EisDat_cvs.set_index('Unnamed: 28')['Unnamed: 26', 'Unnamed: 1'].to_dict()
</code>```

But python throws me a key error...

EDIT

I have a dataframe EisDat_cvs, of which I am considering 3 columns (Unnamed: 28, Unnamed: 26, Unnamed: 1). And I want to get a dictionary that takes the values in column 28 as my keys, and values in column 26 and 1 as values in the dictionary. Something like this:

```<code>Unnamed: 28, Unnamed: 26, Unnamed: 1
bla.          1           90
cra           2           12
ta            3           12
</code>```

and my output should look like

```<code>dict_EisukeID_HMDB = { 'bla': '1', '90'
                       'cra': '2', '12'
                       'ta':  '3', '12'}
</code>```

答:
You can try this:

```<code>dict(zip(
    EisDat_cvs['Unnamed: 28'],
    zip(EisDat_cvs['Unnamed: 26'], EisDat_cvs['Unnamed: 1'])
))
</code>```

The issue you had was not with to_dict() but instead by passing the columns as a tuple, you are trying to access the dataframe through a hierarchal column structure, which if your dataframe does not have, will throw a KeyError.

Hierarchal columns example:

```<code>df = pd.DataFrame({
    ("A", "A0"): [10, 30, 50, 70],
    ("A", "A1"): [11, 31, 51, 71],
    ("B", "B0"): [20, 40, 60, 80],
    ("B", "B1"): [21, 41, 61, 81]
})

print(df["A", "A0"])
</code>```

Output:

0    10
1    30
2    50
3    70
Name: (A, A0), dtype: int64
```

Body:
I want to set two columns from my dataframe (EisDat_cvs) as dictionary key and value in python, and everything works fine using this code:

dict_EisukeID_HMDB = EisDat_cvs.set_index('Unnamed: 28')['Unnamed: 26'].to_dict()

However now I want to append two columns as values and one as key in the dictionary, and I tried to modify the previous one as:

dict_EisukeID_HMDB = EisDat_cvs.set_index('Unnamed: 28')['Unnamed: 26', 'Unnamed: 1'].to_dict()

But python throws me a key error...

EDIT

I have a dataframe EisDat_cvs, of which I am considering 3 columns (Unnamed: 28, Unnamed: 26, Unnamed: 1). And I want to get a dictionary that takes the values in column 28 as my keys, and values in column 26 and 1 as values in the dictionary. Something like this:

Unnamed: 28, Unnamed: 26, Unnamed: 1
bla.          1           90
cra           2           12
ta            3           12

and my output should look like

dict_EisukeID_HMDB = { 'bla': '1', '90'
                       'cra': '2', '12'
                       'ta':  '3', '12'}

Body:
You can try this:

dict(zip(
    EisDat_cvs['Unnamed: 28'],
    zip(EisDat_cvs['Unnamed: 26'], EisDat_cvs['Unnamed: 1'])
))

The issue you had was not with to_dict() but instead by passing the columns as a tuple, you are trying to access the dataframe through a hierarchal column structure, which if your dataframe does not have, will throw a KeyError.

Hierarchal columns example:

df = pd.DataFrame({
    ("A", "A0"): [10, 30, 50, 70],
    ("A", "A1"): [11, 31, 51, 71],
    ("B", "B0"): [20, 40, 60, 80],
    ("B", "B1"): [21, 41, 61, 81]
})

print(df["A", "A0"])

Output:

0    10
1    30
2    50
3    70
Name: (A, A0), dtype: int64


问:
Perforce pending changelist diff script
Does someone have such a script to share?

takes a pending changelist number as input

outputs a unified diff (including files open for add)

I know from experience many people who work with perforce all day have these kicking around. I could really use help with the whole issue of "file(s) not in client view" when diffing newly added files via "p4 diff".

答:
This works for me:

```<code>p4 diff2 //depot/a/b/c/... //depot/a/b/c/...@=$CHANGELIST | grep -v '<none>'
</code>```

The more specific the path, the faster the execution.
You may also diff2 the changelist against a different branch.

Title: Perforce pending changelist diff script

Body:
This works for me:

p4 diff2 //depot/a/b/c/... //depot/a/b/c/...@=$CHANGELIST | grep -v '<none>'

The more specific the path, the faster the execution.
You may also diff2 the changelist against a different branch.


问:
UIAlertController is Crashed (iPad)
I am using Xcode 6 to develop an iOS Application.

When I used UIAlertController, it can be worked well on iPhone 6 simulator, but crashes on iPad simulator.

My problem while clicking "share", then it could be crashed.
How could I solve it?

Here is my Code:

```<code>override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject] {

    var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share", handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in

        let shareMenu = UIAlertController(title: nil, message: "Share using", preferredStyle: .ActionSheet)
        let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil)
        let facebookAction = UIAlertAction(title: "Facebook", style: UIAlertActionStyle.Default, handler: nil)
        let emailAction = UIAlertAction(title: "Email", style: UIAlertActionStyle.Default, handler: nil)
        let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)

        shareMenu.addAction(twitterAction)
        shareMenu.addAction(facebookAction)
        shareMenu.addAction(emailAction)
        shareMenu.addAction(cancelAction)

        self.presentViewController(shareMenu, animated: true, completion: nil)
        }
    )
</code>```

Xcode showed this message:

```<code>******Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0xaf71c80>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.  If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0023c746 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x01c7aa97 objc_exception_throw + 44
    2   UIKit                               0x012c4062 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3086
    3   UIKit                               0x00bda174 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1549
    4   UIKit                               0x00bd8247 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 198
    5   UIKit                               0x00c0d31b __40+[UIViewController _scheduleTransition:]_block_invoke + 18
    6   UIKit                               0x00ac6862 ___afterCACommitHandler_block_invoke + 15
    7   UIKit                               0x00ac680d _applyBlockToCFArrayCopiedToStack + 415
    8   UIKit                               0x00ac6622 _afterCACommitHandler + 549
    9   CoreFoundation                      0x0015d86e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    10  CoreFoundation                      0x0015d7b0 __CFRunLoopDoObservers + 400
    11  CoreFoundation                      0x001531ea __CFRunLoopRun + 1226
    12  CoreFoundation                      0x00152a5b CFRunLoopRunSpecific + 443
    13  CoreFoundation                      0x0015288b CFRunLoopRunInMode + 123
    14  GraphicsServices                    0x047b82c9 GSEventRunModal + 192
    15  GraphicsServices                    0x047b8106 GSEventRun + 104
    16  UIKit                               0x00a9c106 UIApplicationMain + 1526
    17  Mars I                              0x0001c724 main + 180
    18  libdyld.dylib                       0x02392ac9 start + 1
    19  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException******
</code>```

答:
Swift 4</p>

```<code>popoverPresentationController.permittedArrowDirections = .init(rawValue: 0)
popoverPresentationController.sourceView = self.view
popoverPresentationController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)
</code>```

Title: UIAlertController is Crashed (iPad)

Body:
I am using Xcode 6 to develop an iOS Application.

When I used UIAlertController, it can be worked well on iPhone 6 simulator, but crashes on iPad simulator.

My problem while clicking "share", then it could be crashed.
How could I solve it?

Here is my Code:

override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject] {

    var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share", handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in

        let shareMenu = UIAlertController(title: nil, message: "Share using", preferredStyle: .ActionSheet)
        let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil)
        let facebookAction = UIAlertAction(title: "Facebook", style: UIAlertActionStyle.Default, handler: nil)
        let emailAction = UIAlertAction(title: "Email", style: UIAlertActionStyle.Default, handler: nil)
        let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)

        shareMenu.addAction(twitterAction)
        shareMenu.addAction(facebookAction)
        shareMenu.addAction(emailAction)
        shareMenu.addAction(cancelAction)

        self.presentViewController(shareMenu, animated: true, completion: nil)
        }
    )

Xcode showed this message:

******Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0xaf71c80>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.  If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0023c746 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x01c7aa97 objc_exception_throw + 44
    2   UIKit                               0x012c4062 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3086
    3   UIKit                               0x00bda174 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 1549
    4   UIKit                               0x00bd8247 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 198
    5   UIKit                               0x00c0d31b __40+[UIViewController _scheduleTransition:]_block_invoke + 18
    6   UIKit                               0x00ac6862 ___afterCACommitHandler_block_invoke + 15
    7   UIKit                               0x00ac680d _applyBlockToCFArrayCopiedToStack + 415
    8   UIKit                               0x00ac6622 _afterCACommitHandler + 549
    9   CoreFoundation                      0x0015d86e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    10  CoreFoundation                      0x0015d7b0 __CFRunLoopDoObservers + 400
    11  CoreFoundation                      0x001531ea __CFRunLoopRun + 1226
    12  CoreFoundation                      0x00152a5b CFRunLoopRunSpecific + 443
    13  CoreFoundation                      0x0015288b CFRunLoopRunInMode + 123
    14  GraphicsServices                    0x047b82c9 GSEventRunModal + 192
    15  GraphicsServices                    0x047b8106 GSEventRun + 104
    16  UIKit                               0x00a9c106 UIApplicationMain + 1526
    17  Mars I                              0x0001c724 main + 180
    18  libdyld.dylib                       0x02392ac9 start + 1
    19  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException******

Body:
Swift 4

popoverPresentationController.permittedArrowDirections = .init(rawValue: 0)
popoverPresentationController.sourceView = self.view
popoverPresentationController.sourceRect = CGRect(x: self.view.bounds.midX, y: self.view.bounds.midY, width: 0, height: 0)


问:
grid-column-gap adds gap at the end of the last div in the row
I've been experimenting with grids in css and come across the following.

I have created a container containing several divs

My .container creates a grid of 5 items having a width of 20%.

I added the grid-column-gap and noticed that it created a overflow in the container. I found that the grid-column-gap adds it's value to the grid-template-columns value. So I changed the value it 19%.

Now the items fit the grid. However my understanding is that grid-column-gap is added between the divs. What I'm having right now is that the last item also contains a gap at the right side.

I want to have the gaps between the divs and not at the end.
Please, see the Fiddle

Can anyone explain what I'm doing wrong?

答:
Percentage units on grid are calculated as any other. If your unit is percentage it will add extra space to whole calculated area.

If however you add fr unit it will work similarly like flexbox and it will not add extra space.


问:
Display xml content in iframe
I want to display XML content in iFrame. I tried with html code below but it didn't work. It just show a blank page.

<!DOCTYPE html>

Your browser does not support iframes.

```

答: Tried your code with a sample xml of mine and worked fine. Are you sure you are giving the right path to xml file? What you are including in your code means your xml is exactly in the same folder as your html file</p>

Title: Display xml content in iframe


问:
Rewrite link category wordpress
How to make rewrite link category in wordpress.

http://example.com/orenda-avto?car=econom replace on http://example.com/orenda-avto/econom

```<code>add_action( 'init', 'add_mypage_rule' );
function add_mypage_rule(){
   add_rewrite_tag("%car%", '(\d+)');
   add_rewrite_rule('^orenda-avto/([^/]*)/?','index.php?cat=22&car=$matches[1]','top');
}
</code>```

And how change title and description on site after get request?

答:
You can rewrite link with Permalinks

Or you can do it with .htaccess code or yoast plugin

Title: Rewrite link category wordpress

Body:
How to make rewrite link category in wordpress.

http://example.com/orenda-avto?car=econom replace on http://example.com/orenda-avto/econom

add_action( 'init', 'add_mypage_rule' );
function add_mypage_rule(){
   add_rewrite_tag("%car%", '(\d+)');
   add_rewrite_rule('^orenda-avto/([^/]*)/?','index.php?cat=22&car=$matches[1]','top');
}

And how change title and description on site after get request?


问:
How to stretch the table to fill all available space
This question might be simple, but I cannot find an answer.

I have the following html:

```<code><div>
  some text
  <div>
    <table>
        <tr><td>
            Test
        </tr>
    </table>
  </div>
</div>
</code>```

and css:

```<code>body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

table {
    height: 100%;
    margin: 0 auto;
    background: red;
}
</code>```

How can I stretch the table vertically without change of the height property of div? I want the table to have height: 100% but it does not work because the outer containers do not have a fixed height (as I understand).

http://jsfiddle.net/8qedxug9/

答:
Give height: 100% to div element. In case you don't want scrolling, add overflow:hidden;.

body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

div{
  height: 100%;
  overflow:hidden;
}

table {
    height: 100%;
    width: 100%;
    margin: 0 auto;
    background: red;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
  some text
  <div>
    <table>
        <tr>
          <td>
            Test
          </td>
        </tr>
    </table>
  </div>
</div></code>```

Body:
This question might be simple, but I cannot find an answer.

I have the following html:

  some text

            Test

and css:

body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

table {
    height: 100%;
    margin: 0 auto;
    background: red;
}

How can I stretch the table vertically without change of the height property of div? I want the table to have height: 100% but it does not work because the outer containers do not have a fixed height (as I understand).

http://jsfiddle.net/8qedxug9/

Body:
Give height: 100% to div element. In case you don't want scrolling, add overflow:hidden;.

body,html {
    height: 100%;
    width: 100%;
    margin: 0;
}

div{
  height: 100%;
  overflow:hidden;
}

table {
    height: 100%;
    width: 100%;
    margin: 0 auto;
    background: red;
}

<div>
  some text
  <div>
    <table>
        <tr>
          <td>
            Test
          </td>
        </tr>
    </table>
  </div>
</div>