'GTK +' Category

  • 错误生涯:Warning: unable to set property `editable' of type `gboolean' from value of type `gchararray'

    五月 4, 2009

    Warning: unable to set property `editable' of type `gboolean' from value of type `gchararray' 做GTK编程的时候,使用TreeView控件时出现这个警告,也就是无法使单元格变为“editable”,原因出在这里: column = gtk.TreeViewColumn(columName[columnNum], renderer, editable=True) 原理解TreeViewColumn的构造函数接受的参数里面可以接受设置Cellrenderer的属性,就直接给editable设True,于是就得到以上警告。 换用add_attribute、set_attributes,均是如此。 Google上搜到同样错误警告,但是他的原因是设错值类型,我明明设了True啊…… 自己观察pygtk-demo的代码和手册,突然发现在构造函数里面给出的属性设置值不应该是直接的值,而是对应Model里面的相应column的值!看手册的描述: Zero or more attribute=column pairs may be added to specify from which tree model column to retrieve the attribute value. 呃,果然是看手册时候大意了,这么多年来还是让英语介词搞的晕头转向。如果在构造函数里面设True这个值,就会被解析为1,去对应Model里面第二栏的类型,是字符串的gchararray,当然对不上了。 解决办法是renderer.set_property("editable", True),调用继承自GObject的set_property方法来设置对象属性。

  • Create a exe file with icon in Mingw gcc

    一月 12, 2009

    1. get a icon file name "logo.ico"2. create an file name "logo.rc", contain a line: 1 ICON "icon.ico" 3. run : (windres was include in Mingw) windres logo.rc logo.o 4. link the "logo.o" file together with other object files to the final exe file.

  • 编程笔记:Editable Treeview Cell

    一月 12, 2009

    I found that programming gtk+ plays a lot of tricks. I implemented "editable treeview cells" today in my program, after spending quite a while looking up for examples on Google. The most I wanted to say is that, the Gtk manual was detailed enough, but it never tells you how to do, which makes me [...]

  • 编程笔记:GtkBuilder和popup menu

    一月 12, 2009

    今天又奋战gtk的文档,看着别人写的旧版example代码,用GtkBuilder的方法重写,实现了一个自己想要的TreeView List。最后想在TreeView中加入一个右键菜单,却想不到小小的popup menu就给我设了两大难关。 首先找来找去没有见到有right-click的signal,Google了一下,从Maillist里面的解答找到头绪,由GtkWidget的button_press_event来实现。GTK+ Reference Manual里面一点都没提到这个信号,原来这个button指鼠标的button,键盘的键叫做key…… http://mail.gnome.org/archives/gtk-list/2002-August/msg00119.html button_press_event emits when any mouse button pressed, when handling with this signal, use a callback prototype in this way: gboolean callback (GtkWidget *widget, GdkEventButton *event, gpointer data); and you can determine which button was press with event->button (values 1,2,3...3 stands for the right button, 1 for left and [...]

Page optimized by WP Minify WordPress Plugin

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org