コード例 #1
0
    def constroi_tela(self):
        #print("Dicionario", self.dicionario)
        if self.dados == []:
            grid = GridLayout(cols=1)
            grid.add_widget(
                Label(text="Sem dados para mostrar no relatorio",
                      font_size=self.fonte_padrao))
            self.add_widget(grid)
            return

        spacing = "20sp"
        padding = [f"{i}sp" for i in [10, 0, 10, 50]]

        grid = GridLayout(cols=1,
                          size_hint_y=None,
                          spacing=spacing,
                          padding=padding)
        grid.bind(minimum_height=grid.setter("height"))

        for lista in self.dados:
            linha = self.constroi_linha(lista)
            grid.add_widget(linha)

        scroll = ScrollView(size_hint_y=.75)
        scroll.height = self.height * .85
        scroll.add_widget(grid)

        self.add_widget(scroll)
コード例 #2
0
    def insere_scroll_view(self, lista):
        """

        :type lista: list, tuple
        """
        x, y = self.width / 300, self.height / 650
        padding = (10 * x, 10 * y, 10 * x, 10 * y)
        padding = [f"{i}sp" for i in [50, 20, 50, 50]]
        spacing = "20sp"
        grid = GridLayout(cols=2,
                          padding=padding,
                          spacing=spacing,
                          size_hint_y=None)
        grid.bind(minimum_height=grid.setter("height"))

        for i, nome in enumerate(lista):
            texto = str.split(nome, "_")
            label = Label(text=" ".join(texto),
                          size_hint_y=None,
                          height=self.height * .05,
                          font_size=self.fonte_padrao)
            label.text_size = self.width * .45, label.height * .9
            label.valign = label.halign = "center"

            if nome == "CONDUTORES_SIMETRICOS":
                check = CheckBox(active=0)
                check.size_hint = (2, 2)
                grid.add_widget(label)
                grid.add_widget(check)
                self.ids[f"{self.nome_tela}_{self.keys[i]}"] = check
                continue

            inp = TextInput(size_hint_y=None,
                            height=self.height * .06,
                            border=[4] * 4,
                            font_size=self.fonte_padrao)
            filtro = "float"
            if nome == "NOME":
                filtro = None
            elif nome == "NUMERO_CONDUTORES":
                filtro = "int"

            #inp.input_filter = filtro
            inp.write_tab = False

            grid.add_widget(label)
            grid.add_widget(inp)

            self.ids[f"{self.nome_tela}_{self.keys[i]}"] = inp

        scroll = ScrollView(size_hint_y=.65)
        scroll.width = self.width * .9
        scroll.height = self.height * .85
        scroll.add_widget(grid)
        self.add_widget(scroll)
コード例 #3
0
ファイル: kivy_main.py プロジェクト: chinafishz/cmccrobot
    def search_contact_setp2(self, _result_friend, _result_room):
        _main = BoxLayout()
        _popup = Popup(title='搜索结果', title_font=cn_font_1)
        # 显示好友搜索结果
        _scroll_friends = ScrollView(size_hint=[1, 1])
        _box_friends = StackLayout(spacing=[5, 5], size_hint=[1, None])
        for _result_name, _result_value in _result_friend.items():
            _btn = Button(text=_result_name,
                          font_name=cn_font_1,
                          size_hint=[0.25, None])
            _btn._id = _result_value['username']
            _btn.bind(on_release=partial(self.search_result_choose, _popup))
            _box_friends.add_widget(_btn)
        _scroll_friends.add_widget(_box_friends)
        _box_friends.height = self.height / 9 * (int(len(_result_friend) / 4) +
                                                 1)
        _scroll_friends.height = self.height * 0.8

        # 显示群组搜索结果
        _scroll_rooms = ScrollView(size_hint=[1, 1])
        _box_rooms = StackLayout(spacing=[5, 5], size_hint=[1, None])
        for _result_name, _result_value in _result_room.items():
            _btn = Button(text=_result_name,
                          font_name=cn_font_1,
                          size_hint=[0.25, None])
            _btn._id = _result_value['username']
            _btn.bind(on_release=partial(self.search_result_choose, _popup))
            _box_rooms.add_widget(_btn)
        _scroll_rooms.add_widget(_box_rooms)
        _box_rooms.height = self.height / 9 * (int(len(_result_room) / 4) + 1)
        _scroll_rooms.height = self.height * 0.8

        _main.add_widget(_scroll_friends)
        _main.add_widget(_scroll_rooms)
        _popup.content = _main
        _popup.open()
