wxruby 和 rubymsn
我目前正在使用 wxRuby 和 RubyMSN 来学习编写桌面程序。我知道这是一项艰巨的任务,而不仅仅是装一个记事本等,但我需要比记事本更大的任务。
我现在确实设法自己使用它们,但我无法让它们一起工作。问题是循环。
RubyMSN 想要有一个无限循环,例如
while true
sleep 1
end
使用 GUI 的 mainloop 或其他东西,
我目前将此代码作为循环,
TheApp.new.main_loop()
while true
sleep 1
end
我让我的窗口工作,并且 main_loop 做一些事情。但我无法登录,就像我没有任何循环(来自
有人吗?
I'm currently playing with wxRuby and RubyMSN to learn to program desktop-programs. I know it is a hard task instead of just crating a notepad etc, but I need a bigger task than a notepad.
I now do manage to use them by them self, but I cant get them to work together. The problem is the loop.
RubyMSN wants to have an endless loop like
while true
sleep 1
end
or using the GUI's mainloop or something
I currently have this code as the loop
TheApp.new.main_loop()
while true
sleep 1
end
I have my window working, and the main_loop doing something. But I cant log in, it's like I doesn't have any loop (from the tutorial), I only get one debug line. But as soon as I close the window and lets the endless loop do it's job it works like a charm.
Someone ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为我工作。试试这个:从 wxruby 发行版复制
minimal
示例,并修改minimal.rb
以便在 wx 主循环之前启动 msn 线程:您需要当然,在
minimal
目录中符号链接msn
目录以使 require 语句正常工作。您不需要
while true {sleep 1}
循环;这只是为了防止程序退出,以便您的 msn 线程可以继续运行。 wx 主循环完成相同的目的。Worked for me. Try this: copy the
minimal
sample from the wxruby distribution, and modifyminimal.rb
so that you start your msn thread just before the wx main loop:You'll need to symlink the
msn
directory inside theminimal
directory to get the require statement working, of course.You don't need the
while true {sleep 1}
loop; that's just to prevent the program from exiting so that your msn thread can keep running. The wx main loop accomplishes the same purpose.