You are not logged in.

#1 2011-08-03 11:21:37

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,041

[SOLVED] Testing pygi/gtk code against old Gnome/Gtk

Generally speaking most of the programming I do is of the self-beneficial hacking variety, however recently I inherited a Python/Gtk project that I'll be improving and maintaining. Since I'm running Arch with Gnome & Gtk completely up-to-date, I'm interested in migrating the program to Python 3, PyGObject and Gtk 3. However, since many people are still using Gnome/Gtk 2.X, I need to maintain compatibility with that. Long story short, I think I need to run a virtual machine with, say, the last LTR of Ubuntu (10.04) in order to test the code in an older environment.

I've had a look through the VirtualBox wiki entry and I'm assuming that's the way that I'll go. However, I think that, as far as use case scenarios go, this is a rather simplistic one for virtualization. So, I'll ask here if anyone has any simpler solutions.

Perhaps it's not even necessary. I'm pretty sure that PyGObject introspection supported the last couple 2.x releases of Gtk. But then the question becomes, does anyone know how to force PyGObject to use Gtk2? (despite rumors I've seen online, using it in Python2 does not automatically fall back to Gtk2...in Py2 I'm still loading the Gtk3 libraries).

Thanks for your help!

Last edited by jakobcreutzfeldt (2011-08-03 11:50:44)

Offline

#2 2011-08-03 11:34:44

wonder
Developer
From: Bucharest, Romania
Registered: 2006-07-05
Posts: 5,941
Website

Re: [SOLVED] Testing pygi/gtk code against old Gnome/Gtk

import gi
# make sure you use gtk+-2.0
gi.require_version('Gtk', '2.0')
from gi.repository import Gtk
import gi
# make sure you use gtk+-3.0
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

i think you can do this


Give what you have. To someone, it may be better than you dare to think.

Offline

#3 2011-08-03 11:48:00

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,041

Re: [SOLVED] Testing pygi/gtk code against old Gnome/Gtk

Ok yes, that works. Of course then throughout the code I'll have to handle gtk3-only features like StyleContexts (for that fancy Gtk3 primary-toolbar style) by checking for which version is running.

Thanks, I think that solves it! Much easier than virtualization...

Last edited by jakobcreutzfeldt (2011-08-03 11:49:14)

Offline

Board footer

Powered by FluxBB