N
nmp
Hi, I have recently (a few days ago) started programming again. As a hobby
for now, but once I become a bit more proficient at Python I may have an
idea or two for some small scale "commercial" projects.
I have a fair understanding of OO concepts having done some Smalltalk in
the (now distant) past. Thought I should mention that for some weird
reason, heh never mind. I may still be a quick learner but I am probably
*way* behind on modern application programming...
My development environment at the moment is Python, PyGTK, Glade and SPE
on Ubuntu 6.10. I am using Dive into Python, www.learnpython.com and such
sources as references, but mostly I try to learn by doing.
First "problem": when I insert the glade file in my application the way
some tutorials have shown me:
self.wTree = gtk.glade.XML("autostart.glade", "mainWindow")
.... Python is consistently giving me this warning:
/home/xxxx/Projecten/autostart/autostart.py:18: GtkWarning:
gtk_widget_grab_default: assertion `GTK_WIDGET_CAN_DEFAULT (widget)'
failed
self.wTree = gtk.glade.XML("autostart.glade", "mainWindow")
It doesn't seem to be a big deal because the program does run and the
window is shown correctly et cetera. However it bugs me, because I don't
*understand* what it is that I am doing wrong. A Google search on this
warning turns up some posts of people asking the same question, but no
answers as far as I can tell... So, how do I get rid of this warning?
Second "problem": I have discovered the Gtk.TreeView and managed to load a
CSV file into it as a primitive database of sorts. And all this with just a
few lines of code, really awesome. However, this TreeView business
confuses me. One of the fields in my database is a boolean (so my
ListModel, I guess it is called, is (str, str, bool)). Imagine something
like this:
Author | Title | In collection?
---------------------+---------------------------+---------------
Darwin, Charles | On the Origin of Species | FALSE
Shakespeare, William | A Midsummer Night's Dream | TRUE
etc. | |
Now I want the user of my program to be able to just double click a row or
hit Enter to flip the boolean, so FALSE becomes TRUE and vice versa.
I got as far as figuring out that I will need to connect a handler for the
row_activated signal. But there it stops for me, I can't quite get my head
around what should happen next. The handler will be passed a Gtk.TreePath
object from which I should be able to extract which row was affected. Now
I *think* that it should be just two or three lines of code, but I can't
figure it out. Haven't seen anything helpful elsewhere, either. I hope
that someone here can give me the key to this, so that I can open the door
myself, and perhaps then I will finally "get" it.
The third "problem" (for now...) is really just a cosmetic thing. The
representation of the boolean in the list is fine for me, but in time I
would like to make it prettier by replacing it with a graphical checkbox.
Does anyone have an example of this that I can use?
Thank you for your patience. I can already see how all this is going to
keep me busy for weeks and it will be fun
for now, but once I become a bit more proficient at Python I may have an
idea or two for some small scale "commercial" projects.
I have a fair understanding of OO concepts having done some Smalltalk in
the (now distant) past. Thought I should mention that for some weird
reason, heh never mind. I may still be a quick learner but I am probably
*way* behind on modern application programming...
My development environment at the moment is Python, PyGTK, Glade and SPE
on Ubuntu 6.10. I am using Dive into Python, www.learnpython.com and such
sources as references, but mostly I try to learn by doing.
First "problem": when I insert the glade file in my application the way
some tutorials have shown me:
self.wTree = gtk.glade.XML("autostart.glade", "mainWindow")
.... Python is consistently giving me this warning:
/home/xxxx/Projecten/autostart/autostart.py:18: GtkWarning:
gtk_widget_grab_default: assertion `GTK_WIDGET_CAN_DEFAULT (widget)'
failed
self.wTree = gtk.glade.XML("autostart.glade", "mainWindow")
It doesn't seem to be a big deal because the program does run and the
window is shown correctly et cetera. However it bugs me, because I don't
*understand* what it is that I am doing wrong. A Google search on this
warning turns up some posts of people asking the same question, but no
answers as far as I can tell... So, how do I get rid of this warning?
Second "problem": I have discovered the Gtk.TreeView and managed to load a
CSV file into it as a primitive database of sorts. And all this with just a
few lines of code, really awesome. However, this TreeView business
confuses me. One of the fields in my database is a boolean (so my
ListModel, I guess it is called, is (str, str, bool)). Imagine something
like this:
Author | Title | In collection?
---------------------+---------------------------+---------------
Darwin, Charles | On the Origin of Species | FALSE
Shakespeare, William | A Midsummer Night's Dream | TRUE
etc. | |
Now I want the user of my program to be able to just double click a row or
hit Enter to flip the boolean, so FALSE becomes TRUE and vice versa.
I got as far as figuring out that I will need to connect a handler for the
row_activated signal. But there it stops for me, I can't quite get my head
around what should happen next. The handler will be passed a Gtk.TreePath
object from which I should be able to extract which row was affected. Now
I *think* that it should be just two or three lines of code, but I can't
figure it out. Haven't seen anything helpful elsewhere, either. I hope
that someone here can give me the key to this, so that I can open the door
myself, and perhaps then I will finally "get" it.
The third "problem" (for now...) is really just a cosmetic thing. The
representation of the boolean in the list is fine for me, but in time I
would like to make it prettier by replacing it with a graphical checkbox.
Does anyone have an example of this that I can use?
Thank you for your patience. I can already see how all this is going to
keep me busy for weeks and it will be fun