在wxWidgets中使用GUI附加控制台 [英] Attaching the console with the GUI in wxWidgets

查看:148
本文介绍了在wxWidgets中使用GUI附加控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在写一个wxWidgets GUI应用程序,但它也使用一些控制台对象。

I'm writing a wxWidgets GUI application, but it also uses some console objects.

我需要一种显示stdout和访问stdin的方法;最好的方法是显示控制台以及GUI。这可以在用户从命令提示符/ shell等运行程序时完成,但是在应用程序运行时命令提示符不会自动打开以查看stdout。

I need a way of displaying stdout and accessing stdin; the best way to do this, would be displaying the console as well as the GUI. This can be done if a user runs the program from the command prompt/shell etc, but the command prompt does not automatically open to view stdout when the application is ran.

我知道这是可能的,因为当你运行一个控制台应用程序,控制台自动运行。我发现一个或两个解决方案需要Windows API,但可惜的是我的代码需要跨平台(我正在Linux上开发这个)。

I know this has to be possible, because when you run a console application, the console runs automatically. I found one or two solutions that require the Windows API, but sadly my code needs to be cross platform (I'm developing this on Linux).

推荐答案

解决方案非常简单:使用 wxStreamToTextRedirector 。这允许控制台输出重定向到文本控件。您可以为此创建一个单独的窗口,并将其颜色设置为控制台。上面的链接提供了一个示例。

The solution is very simple: use wxStreamToTextRedirector. This allows console output to be redirected to a text control. You could create a separate window for this and color it to look like a console. The link above provides an example.

这篇关于在wxWidgets中使用GUI附加控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