Search code examples
pythonqtlisppysidehy

Creating objects in Hy


I've looked all over the documentation of Hy, but I can't find a way to create objects anywhere. More specifically, I'm trying to follow this PySide tutorial, but converting each command to Hy, and I'm not sure how to do app = QApplication(sys.argv) in Hy. Would appreciate all the help possible.


Solution

  • In Python you create an object by calling the constructor, a function that has the same name as the class. The exact same applies in Hy.

    (import sys)
    (import [PySide.QtGui [QApplication]])
    
    (setf app (QApplication sys.argv))
    

    Notes:

    • You assign the object created with setf
    • Be sure to import all the necessary modules