简体   繁体   English

我创建了一个 python 脚本将 excel 表导入我的数据库,但现在我想创建将文件路径作为输入的 Gui

[英]I've created a python script to import excel sheets into my DB, But now i want create Gui which will take file path as input

So i want add GUI in to my script as i already created.exe file of my script and it will take simple file-path from user and and write it into my database.所以我想将 GUI 添加到我的脚本中,因为我已经创建了脚本的 .exe 文件,它将从用户那里获取简单的文件路径并将其写入我的数据库。 My code of taking input:我的输入代码:

filename = input("Input the Filename: ")
dfs = pd.read_excel(filename, usecols=['SR_NO','NTN'], sheet_name=None)

Is there any way that when i run script a gui can pop up and take file path as input and pass it to my script有什么方法可以让我在运行脚本时弹出一个 gui 并将文件路径作为输入并将其传递给我的脚本

If you only need something simple, you can use Tkinter (it's already built-in in Python) and its askopenfile function.如果你只需要简单的东西,你可以使用 Tkinter(它已经内置在 Python 中)及其askopenfile function。 More information about the usage can be found here: https://docs.python.org/3/library/dialog.html#tkinter.filedialog.askopenfile有关用法的更多信息,请参见: https://docs.python.org/3/library/dialog.html#tkinter.filedialog.askopenfile

And here are a few examples on how to use this: https://www.pythontutorial.net/tkinter/tkinter-open-file-dialog/以下是一些关于如何使用它的示例: https://www.pythontutorial.net/tkinter/tkinter-open-file-dialog/

You can use Tkinter , PyQt and Kivy to build a GUI app.您可以使用TkinterPyQtKivy构建 GUI 应用程序。 Although Tkinter is simple, it is not as beautiful as PyQt. Tkinter虽然简单,但不如PyQt漂亮。

Note that: PyQt and PySide are very similar.注意:PyQt 和 PySide 非常相似。 you can learn more from here .您可以从这里了解更多信息。

PyQt - PyQt is a set of Python bindings for The Qt Company's Qt application framework and runs on all platforms supported by Qt including Windows, macOS, Linux, iOS and Android. PyQt - PyQt is a set of Python bindings for The Qt Company's Qt application framework and runs on all platforms supported by Qt including Windows, macOS, Linux, iOS and Android.

Kivy - Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps. Kivy - 开源 Python 库,用于快速开发利用创新用户界面的应用程序,例如多点触控应用程序。

Tkinter - The tkinter package (“Tk interface”) is the standard Python interface to the Tcl/Tk GUI toolkit. Tkinter - The tkinter package (“Tk interface”) is the standard Python interface to the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, including macOS, as well as on Windows systems Tk 和 tkinter 在大多数 Unix 平台(包括 macOS)以及 Windows 系统上都可用

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我已经编写了 python 代码以将 excel 文件(多张)导入我的 sql 服务器,但是对于大文件,它需要太多时间 - I've written the python code to import excel file (multiple sheets) into my sql server, But for large file it taking too much time 我试图让我的程序创建一个文件来保存输入,但我不希望它出现两次。 (Python) - I'm trying to get my program to create a file which will save an input, but I don't want it to appear twice. (Python) 我可以导入 python 脚本以使其在我的 GUI 中运行吗? - Can I import a python script to make it run in my GUI? 如何指定我希望用 python 创建我的 txt 文件的目录? - How can i specify the directory in which i want my txt file to be created with python? 我想在 python 中导入我的文件但无法导入 - i want import my file in python but can't import 我的谷歌表格文件没有源文件夹,我必须使用 python 将它移动到驱动器文件夹中 - My google sheets file have no source folder , I've to move it into drive folder using python 我想在 GUI 中获取用户输入和 output - I want to take user input and output it inside GUI 我想用启动命令运行我的python程序(不是脚本),这是要执行的python程序文件中的一种方法 - i want to run my python program(not script) with start command which is a method in that python program file to be executed 我想使用“数字”中的元素作为名称在单个 excel 文件中创建多个 excel 工作表 - I want to create multiple excel sheets in a single excel file using the elements from 'number' as their name 如何创建批处理文件,使我的python脚本可以进行2次输入 - How do I create a batch file that will allow my python script to take 2 inputs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM