显示从熊猫到Kivy的数据

问题描述 投票:1回答:1

我有一些数据准备从熊猫数据库显示,我想让它看起来不错,但我只能将其打印为标签。看起来很糟糕我也想让它可滚动但我在Kivy全新。我无法在互联网上制作任何解决方案。这是我的代码。

我希望有一种类型的库可以处理Kivy的熊猫,但我没有看到类似的东西。

任何建议将不胜感激,提前谢谢。

class ScatterTextWidget(BoxLayout):

''' this part we take the information from timestation website and start analyze it '''

    item_to_display = ObjectProperty()
    text_location = ObjectProperty()
    input_date = ObjectProperty()
    input_time = ObjectProperty()

    def initialize_request(self):
        ''' Initial analysis and control flow of the class '''

        location = self.text_location.text
        date = self.input_date.text
        time_raw = self.input_time.text

        url = 'test.csv'

        data = pd.read_csv(url)
        time = self.time_format_checker(time_d=time_raw)
        group_name = data[data["Time"] <= time]
        duplicates_removed = group_name.drop_duplicates(subset="Name", keep='last')
        punch_in_df = duplicates_removed[duplicates_removed.Activity.str.contains('Punch In')]
        filtered_data = punch_in_df[punch_in_df.Department.str.contains(location)]
        filtered_data.reset_index(inplace=True)
        self.item_to_display.text = filtered_data[['Name', 'Department', 'Device', 'Time']].to_string()

这是kivy文件---短版:

#:import utils kivy.utils
#:import ListAdapter kivy.adapters.listadapter.ListAdapter
#:import ListItemButton kivy.uix.listview.ListItemButton
#:import main MainGui


<ScatterTextWidget>:

    text_location:text_location
    item_to_display:item_to_display
    input_date:input_date
    input_time:input_time


    canvas.before:
        Color:
             rgb: utils.get_color_from_hex('#000131')
        Rectangle:
            pos: self.pos
            size: self.size

    BoxLayout:
         orientation: "vertical"

        BoxLayout:
            canvas.before:
                 Color:
                    rgb: utils.get_color_from_hex('#00050c')
                 Rectangle:
                    pos: self.pos
                    size: self.size

            Label:
                id:item_to_display
                pos_hint_y: 'top'
                size_hint_y: .75
                text: 'Please introduce the Date'

我希望得到这样的东西:

Name               | Department   | Device      | Time |
Rodriguez, Cesar   |IT Department | IT Office   | 6:00 |
Clarke, Gyles      |Kent Avenue   | Kent Device | 7:00 |
python python-3.x kivy kivy-language
1个回答
1
投票

你检查一下这个模块DataframeGUIKivy吗?

您可以使用此模块在Kivy中显示pandas数据帧。

© www.soinside.com 2019 - 2024. All rights reserved.