There is a reason for that. Python is
I started to use vagrant to hold my development environment, it helps to keep the development environment isolated, since the app will run on a Linux server, with a specific database engine and probably some other specific modules, I don’t want to clutter my OS with all that stuff. More if I plan to work on another project that maybe, have a dependency on other versions of the same base (legacy Django perhaps?)
This post comes from the old blog.
A few weeks ago, I have to write a program in PyGTK that was supposed to be all the time in the background. This application needs to run over Microsoft Windows, and hide in the notification area, wich in Windows is near to the clock.
One of challenges for me in this application is that as it must run in the background there must be a way to raise it, the most easy way to do it is by force the user to click on the small icon in the notification area, but in this case, that was impossible because the computer don’t have any mouse, everything is done with the keyboard.
(Reposted from the old blog)
This time I’m going to talk about putting an image as the application background in Gtk. In Gtk we are used to leave the colors of the application to the theme, but sometimes we will need to use an image as background. I already wrote how to draw a pixbuf in a gtk.DrawingArea (Esp), we could use that, but we will “draw” directly on the widget window instead.
Yes, I said the widget’s window instead the widget itself. You should know that every widget that has been packed in a container has a gtk.gdk.window object and is the responsible for containing your widget. Well, we can draw on that object.
The code should look like this:
#!/usr/bin/env python import gtk def draw_pixbuf(widget, event): path = '/home/markuz/wallpapers/WMwall1024x768.gif' pixbuf = gtk.gdk.pixbuf_new_from_file(path) widget.window.draw_pixbuf(widget.style.bg_gc[gtk.STATE_NORMAL], pixbuf, 0, 0, 0,0) window = gtk.Window() window.set_title('Drawing Test') window.set_size_request(640,480) window.connect('destroy',gtk.main_quit) hbbox = gtk.HButtonBox() window.add(hbbox) hbbox.connect('expose-event', draw_pixbuf) button = gtk.Button('Press Me!') hbbox.pack_start(button, True, False, 10) window.show_all() gtk.main()
Reposting from the old blog.
This time I’m about to talk about lazy object, I called like that because they are more or less similar to what we use in lazy treeviews (In Gtk) where the Tree shows expanders but didn’t load the child nodes until you expand the node). What I want to do is create objects and count them, but don’t load any data until I need it.
Why would I need this?. Well. I’m currently writing a program for my employer, this program load a list of customers and shows how many accounts it has. As this accounts are kind of complex I create an object for them. This object is responsible for load/save the data for it, and any data you need is accessed via properties.
294 total views, no views today
Well, its interesting to work with it, basically because I have the influence of GTK+ and having no windows but calling to widgets creates some confusion. Also, there is this Kivy language which is something like what Glade is In GTK but a lot easier to read (actually everything is easier to to read than XML).