コード例 #4
0
    def insere_scroll_view(self):
        dic_lido = self.dados.ler_do_banco_dados()
        # print(dic_lido)
        if dic_lido == {}:
            label = Label(text="A base da dados está vazia",
                          font_size=self.fonte_padrao * 1.2)
            self.add_widget(label)
            return
        spacing = "20sp"
        root = GridLayout(cols=1, size_hint_y=None, spacing=spacing)
        root.bind(minimum_height=root.setter("height"))

        for key, tabelas in dic_lido.items():
            constantes, _ = tabelas
            id, data, tipo, nome = constantes[:4]
            linha = self.constroi_linha_historico(id, data, nome, tipo)

            root.add_widget(linha)

        scroll = ScrollView(size_hint_y=None)
        scroll.height = self.height * .85
        scroll.add_widget(root)

        self.add_widget(scroll)
コード例 #5
0
    def constroi_mensagem(self):
        grid = GridLayout(cols=1, size_hint_y=None)
        grid.bind(minimum_height=grid.setter("height"))

        for log in self.logs:
            #print("criando: ", log)
            log = "[color=008080]" + log + "[/color]"
            label = Label(text=log)
            label.size_hint_y = None
            label.height = self.height * .1
            label.markup = True
            label.font_size = self.fonte_padrao
            label.text_size = self.width * .9, self.height * 1
            label.halign = label.valign = "center"

            grid.add_widget(label)

        scroll = ScrollView(size_hint_y=None)
        scroll.height = self.height * .6
        scroll.width = self.width
        scroll.add_widget(grid)
        box = GridLayout(cols=1)
        box.add_widget(scroll)
        return box
