enter image description here我希望excel文件的内容显示在图形用户界面框中,而不是缩小或消除列或行。THis代码,截断列并将所有内容压缩在一起。
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()
发布于 2020-07-23 08:46:47
有很多东西可供实验。通过使用.to_string
方法处理数据,我得到了一些结果。(参见pandas.DataFrame.to_string)。在使用不同的值之后,这给出了一些好的结果:
seq_text = Label(root, text=sequence_file.to_string(col_space=30))
您可以进一步尝试对齐列中的文本,该列的信息位于同一链接中。
https://stackoverflow.com/questions/63044329
复制相似问题