“接受位置” Ruby/Gtk2 中未调用信号

发布于 2024-08-11 02:07:34 字数 827 浏览 7 评论 0原文

我正在用 Ruby/Gtk 创建一个带有窗格的应用程序。当调整窗格大小时,我需要做一些事情。但我不知道该使用哪个信号。我认为这是“accept_position” - 但它似乎不起作用。这是一个示例应用程序,说明了我的问题...

#!/usr/bin/env ruby

require 'gtk2'

window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
window.set_title  "Panes"
window.border_width = 10
window.set_size_request(225, 150)
window.signal_connect('destroy') { Gtk.main_quit }
window.signal_connect('delete_event') { false }

button1 = Gtk::Button.new("Resize")
button2 = Gtk::Button.new("Me")

button1.signal_connect( "clicked" ) { window.destroy }
button2.signal_connect( "clicked" ) { window.destroy }

paned = Gtk::VPaned.new
paned.add1(button1)
paned.add2(button2)

paned.signal_connect( "accept_position" ) { 
 puts "hello"
 false
}

window.add(paned)
window.show_all
Gtk.main 

“accept_position”调用从未被触发。知道是什么原因造成的/如何解决它?

I'm creating a application with panes in Ruby/Gtk. When the panes are resized, I need to do some stuff. But I cannot figure out which signal to use. I think it is 'accept_position' - but it don't seem to work. This is a sample app that illustrates my problem...

#!/usr/bin/env ruby

require 'gtk2'

window = Gtk::Window.new(Gtk::Window::TOPLEVEL)
window.set_title  "Panes"
window.border_width = 10
window.set_size_request(225, 150)
window.signal_connect('destroy') { Gtk.main_quit }
window.signal_connect('delete_event') { false }

button1 = Gtk::Button.new("Resize")
button2 = Gtk::Button.new("Me")

button1.signal_connect( "clicked" ) { window.destroy }
button2.signal_connect( "clicked" ) { window.destroy }

paned = Gtk::VPaned.new
paned.add1(button1)
paned.add2(button2)

paned.signal_connect( "accept_position" ) { 
 puts "hello"
 false
}

window.add(paned)
window.show_all
Gtk.main 

The 'accept_position' call is never fired. Any idea what is causing this/how to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

北凤男飞 2024-08-18 02:07:34

'accept_position' 是一个键绑定信号,仅在使用键盘调整窗格大小时发出。

我不了解 Ruby,但在 C 中,您想要的信号是 'notify::position'notify 是一个 GObject 信号,每当属性值更改时就会触发。如果您在连接信号时向信号名称添加详细信息,例如位置,则仅当特定属性更改其值时才会触发。

'accept_position' is a keybinding signal, only emitted when the pane is resized using the keyboard.

I don't know Ruby, but in C the signal you want is 'notify::position'. notify is a GObject signal which fires whenever a property changes its value. If you add a detail, such as position, to the signal name when connecting it, then it only fires when that specific property changes its value.

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