我已经准备好从熊猫数据库中显示一些数据,我想使其看起来不错,但我只是能够将其打印为标签。看起来糟透了我也想使其滚动,但我在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 |

最佳答案

您是否已检查此模块DataframeGUIKivy

您可以使用此模块在Kivy中显示熊猫数据框。

08-24 13:45
查看更多