[英]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.您可以使用Tkinter 、 PyQt和Kivy构建 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.