wxruby 和 ruby​​msn

发布于 2024-08-13 04:21:19 字数 402 浏览 6 评论 0原文

我目前正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉睡月亮 2024-08-20 04:21:19

为我工作。试试这个:从 wxruby 发行版复制 minimal 示例,并修改 minimal.rb 以便在 wx 主循环之前启动 msn 线程:

require 'msn/msn'

conn = MSNConnection.new("[email protected]", "secretpassword123")
conn.start

# Wx::App is the container class for any wxruby app. To start an
# application, either define a subclass of Wx::App, create an instance,
# and call its main_loop method, OR, simply call the Wx::App.run class
# method, as shown here.
Wx::App.run do 
  self.app_name = 'Minimal'
  frame = MinimalFrame.new("Minimal wxRuby App")
  frame.show
end

您需要当然,在 minimal 目录中符号链接 msn 目录以使 require 语句正常工作。

您不需要 while true {sleep 1} 循环;这只是为了防止程序退出,以便您的 msn 线程可以继续运行。 wx 主循环完成相同的目的。

Worked for me. Try this: copy the minimal sample from the wxruby distribution, and modify minimal.rb so that you start your msn thread just before the wx main loop:

require 'msn/msn'

conn = MSNConnection.new("[email protected]", "secretpassword123")
conn.start

# Wx::App is the container class for any wxruby app. To start an
# application, either define a subclass of Wx::App, create an instance,
# and call its main_loop method, OR, simply call the Wx::App.run class
# method, as shown here.
Wx::App.run do 
  self.app_name = 'Minimal'
  frame = MinimalFrame.new("Minimal wxRuby App")
  frame.show
end

You'll need to symlink the msn directory inside the minimal 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文