[vlc-commits] Fix python-qt example against py3k

xantares 09 git at videolan.org
Sat Mar 7 18:47:11 CET 2015


vlc/python | branch: master | xantares 09 <xantares09 at hotmail.com> | Sat Mar  7 18:45:48 2015 +0100| [b177c90fcd847c021637a80faf2f15187b26120b] | committer: Olivier Aubert

Fix python-qt example against py3k

Signed-off-by: Olivier Aubert <contact at olivieraubert.net>

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=b177c90fcd847c021637a80faf2f15187b26120b
---

 examples/qtvlc.py |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/examples/qtvlc.py b/examples/qtvlc.py
index 2d427e7..28d8925 100755
--- a/examples/qtvlc.py
+++ b/examples/qtvlc.py
@@ -20,7 +20,7 @@
 #
 
 import sys
-import user
+import os.path
 import vlc
 from PyQt4 import QtGui, QtCore
 
@@ -131,12 +131,14 @@ class Player(QtGui.QMainWindow):
         """Open a media file in a MediaPlayer
         """
         if filename is None:
-            filename = QtGui.QFileDialog.getOpenFileName(self, "Open File", user.home)
+            filename = QtGui.QFileDialog.getOpenFileName(self, "Open File", os.path.expanduser('~'))
         if not filename:
             return
 
         # create the media
-        self.media = self.instance.media_new(unicode(filename))
+        if sys.version < '3':
+            filename = unicode(filename)
+        self.media = self.instance.media_new(filename)
         # put the media in the media player
         self.mediaplayer.set_media(self.media)
 
@@ -150,7 +152,7 @@ class Player(QtGui.QMainWindow):
         # this is platform specific!
         # you have to give the id of the QFrame (or similar object) to
         # vlc, different platforms have different functions for this
-        if sys.platform == "linux2": # for Linux using the X Server
+        if sys.platform.startswith('linux'): # for Linux using the X Server
             self.mediaplayer.set_xwindow(self.videoframe.winId())
         elif sys.platform == "win32": # for Windows
             self.mediaplayer.set_hwnd(self.videoframe.winId())



More information about the vlc-commits mailing list