コード例 #6
0
ファイル: tabbedpanel.py プロジェクト: DanAlbert/kivy
    def _update_tabs(self, *l):
        self_content = self.content
        if not self_content:
            return
        # cache variables for faster access
        tab_pos = self.tab_pos
        tab_layout = self._tab_layout
        tab_layout.clear_widgets()
        scrl_v = ScrollView(size_hint=(None, 1))
        tabs = self._tab_strip
        parent = tabs.parent
        if parent:
            parent.remove_widget(tabs)
        scrl_v.add_widget(tabs)
        scrl_v.pos = (0, 0)
        self_update_scrollview = self._update_scrollview

        # update scrlv width when tab width changes depends on tab_pos
        if self._partial_update_scrollview is not None:
            tabs.unbind(width=self._partial_update_scrollview)
        self._partial_update_scrollview = partial(
            self_update_scrollview, scrl_v)
        tabs.bind(width=self._partial_update_scrollview)

        # remove all widgets from the tab_strip
        self.clear_widgets(do_super=True)
        tab_height = self.tab_height

        widget_list = []
        tab_list = []
        pos_letter = tab_pos[0]
        if pos_letter == 'b' or pos_letter == 't':
            # bottom or top positions
            # one col containing the tab_strip and the content
            self.cols = 1
            self.rows = 2
            # tab_layout contains the scrollview containing tabs and two blank
            # dummy widgets for spacing
            tab_layout.rows = 1
            tab_layout.cols = 3
            tab_layout.size_hint = (1, None)
            tab_layout.height = tab_height
            self_update_scrollview(scrl_v)

            if pos_letter == 'b':
                # bottom
                if tab_pos == 'bottom_mid':
                    tab_list = (Widget(), scrl_v, Widget())
                    widget_list = (self_content, tab_layout)
                else:
                    if tab_pos == 'bottom_left':
                        tab_list = (scrl_v, Widget(), Widget())
                    elif tab_pos == 'bottom_right':
                        #add two dummy widgets
                        tab_list = (Widget(), Widget(), scrl_v)
                    widget_list = (self_content, tab_layout)
            else:
                # top
                if tab_pos == 'top_mid':
                    tab_list = (Widget(), scrl_v, Widget())
                elif tab_pos == 'top_left':
                    tab_list = (scrl_v, Widget(), Widget())
                elif tab_pos == 'top_right':
                    tab_list = (Widget(), Widget(), scrl_v)
                widget_list = (tab_layout, self_content)
        elif pos_letter == 'l' or pos_letter == 'r':
            # left ot right positions
            # one row containing the tab_strip and the content
            self.cols = 2
            self.rows = 1
            # tab_layout contains two blank dummy widgets for spacing
            # "vertically" and the scatter containing scrollview
            # containing tabs
            tab_layout.rows = 3
            tab_layout.cols = 1
            tab_layout.size_hint = (None, 1)
            tab_layout.width = tab_height
            scrl_v.height = tab_height
            self_update_scrollview(scrl_v)

            # rotate the scatter for vertical positions
            rotation = 90 if tab_pos[0] == 'l' else -90
            sctr = Scatter(do_translation=False,
                           rotation=rotation,
                           do_rotation=False,
                           do_scale=False,
                           size_hint=(None, None),
                           auto_bring_to_front=False,
                           size=scrl_v.size)
            sctr.add_widget(scrl_v)

            lentab_pos = len(tab_pos)

            # Update scatter's top when it's pos changes.
            # Needed for repositioning scatter to the correct place after its
            # added to the parent. Use clock_schedule_once to ensure top is
            # calculated after the parent's pos on canvas has been calculated.
            # This is needed for when tab_pos changes to correctly position
            # scatter. Without clock.schedule_once the positions would look
            # fine but touch won't translate to the correct position

            if tab_pos[lentab_pos - 4:] == '_top':
                #on positions 'left_top' and 'right_top'
                sctr.bind(pos=partial(self._update_top, sctr, 'top', None))
                tab_list = (sctr, )
            elif tab_pos[lentab_pos - 4:] == '_mid':
                #calculate top of scatter
                sctr.bind(pos=partial(self._update_top, sctr, 'mid',
                                      scrl_v.width))
                tab_list = (Widget(), sctr, Widget())
            elif tab_pos[lentab_pos - 7:] == '_bottom':
                tab_list = (Widget(), Widget(), sctr)

            if pos_letter == 'l':
                widget_list = (tab_layout, self_content)
            else:
                widget_list = (self_content, tab_layout)

        # add widgets to tab_layout
        add = tab_layout.add_widget
        for widg in tab_list:
            add(widg)

        # add widgets to self
        add = self.add_widget
        for widg in widget_list:
            add(widg)
