小编jkd*_*jkd的帖子

如何在vala中使用set_cell_data_func函数来根据其内容更改单元格的布局?

我正在尝试使用set_cell_data_funcon Gtk.TreeViewColumn.我的代码编译但在运行时出现分段错误.我也试过了,insert_column_with_data_func但结果是一样的.

这是我的代码,我希望你能帮助我:)

public class Application : Gtk.Window {
    public Application () {
        this.destroy.connect (Gtk.main_quit);
        this.set_default_size (600, 400);

        Gtk.ListStore store = new Gtk.ListStore (2, typeof(int),
            typeof(string));
        Gtk.TreeIter iter;

        store.append (out iter);
        store.set (iter, 0, 0, 1, "A");
        store.append (out iter);
        store.set (iter, 0, 1, 1, "B");
        store.append (out iter);
        store.set (iter, 0, 0, 1, "C");
        store.append (out iter);
        store.set (iter, 0, 0, 1, "D");

        Gtk.TreeView view = new Gtk.TreeView.with_model (store);
        this.add(view);

        Gtk.CellRendererText cell = new …
Run Code Online (Sandbox Code Playgroud)

gtk vala

6
推荐指数
1
解决办法
581
查看次数

在gtk.SpinButton中显示前导零

我想在旋钮中有一个前导零,以便始终显示两位数.

adj_hour = gtk.Adjustment(int(time.strftime("%H")),0,24,1,1)
entry_hour = gtk.SpinButton()
entry_hour.set_adjustment(adj_hour)
Run Code Online (Sandbox Code Playgroud)

问题是gtk.Adjustment的第一个参数必须是float/int.

我尝试过这样的事情:

adj_hour = gtk.Adjustment(float(format(int(time.strftime("%H")), '02d')),0,24,1,1)
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

gtk pygtk

5
推荐指数
1
解决办法
580
查看次数

标签 统计

gtk ×2

pygtk ×1

vala ×1