Commits

Arne Babenhauserheide  committed 6f94597

added a switch for emacs 23.1/24 (emacs or emacsclient) and python <2.7/≥2.7

  • Participants
  • Parent commits 3864efa

Comments (0)

Files changed (1)

File qxembed-emacs.py

 from PyQt4.QtGui import QApplication
 from PyQt4.QtCore import QProcess, SIGNAL, SLOT
 
-from sys import argv
+from sys import argv, version_info
+
+if version_info > (2,7,0, 'final', 0): 
+    from subprocess import check_output
+    out = check_output(["emacs", "--version"])
+    n = len("GNU Emacs ")
+    vers = float(out[n:n+4])
+else:
+    vers = None
 
 app = QApplication(argv)
 
 container = QX11EmbedContainer()
+container.resize(670, 630)
 container.show()
 
-def resize():
-    container.resize(670, 630)
-container.resize_ = resize
-
 process = QProcess(container)
-print container.winId()
 args = ["--parent-id", str(container.winId())]
-#process.start("emacs", args)
-process.start("emacsclient-emacs-24", args)
+if vers >= 24: 
+    process.start("emacsclient", args)
+elif vers is None or vers >= 23.1: 
+    process.start("emacs", args)
+else:
+    print "You need at least emacs 23.1 for embedding emacs via XEmbed."
+    exit()
 container.connect(container, SIGNAL("clientClosed()"), app.quit)
-container.connect(container, SIGNAL("clientIsEmbedded()"), container.resize_)
+#container.connect(container, SIGNAL("clientIsEmbedded()"), container.resize_)
 container.connect(container, SIGNAL("error(QX11EmbedContainer::Error)"), app.quit)
 status = app.exec_()
 process.close()
-
-
-### Self Test == Run the Program ###
-
-if __name__ == "__main__":
-    pass