source: src/mlx/common.py@ 724:829a9fd55073

Last change on this file since 724:829a9fd55073 was 585:1a277e09c6b9, checked in by István Váradi <ivaradi@…>, 10 years ago

Fixed the handling of the Gst library with PyGTK

File size: 1.7 KB
Line 
1import os
2
3#-----------------------------------------------------------------------------
4
5## @package mlx.common
6#
7# Common definitions to be used by both the GUI and possible other parts
8#
9# The main purpose of this module is to import Gtk+2 or 3 and related modules
10# and provide common names for them. There is a similator module in the GUI
11# part (\ref mlx.gui.common), which contains the GUI-specific names. This one
12# contains only what is used by other modules as well.
13# The variable \c pygobject tells which version of Gtk is being used. If it is
14# \c True, Gtk+ 3 is used via the PyGObject interface. Otherwise Gtk+ 2 is
15# used, which is the default on Windows or when the \c FORCE_PYGTK environment
16# variable is set.
17
18#-------------------------------------------------------------------------------
19
20if os.name=="nt" or "FORCE_PYGTK" in os.environ:
21 print "Using PyGTK"
22 pygobject = False
23 import gobject
24 try:
25 import pygst
26 pygst.require('0.10')
27 import gst
28
29 def gst_init():
30 pass
31
32 def gst_element_factory_make(what):
33 return gst.element_factory_make(what)
34
35 GST_STATE_PLAYING=gst.STATE_PLAYING
36 GST_MESSAGE_EOS=gst.MESSAGE_EOS
37 except:
38 pass
39else:
40 print "Using PyGObject"
41 pygobject = True
42
43 from gi.repository import GObject as gobject
44
45 try:
46 from gi.repository import Gst as gst
47
48 def gst_init():
49 gst.init()
50
51 def gst_element_factory_make(what):
52 return gst.ElementFactory.make(what)
53
54 GST_STATE_PLAYING=gst.State.PLAYING
55 GST_MESSAGE_EOS=gst.MessageType.EOS
56 except:
57 import traceback
58 traceback.print_exc()
59 pass
Note: See TracBrowser for help on using the repository browser.