【问题标题】:I need help programming functions for my buttons (importing, exporting)我需要帮助为我的按钮编程功能(导入、导出)
【发布时间】:2018-04-24 21:57:22
【问题描述】:

我正在尝试创建一个真正的基本软件,用户可以:

1)按一个按钮导入一个.csv文件,程序会读取文件并打印出来

2) 按另一个按钮以特定方式对数据进行排序

3) 按第三个也是最后一个按钮将该数据导出为新的 .csv 文件

基本上,我在步骤 1 和 3 上需要帮助,我不知道该怎么做。

我的代码:

from tkinter import *

import tkinter

import tkinter.messagebox

top = Toplevel()


def UploadAction():
#Allows user to import a .csv of their choice into the program
#Python should read the file into the system and display the contents


def SortingCSV():
#Allows user to switch the contents of the file to the desired settings


def Export():
#Exports the manipulated data into a new .csv file and downloads it    


B=Button(top, text ="Upload", command = UploadAction).grid(row=2,column=1)

B=Button(top, text ="Convert File", command = SortingCSV).grid(row=6, column=1)

B=Button(top, text ="Download File", command = Export).grid(row=7,column=1)


top.mainloop()

【问题讨论】:

  • 你是什么意思下载它?你想从网上下载它还是文件存在于你的电脑中,你想在屏幕上打印内容。你想排序的数据类型是什么.在 csv 文件中给出您的内容。
  • 这太笼统了,网上有很多资源可以教你如何读取和处理 csv 文件。
  • 对不起,我意识到我的问题措辞很奇怪。基本上我希望能够打开一个文件对话框,但我遇到了麻烦。

标签: python tkinter


【解决方案1】:

存在许多 Python 模块,可以简化此类问题的工作。

有一个用于处理 csv 的:https://docs.python.org/2/library/csv.html

祝你好运!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多