如何在 haskell/gtk2hs 中制作图形命令行?
我正在尝试在 haskell 中创建我的第一个“真正的程序”(如果多项式可以解决积分问题),但我完全被这部分难住了:
我想做一些非常简单的东西,有点像 GHCi:
> user input
program output
> user input
program output
> user input
program output
>
除了我的程序输出是图像(使用 LaTeX 将数学表达式转换为 PNG) - 所以我不能使用 System.IO 来做到这一点。我认为使用我已成功安装的 gtk2hs 是可能的,但我不知道如何进行此输入/输出对话。
如果您有时间,请向我展示它是如何完成的。多谢!
I'm trying to create my first "real program" in haskell (something that solves integrals if polynomials) but I'm completely stumped with this part of it:
I want to make something very simple a bit like GHCi:
> user input
program output
> user input
program output
> user input
program output
>
except that my program output is images (using LaTeX to turn mathematical expressions into PNGs) - so I can't do this using System.IO. I think it will be possible with gtk2hs which I've managed to install but I can't figure out how to make this input/output dialogue.
Please show me how it's done if you have the time. Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢 ClaudiusMaximus,我们设法提出了以下解决方案。
We managed to come up with the following solution, thanks to ClaudiusMaximus.
我认为你应该首先实现后端,即解析命令和创建输出图像的代码。如果可行,您就可以实现 GUI。基本上,您需要一些轻量级的文本输入用于输入,文本和绘图小部件用于输出。由于 GUI 编程(恕我直言)并不简单,因此您应该首先查看一些 GTK/gtk2hs 教程/介绍。
I think you should first implement the backend, i.e. the code for parsing a command and creating the output image. If that works, you could then implement the GUI. Basically, you need something light a text entry for input and an text and drawing widget for output. As GUI programming is (IMHO) not trivial, you should first look at some GTK/gtk2hs tutorials / introductions.