“接受位置” Ruby/Gtk2 中未调用信号
我正在用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
'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 aGObject
signal which fires whenever a property changes its value. If you add a detail, such asposition
, to the signal name when connecting it, then it only fires when that specific property changes its value.