我什么时候应该添加GUI?

时间:2022-09-10 23:52:13

I write many scripts at home and on the job. Most of the time the scripts get used only a few times to accomplish their chosen task and then are never used again. However, sometimes I write a script to do something more complicated, something that requires user input. It is at this point that I usually agonize over whether to implement a GUI or stick with a y/n, press 1-10, etc. command-line interface. This type of interface can become tedious to use and difficult to maintain.

我在家里和工作中写了很多脚本。大多数情况下,脚本只使用几次来完成他们所选择的任务,然后再也不会使用。但是,有时我会编写一个脚本来做一些更复杂的事情,这需要用户输入。正是在这一点上,我经常为是否使用y / n,按1-10等命令行界面实现GUI或棒而苦恼。这种类型的界面使用起来变得乏味且难以维护。

I know some things lend themselves to a GUI more than others, such as selecting things in a giant list. However, the time it takes to switch a command-line application to use a GUI is prohibitive. For me, it takes a good amount of time to add a GUI with even the most simple framework I can find.

我知道有些东西比其他东西更适合GUI,比如在巨大的列表中选择东西。但是,将命令行应用程序切换为使用GUI所花费的时间是令人望而却步的。对我来说,即使是我能找到的最简单的框架,也需要花费大量时间来添加GUI。

I am curious if any developers have a method of determining at what point their script has grown enough to need a GUI. Or am I going about this the wrong way, should I always be writing my scripts assuming I might later add a GUI?

我很好奇是否有任何开发人员有一种方法可以确定他们的脚本在什么时候已经增长到足以需要GUI。或者我是以错误的方式解决这个问题,我是否应该总是编写我的脚本,假设我以后可能会添加GUI?

7 个解决方案

#1


As with many questions of this type, the answer is that it depends.

与此类型的许多问题一样,答案是它取决于。

If your program/script does just one single thing by receiving a number of inputs from the user, it is better to stick with the non-GUI mode.

如果您的程序/脚本通过从用户接收大量输入来完成一件事,那么最好坚持使用非GUI模式。

If the application is doing more than one thing and if you think that the user will use the application to do a lot of stuff, you may consider using a GUI.

如果应用程序执行的操作不止一件,并且您认为用户将使用该应用程序执行大量操作,则可以考虑使用GUI。

Are you planning to distribute this program to others? Then it is better to provide a GUI.

您打算将此计划分发给其他人吗?那么最好提供一个GUI。

If the users are non-technical, a GUI is a must!

如果用户是非技术用户,则必须使用GUI!

Thats it.

#2


This doesn't answer your question but FWIW an intermediate step, between UI and command-line, is to have a configuration file instead of a UI:

这不能解答您的问题,但FWIW在UI和命令行之间的中间步骤是拥有配置文件而不是UI:

  1. Edit the configuration file
  2. 编辑配置文件

  3. Run the program
  4. 运行程序

A configuration file format can, if necessary, be complicated and well-commented.

如有必要,配置文件格式可以是复杂且评论良好的。

#3


When you want to hand your stuff over to someone else in a discoverable way. Command-line scripts are awesome because they are simple and elegant, but they are not very discoverable. That is, if you were to hand your scripts over to someone else with no documentation, would they be able to figure out what they are and how to use them? If your tasks are so simple that myscript /? will explain what you need to do fully, then you don't need a GUI.

当你想以可发现的方式将你的东西交给别人时。命令行脚本很棒,因为它们简单而优雅,但它们不是很容易被发现。也就是说,如果您将脚本交给没有文档的其他人,他们是否能够弄清楚它们是什么以及如何使用它们?如果你的任务如此简单,以至于myscript /?将解释你需要做什么,然后你不需要GUI。

If on the other hand, you are handing your scripts over to someone who isn't so technical, or needs some more visual guidance about the task to be done, than by all means, a GUI is a good way to go. You might even want to keep your scripts as they are and just create a separate GUI that runs them for maximum flexibility.

另一方面,如果您将脚本交给不那么技术性的人,或者需要更多关于要完成的任务的视觉指导,那么GUI就是一个很好的方法。您甚至可能希望保持脚本不变,只需创建一个单独的GUI来运行它们以获得最大的灵活性。

#4


I think this decission also depends on the audience who will be using your script: If it is people who are comfortable working with the command line, then there is not pressing need to add a GUI as long as your script has a good /help which explains all the parameters it accepts. But if you want the "average user" to be able to use your program, I'd rather add a GUI because otherwise your program might not be intuitive enough for that user group.

我认为这个决定还取决于将使用你的脚本的观众:如果是那些熟悉命令行的人,那么只要你的脚本有一个好的/帮助,就没有必要添加GUI。解释它接受的所有参数。但是,如果您希望“普通用户”能够使用您的程序,我宁愿添加一个GUI,因为否则您的程序可能对该用户组不够直观。

#5


If you only need some "Dialogs" to improve your scripts, you can use KDE Kdialog or Gnome Zenity.

如果您只需要一些“对话框”来改进脚本,可以使用KDE Kdialog或Gnome Zenity。

#6


I can't count the number of times I've written what I thought would be a 'one-off' and it became more useful than I thought and ended up writing a GUI for it, or I've need to come back to use a program months later. The advantage of the GUI is it makes it easier to remember what would otherwise likely be command line arguments. I.e. for flags and options you can simply use check boxes, combo boxes, radio buttons, and file selectors filenames. I use Borland C++ RAD so it is quite quick and easy to throw together a simple (or even not so simple) dialog box. I now often start with creating the GUI.

