简体   繁体   English

如何从桌面图标通过Cygwin启动带有GUI的GNU Octave?

[英]How to start GNU Octave with GUI through Cygwin from a desktop icon?

Since GNU Octave comes wit a GUI since versions 3.8.0, I thought I should check it out. 由于GNU Octave自3.8.0版以来就带有GUI,我想我应该检查一下。

So since I run Windows and could only find Octave 3.8 for Cygwin, I installed Cygwin and the packages octave , xinit , xlaunch and gnuplot (according to this page , but I don't know if all those packages are needed). 所以,因为我运行Windows并且只能为Cygwin找到Octave 3.8,所以我安装了Cygwin和包octavexinitxlaunchgnuplot (根据这个页面 ,但我不知道是否需要所有这些包)。

Then, when trying to start Octave with the GUI from Cygwin with octave --force-gui , I initially got the error message 然后,当尝试使用带有octave --force-gui Cygwin的GUI启动Octave时,我最初得到了错误消息

octave: X11 DISPLAY environment variable not set

and Octave would start in console mode. 和Octave将以控制台模式启动。 So I found this page , which told me to run 所以我找到了这个页面 ,告诉我要运行

echo "export DISPLAY=:0.0" >>~/.bash_profile

from Cygwin, to permanently get rid of the error message, which worked. 从Cygwin,永久摆脱错误信息,这是有效的。 However, then I instead got this error message: 但是,然后我得到此错误消息:

octave: unable to open X11 DISPLAY

The same page also said that you have to run the X Server by going to Start -> Cygwin-X -> XWin Server. 同一页面还说你必须通过转到开始 - > Cygwin-X - > XWin服务器来运行X服务器。 That worked, but since I don't want the xterm terminal to start since it is not needed, I found this page which told me to run 这工作,但由于我不希望xterm终端启动,因为它不需要,我发现这个页面告诉我运行

touch ~/.startxwinrc

from Cygwin to create an empty .startxwinrc file, to prevent the xtrem terminal from starting by default, which worked. 从Cygwin创建一个空的.startxwinrc文件,以防止xtrem终端默认启动,这有效。 The same page also mentioned that the X Server can be started directly from Cygwin with the command startxwin . 同一页面还提到可以使用命令startxwin直接从Cygwin启动X Server。

So, now I can start Octave with the GUI from Cygwin, simply by running 所以,现在我可以使用Cygwin的GUI启动Octave,只需运行即可

startxwin
octave --force-gui

However, I would like to just be able to double click on a desktop icon to get everything up and running. 但是,我希望能够双击桌面图标以启动并运行所有内容。

So, to my question: Can I somehow put this in a script file, which when I run it, will be opened in Cygwin so that the commands in the script file will be run in Cygwin? 所以,对于我的问题: 我可以以某种方式把它放在一个脚本文件中,当我运行它时,将在Cygwin中打开,以便脚本文件中的命令将在Cygwin中运行? And is there some way to automatically close the X Server after Octave has terminated? 在Octave终止后,有没有办法自动关闭X服务器? I've tried writing a file octave.bat , which starts Cygwin and gives a second batch file as argument, which in turn contains the commands I want to execute. 我已经尝试编写一个文件octave.bat ,它启动Cygwin并提供第二个批处理文件作为参数,而后者又包含我想要执行的命令。 But when I run the first script, I just get bombarded with command prompts (not Cygwin prompts), and the all say 但是当我运行第一个脚本时,我只是被命令提示(而不是Cygwin提示)轰炸,而且所有人都说

'startxwin' is not recognized as an internal or external command, operable program or batch file.

Why is the second script not opened in Cygwin, and how can I achieve what I want as simply as possible? 为什么第二个脚本没有在Cygwin中打开,我怎样才能尽可能地实现我想要的?

Please grab Octave from here: http://mxeoctave.osuv.de/ 请从这里抓住Octave: http//mxeoctave.osuv.de/

The installer should configure everything for you. 安装程序应该为您配置一切。

GNU Octave offers now Windows binary itself. GNU Octave现在提供Windows二进制文件。 Go to ftp://ftp.gnu.org/gnu/octave/windows/ 转到ftp://ftp.gnu.org/gnu/octave/windows/

You have to put 你必须把

c:\cygwin64\bin\mintty.exe /bin/sh -lc 'startxwin /bin/octave --force-gui'

in your windows batch file (please adapt the Cygwin path to your settings). 在您的Windows批处理文件中(请根据您的设置调整Cygwin路径)。 That worked fine for me. 这对我来说很好。

The call 电话

c:\cygwin64\bin\bash --login -c "startxwin /bin/octave --force-gui"

did open Octave as desired but the GUI seemed to have response issues to the keyboard and froze after clicking into the editor. 确实打开了Octave,但是GUI似乎对键盘有响应问题,点击进入编辑器后就冻结了。

I don't have any of the those commands installed with my Cygwin installation, so I can't test this by trying using the following an .bat file on your desktop: 我没有安装Cygwin安装的任何命令,因此我无法通过在桌面上使用以下.bat文件来测试它:

 c:\cygwin\bin\bash --login -c "startxwin octave --force-gui"

Replace c:\\cygwin with the directory where you installed Cygwin. c:\\cygwin替换为安装Cygwin的目录。

If this leaves a console window on the screen try doing: 如果这在屏幕上留下控制台窗口,请尝试:

 c:\cygwin\bin\bash --login -c "run startxwin octave --force-gui"

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

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