首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Tkinter -导入一个小表格以显示在我的gui框中

Tkinter -导入一个小表格以显示在我的gui框中
EN

Stack Overflow用户
提问于 2020-07-23 06:54:50
回答 1查看 39关注 0票数 0

enter image description here我希望excel文件的内容显示在图形用户界面框中,而不是缩小或消除列或行。THis代码,截断列并将所有内容压缩在一起。

代码语言:javascript
运行
复制
import pandas as pd
    from tkinter import *
    from tkinter import filedialog
    import tktable
    import os

root = Tk()
root.title('Import Instrument Sequence')
root.geometry('800x400')
#root.resizable(height = 10, width = 50)

#Creating a label
label = Label(root, text='Select Sequence File:')

#putting it on the screen
label.pack()

def browse():
    # Allow user to select a directory, file, and load the seq file
    sequence_filepath = filedialog.askopenfilename('/')
    sequence_file = pd.read_excel(sequence_filepath, header=0, index_col=0)
    work_directory = os.path.dirname(sequence_filepath)
    seq_text = Label(root, text=sequence_file).pack()
    print(sequence_file.head())
    
browse_button = Button(root, text='Browse & Load Sequence', padx=100, command=browse)
browse_button.pack()


root.mainloop()
EN

Stack Overflow用户

发布于 2020-07-23 08:46:47

有很多东西可供实验。通过使用.to_string方法处理数据,我得到了一些结果。(参见pandas.DataFrame.to_string)。在使用不同的值之后,这给出了一些好的结果:

代码语言:javascript
运行
复制
seq_text = Label(root, text=sequence_file.to_string(col_space=30))

您可以进一步尝试对齐列中的文本,该列的信息位于同一链接中。

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63044329

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档