我无法计算我写过的次数,我认为这是“一次性”,它变得比我想象的更有用,最后为它编写GUI,或者我需要回到几个月后使用一个程序。 GUI的优点是可以更容易地记住可能是命令行参数的内容。即对于标志和选项,您只需使用复选框,组合框,单选按钮和文件选择器文件名。我使用Borland C ++ RAD,因此可以快速轻松地将简单(甚至不那么简单)的对话框放在一起。我现在经常开始创建GUI。

#7


If you use Linux, try Zenity. It's an easy to use tool to make a GUI for command-line programs.

如果您使用Linux,请尝试使用Zenity。它是一个易于使用的工具,可用于命令行程序的GUI。

#1


As with many questions of this type, the answer is that it depends.

与此类型的许多问题一样,答案是它取决于。

If your program/script does just one single thing by receiving a number of inputs from the user, it is better to stick with the non-GUI mode.

如果您的程序/脚本通过从用户接收大量输入来完成一件事,那么最好坚持使用非GUI模式。

If the application is doing more than one thing and if you think that the user will use the application to do a lot of stuff, you may consider using a GUI.

如果应用程序执行的操作不止一件,并且您认为用户将使用该应用程序执行大量操作,则可以考虑使用GUI。

Are you planning to distribute this program to others? Then it is better to provide a GUI.

您打算将此计划分发给其他人吗?那么最好提供一个GUI。

If the users are non-technical, a GUI is a must!

如果用户是非技术用户,则必须使用GUI!

Thats it.

#2


This doesn't answer your question but FWIW an intermediate step, between UI and command-line, is to have a configuration file instead of a UI:

这不能解答您的问题,但FWIW在UI和命令行之间的中间步骤是拥有配置文件而不是UI:

  1. Edit the configuration file
  2. 编辑配置文件

  3. Run the program
  4. 运行程序

A configuration file format can, if necessary, be complicated and well-commented.

如有必要,配置文件格式可以是复杂且评论良好的。

#3


When you want to hand your stuff over to someone else in a discoverable way. Command-line scripts are awesome because they are simple and elegant, but they are not very discoverable. That is, if you were to hand your scripts over to someone else with no documentation, would they be able to figure out what they are and how to use them? If your tasks are so simple that myscript /? will explain what you need to do fully, then you don't need a GUI.

当你想以可发现的方式将你的东西交给别人时。命令行脚本很棒,因为它们简单而优雅,但它们不是很容易被发现。也就是说,如果您将脚本交给没有文档的其他人,他们是否能够弄清楚它们是什么以及如何使用它们?如果你的任务如此简单,以至于myscript /?将解释你需要做什么,然后你不需要GUI。

If on the other hand, you are handing your scripts over to someone who isn't so technical, or needs some more visual guidance about the task to be done, than by all means, a GUI is a good way to go. You might even want to keep your scripts as they are and just create a separate GUI that runs them for maximum flexibility.

另一方面,如果您将脚本交给不那么技术性的人,或者需要更多关于要完成的任务的视觉指导,那么GUI就是一个很好的方法。您甚至可能希望保持脚本不变,只需创建一个单独的GUI来运行它们以获得最大的灵活性。

#4


I think this decission also depends on the audience who will be using your script: If it is people who are comfortable working with the command line, then there is not pressing need to add a GUI as long as your script has a good /help which explains all the parameters it accepts. But if you want the "average user" to be able to use your program, I'd rather add a GUI because otherwise your program might not be intuitive enough for that user group.

我认为这个决定还取决于将使用你的脚本的观众:如果是那些熟悉命令行的人,那么只要你的脚本有一个好的/帮助,就没有必要添加GUI。解释它接受的所有参数。但是,如果您希望“普通用户”能够使用您的程序,我宁愿添加一个GUI,因为否则您的程序可能对该用户组不够直观。

#5


If you only need some "Dialogs" to improve your scripts, you can use KDE Kdialog or Gnome Zenity.

如果您只需要一些“对话框”来改进脚本,可以使用KDE Kdialog或Gnome Zenity。

#6


I can't count the number of times I've written what I thought would be a 'one-off' and it became more useful than I thought and ended up writing a GUI for it, or I've need to come back to use a program months later. The advantage of the GUI is it makes it easier to remember what would otherwise likely be command line arguments. I.e. for flags and options you can simply use check boxes, combo boxes, radio buttons, and file selectors filenames. I use Borland C++ RAD so it is quite quick and easy to throw together a simple (or even not so simple) dialog box. I now often start with creating the GUI.

我无法计算我写过的次数,我认为这是“一次性”,它变得比我想象的更有用,最后为它编写GUI,或者我需要回到几个月后使用一个程序。 GUI的优点是可以更容易地记住可能是命令行参数的内容。即对于标志和选项,您只需使用复选框,组合框,单选按钮和文件选择器文件名。我使用Borland C ++ RAD,因此可以快速轻松地将简单(甚至不那么简单)的对话框放在一起。我现在经常开始创建GUI。

#7


If you use Linux, try Zenity. It's an easy to use tool to make a GUI for command-line programs.

如果您使用Linux,请尝试使用Zenity。它是一个易于使用的工具,可用于命令行程序的GUI。