是否可以使用 MacRuby 的 macirb 创建交互式 GUI?
我想使用 Macruby 来制作 GUI 原型。比如创建一个窗口,在其中放置一些视图等。这可能吗?
I'd like to live prototype GUIs with Macruby. Like creating a window, placing some views in it, etc.. Is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的!我自己才弄清楚这一点,所以我想我会分享(尽管这是一个老问题)。我假设您已经安装了 MacRuby(我使用的是 0.11)。
安装 HotConsole。 HotConsole 是一个类似 IRB 的东西,运行 MacRuby 代码。好处是它是多线程的,这意味着 HotCocoa 应用程序不会阻塞控制台。安装方法如下:
然后,您可以将 HotConsole.app 拖到您的 /Applications 文件夹中。
在 HotConsole 中,您可以将 HotCocoa 窗口存储在变量中,然后使用它。例如,在 HotConsole.app 中(确保使用 alt-Enter 转到新行,否则您将运行到目前为止键入的内容):
您应该看到弹出一个漂亮的 Cocoa 窗口,其中带有一个标签,上面写着“你好'。现在是有趣的部分。在 HotConsole.app 中,您现在可以输入:
HotConsole 对我来说相当崩溃,但我使用尚未发布的 MacRuby 版本来构建/运行它,所以我不知道这是否会产生影响。
Yes! I just figured this out myself, so I thought I'd share (even though this is an old question). I'm assuming you have MacRuby installed (I'm using 0.11).
Install HotConsole. HotConsole is an IRB-like thing that runs MacRuby code. The nice thing is that it is multithreaded, which means the HotCocoa app doesn't block the console. To install just:
You can then drag the HotConsole.app to your /Applications folder.
In HotConsole, you can store a HotCocoa window in a variable and then play around with it. For example, in HotConsole.app (make sure you use alt-Enter to go to a new line, else you will run what you've typed so far):
You should see a nice Cocoa window pop up with a label that says 'Hello'. Now for the fun part. In HotConsole.app, you can now type:
HotConsole is pretty crashy for me, but I'm using a not-yet-released version of MacRuby to build/run it, so I don't know if that makes a difference.
是的。
查看 HotCocoa 文档: http://www.macruby.org/hotcocoa.html
Yes it is.
Have a look at the HotCocoa documentation: http://www.macruby.org/hotcocoa.html
但是,您可以,因为所有代码都在主线程中运行,它会阻塞运行循环,因此视图不会按其应有的方式运行。
我一直在致力于另一个允许您执行此操作的项目,唯一重要的是要注意,在这种情况下,所有用户代码都在单独的线程中运行,因此您应该在主线程上分派一条消息与其他视图交互时: https://github.com/alloy/interactive-macruby
You can, however, since all the code runs in the main thread it would block the runloop and thus views won't behave as they should.
I’ve been working on and off on another project that does allow you to do this, the only thing that's important is to note that in this case all user code is run in separate threads, so you should dispatch a message on the main thread when interacting with other views: https://github.com/alloy/interactive-macruby