コード例 #7
0
    def _update_tabs(self, *l):
        self_content = self.content
        if not self_content:
            return
        # cache variables for faster access
        tab_pos = self.tab_pos
        tab_layout = self._tab_layout
        tab_layout.clear_widgets()
        scrl_v = ScrollView(size_hint=(None, 1))
        tabs = self._tab_strip
        parent = tabs.parent
        if parent:
            parent.remove_widget(tabs)
        scrl_v.add_widget(tabs)
        scrl_v.pos = (0, 0)
        self_update_scrollview = self._update_scrollview

        # update scrlv width when tab width changes depends on tab_pos
        if self._partial_update_scrollview is not None:
            tabs.unbind(width=self._partial_update_scrollview)
        self._partial_update_scrollview = partial(self_update_scrollview,
                                                  scrl_v)
        tabs.bind(width=self._partial_update_scrollview)

        # remove all widgets from the tab_strip
        self.clear_widgets(do_super=True)
        tab_height = self.tab_height

        widget_list = []
        tab_list = []
        pos_letter = tab_pos[0]
        if pos_letter == 'b' or pos_letter == 't':
            # bottom or top positions
            # one col containing the tab_strip and the content
            self.cols = 1
            self.rows = 2
            # tab_layout contains the scrollview containing tabs and two blank
            # dummy widgets for spacing
            tab_layout.rows = 1
            tab_layout.cols = 3
            tab_layout.size_hint = (1, None)
            tab_layout.height = tab_height
            self_update_scrollview(scrl_v)

            if pos_letter == 'b':
                # bottom
                if tab_pos == 'bottom_mid':
                    tab_list = (Widget(), scrl_v, Widget())
                    widget_list = (self_content, tab_layout)
                else:
                    if tab_pos == 'bottom_left':
                        tab_list = (scrl_v, Widget(), Widget())
                    elif tab_pos == 'bottom_right':
                        #add two dummy widgets
                        tab_list = (Widget(), Widget(), scrl_v)
                    widget_list = (self_content, tab_layout)
            else:
                # top
                if tab_pos == 'top_mid':
                    tab_list = (Widget(), scrl_v, Widget())
                elif tab_pos == 'top_left':
                    tab_list = (scrl_v, Widget(), Widget())
                elif tab_pos == 'top_right':
                    tab_list = (Widget(), Widget(), scrl_v)
                widget_list = (tab_layout, self_content)
        elif pos_letter == 'l' or pos_letter == 'r':
            # left ot right positions
            # one row containing the tab_strip and the content
            self.cols = 2
            self.rows = 1
            # tab_layout contains two blank dummy widgets for spacing
            # "vertically" and the scatter containing scrollview
            # containing tabs
            tab_layout.rows = 3
            tab_layout.cols = 1
            tab_layout.size_hint = (None, 1)
            tab_layout.width = tab_height
            scrl_v.height = tab_height
            self_update_scrollview(scrl_v)

            # rotate the scatter for vertical positions
            rotation = 90 if tab_pos[0] == 'l' else -90
            sctr = Scatter(do_translation=False,
                           rotation=rotation,
                           do_rotation=False,
                           do_scale=False,
                           size_hint=(None, None),
                           auto_bring_to_front=False,
                           size=scrl_v.size)
            sctr.add_widget(scrl_v)

            lentab_pos = len(tab_pos)

            # Update scatter's top when it's pos changes.
            # Needed for repositioning scatter to the correct place after its
            # added to the parent. Use clock_schedule_once to ensure top is
            # calculated after the parent's pos on canvas has been calculated.
            # This is needed for when tab_pos changes to correctly position
            # scatter. Without clock.schedule_once the positions would look
            # fine but touch won't translate to the correct position

            if tab_pos[lentab_pos - 4:] == '_top':
                #on positions 'left_top' and 'right_top'
                sctr.bind(pos=partial(self._update_top, sctr, 'top', None))
                tab_list = (sctr, )
            elif tab_pos[lentab_pos - 4:] == '_mid':
                #calculate top of scatter
                sctr.bind(
                    pos=partial(self._update_top, sctr, 'mid', scrl_v.width))
                tab_list = (Widget(), sctr, Widget())
            elif tab_pos[lentab_pos - 7:] == '_bottom':
                tab_list = (Widget(), Widget(), sctr)

            if pos_letter == 'l':
                widget_list = (tab_layout, self_content)
            else:
                widget_list = (self_content, tab_layout)

        # add widgets to tab_layout
        add = tab_layout.add_widget
        for widg in tab_list:
            add(widg)

        # add widgets to self
        add = self.add_widget
        for widg in widget_list:
            add(widg)