PHP GTK按钮点击
我试图让这个按钮改变背景当你点击它,这就是我所拥有的:
<?php
if (!class_exists('gtk')) {
die("Please load the php-gtk2 module in your php.ini\r\n");
}
function loc(){
return dirname(__FILE__);
};
$wnd = new GtkWindow();
$wnd->set_title('Picture Viewer');
$wnd->set_resizable(false);
$wnd->set_position(GTK_WIN_POS_CENTER);
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
$im = GtkImage::new_from_file(loc()."\bg.jpg");
$btn = new GtkButton;
$btn->set_image($im);
$btn->clicked(function(){
$im = GtkImage::new_from_file(loc()."\bg2.jpg");
$btn->set_image($im);
});
$wnd->add($btn);
$wnd->show_all();
Gtk::main();
?>
< strong>为什么这不起作用?
我认为$btn->clicked(function(){
部分是问题所在。
I'm trying to make this button change background when you click it and this is what I have:
<?php
if (!class_exists('gtk')) {
die("Please load the php-gtk2 module in your php.ini\r\n");
}
function loc(){
return dirname(__FILE__);
};
$wnd = new GtkWindow();
$wnd->set_title('Picture Viewer');
$wnd->set_resizable(false);
$wnd->set_position(GTK_WIN_POS_CENTER);
$wnd->connect_simple('destroy', array('gtk', 'main_quit'));
$im = GtkImage::new_from_file(loc()."\bg.jpg");
$btn = new GtkButton;
$btn->set_image($im);
$btn->clicked(function(){
$im = GtkImage::new_from_file(loc()."\bg2.jpg");
$btn->set_image($im);
});
$wnd->add($btn);
$wnd->show_all();
Gtk::main();
?>
Why doesn't this work?
I think that the $btn->clicked(function(){
part is the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
$btn->clicked
实际上发出点击信号。您想要做的是将函数连接到信号:$btn->clicked
actually emits the clicked signal. What you want to do is connect a function to the signal: