我試圖找出爲什麼我的代碼輸出「1」,從靜態的主要功能和從Gtk.Button
後續調用一些明顯的隨機值第一次調用。我的信號處理程序有什麼問題?
gtkdream.vala:
using GLib;
using Gtk;
public class Main : Object {
public int pc = 1;
public Main() {
var builder = new Builder();
builder.add_from_file ("gtkdream.ui");
builder.connect_signals (this);
var window = builder.get_object ("window") as Window;
window.show_all();
}
public void step_clicked() {
stderr.printf("%d\n", pc);
}
static int main (string[] args) {
Gtk.init (ref args);
var app = new Main();
app.step_clicked();
Gtk.main();
return 0;
}
}
gtkdream.ui:
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkWindow" id="window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">window</property>
<property name="window_position">center</property>
<property name="default_width">500</property>
<property name="default_height">400</property>
<child>
<object class="GtkButton" id="step">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="use_action_appearance">False</property>
<property name="label" translatable="yes">Schritt ausführen</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="main_step_clicked" swapped="no"/>
</object>
</child>
</object>
</interface>
我使用這個命令行編譯:
valac gtkdream.vala --pkg gtk+-3.0 --pkg gmodule-2.0
一些錯誤信號連接?
這就是我從不耐煩......我只是呼籲從主要出於絕望,但良好的方法來知道按鈕參數可以是可空搞定。 – 2013-05-04 07:56:23