简体   繁体   English

有没有办法为bash脚本设置GUI?

[英]Is there a way of having a GUI for bash scripts?

I have some bash scripts, some simple ones to copy, search, write lines to files and so on. 我有一些bash脚本,一些简单的复制,搜索,写行到文件等等。

I am an Ubuntu. 我是Ubuntu。 and I've searched in google, but it seems that everybody is doing that on python. 我在谷歌搜索过,但似乎每个人都在python上这样做。 I could do these on python, but since I am not a python programmer, I just know the basics. 我可以在python上做这些,但由于我不是python程序员,我只知道基础知识。 I have no idea of how calling a sh script from a GUI written on python. 我不知道如何从python上编写的GUI调用sh脚本。

If someone has a link or something to say, please drop a line. 如果有人有链接或要说的话,请删除一行。

regards, Mario 问候,马里奥

Is there a way of having a GUI for bash scripts? 有没有办法为bash脚本设置GUI?

You can try using Zenity . 您可以尝试使用Zenity

a tool that allows you to display GTK dialog boxes in commandline and shell scripts. 一个工具,允许您在命令行和shell脚本中显示GTK对话框。


I have no idea of how calling a sh script from a GUI written on python. 我不知道如何从python上编写的GUI调用sh脚本。

You can do this using subprocess . 您可以使用subprocess执行此操作。

Personally I would recommend that you learn Python and call the scripts from Python instead of trying to write the GUI in Bash. 就个人而言,我建议您学习Python并从Python调用脚本,而不是尝试在Bash中编写GUI。

basically, all bash does is start other programs (and do symbolic math on the command line). 基本上,所有bash都是启动其他程序(并在命令行上进行符号数学运算)。 So no, you're going to have to involve some other program. 所以不,你将不得不涉及其他一些程序。

I do not fully understand what you want. 我不完全明白你想要什么。 Calling a shell script from python, is like calling any executable from python, using os.system . 从python调用shell脚本就像使用os.system调用python中的任何可执行文件一样

In fact there're several 'guis' for bash, namely zenity and others . 事实上,有两个关于bash的'guis',即zenity其他

If you want to be able to display dialog boxes, calendar selection boxes, etc. you might want to take a look at dialog and whiptail . 如果您希望能够显示对话框,日历选择框等,您可能需要查看对话框whiptail They are not graphical - they use text mode - but they may be adequate for your needs. 它们不是图形 - 它们使用文本模式 - 但它们可能足以满足您的需求。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM