# Python Bindings using SWIG

**URL:** <https://forum.juce.com/t/python-bindings-using-swig/13655>\
**Category:** General JUCE discussion\
**Created:** [October 1, 2014, 2:03pm UTC](https://forum.juce.com/t/python-bindings-using-swig/13655 "2014-10-01T14:03:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![synth](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@synth](https://forum.juce.com/u/synth)\
**Post date:** [October 1, 2014, 2:03pm UTC](https://forum.juce.com/t/python-bindings-using-swig/13655/1 "2014-10-01T14:03:04Z")

</div>

Hi,

&nbsp;

I got the code for&nbsp;the python bindings using the SWIG library as mentioned here :&nbsp;http://www.juce.com/forum/topic/python-bindings?page=1

I have updated the interface file for the latest JUCE source code:

&nbsp;

JUCE.i :

&nbsp;

```
​%module(directors="1", autodoc="1") JUCE // #pragma SWIG nowarn=362 %include exception.i %include implicit.i %include typemaps.i // "#define Rectangle" in juce.h generates errors in WinGDI.h ! /\* %{ #if defined(\_WIN32) || defined(\_\_WIN32\_\_) || defined(\_\_CYGWIN\_\_) #include \<windows.h\> BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul\_reason\_for\_call, LPVOID lpReserved) { &nbsp;&nbsp; &nbsp;return TRUE; } #endif // defined(\_WIN32) || defined(\_\_WIN32\_\_) || defined(\_\_CYGWIN\_\_) %} \*/ %{ #include \<juce\juce.h\> %} %extend StringArray { &nbsp;&nbsp; &nbsp;const String &\_\_getitem\_\_(int subscript) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return self-\>StringArray::operator[](subscript); &nbsp;&nbsp; &nbsp;} } %rename(RelativeTimeCopy) RelativeTime::RelativeTime(const RelativeTime&) throw(); %rename(TimeCopy) Time::Time(const RelativeTime&) throw(); %rename(ArrayCopy) Array::Array(const Array&) throw(); %rename(BitArrayCopy) BitArray::BitArray(const BitArray&) throw(); %rename(OwnedArrayCopy) OwnedArray::OwnedArray(const OwnedArray&) throw(); %rename(ReferenceCountedArrayCopy) ReferenceCountedArray::ReferenceCountedArray(const ReferenceCountedArray&) throw(); %rename(ReferenceCountedObjectCopy) ReferenceCountedObject::ReferenceCountedObject(const ReferenceCountedObject&) throw(); %rename(SortedSetCopy) SortedSet::SortedSet(const SortedSet&) throw(); %rename(FileCopy) File::File(const File&) throw(); %rename(FileSearchPathCopy) FileSearchPath::FileSearchPath(const FileSearchPath&) throw(); %rename(URLCopy) URL::URL(const URL&) throw(); %rename(StringCopy) String::String(const String&) throw(); %rename(StringArrayCopy) StringArray::StringArray(const StringArray&) throw(); %rename(StringPairArrayCopy) StringPairArray::StringPairArray(const StringPairArray&) throw(); %rename(AudioSampleBufferCopy) AudioSampleBuffer::AudioSampleBuffer(const AudioSampleBuffer&); %rename(MidiMessageCopy) MidiMessage::MidiMessage(const MidiMessage&) throw(); %rename(MidiMessageSequenceCopy) MidiMessageSequence::MidiMessageSequence(const MidiMessageSequence&); // %rename(ColourCopy) Colour::Colour(const Colour&) throw(); %rename(EdgeTableCopy) EdgeTable::EdgeTable(const EdgeTable&) throw(); %rename(JustificationCopy) Justification::Justification(const Justification&) throw(); // %rename(GlyphArrangementCopy) GlyphArrangement::GlyphArrangement(cont GlyphArrangement&); %rename(TextLayoutCopy) TextLayout::TextLayout(const TextLayout&); %rename(TypefaceCopy) Typeface::Typeface(const Typeface&); %rename(AffineTransformCopy) AffineTransform::AffineTransform(const AffineTransform&) throw(); %rename(LineCopy) Line::Line(const Line&); %rename(PathCopy) Path::Path(const Path&) throw(); %rename(PointCopy) Point::Point(const Point&); %rename(RectangleList) RectangleList::RectangleList(const RectangleList&) throw(); %rename(ImageCopy) Image::Image(const Image&); %rename(KeyPressCopy) KeyPress::KeyPress(const KeyPress&) throw(); %rename(ModifierKeysCopy) ModifierKeys::ModifierKeys(const ModifierKeys&) throw(); %rename(PopupMenuCopy) PopupMenu::PopupMenu(const PopupMenu&); %rename(MouseCursorCopy) MouseCursor::MouseCursor(const MouseCursor&) throw(); // Thread::yield --\> yield is a python keyword ! %rename(handover) yield; %rename(ComponentWithName) Component::Component(const String& componentName) throw(); %{ typedef MidiMessageSequence::MidiEventHolder MidiEventHolder; %} %{ typedef ZipFile::ZipEntry ZipEntry; %} namespace JUCE { &nbsp;&nbsp; &nbsp;class MouseHoverDetector &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;public: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;MouseHoverDetector (const int hoverTimeMillisecs = 400); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;virtual ~MouseHoverDetector(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;void setHoverTimeMillisecs (const int newTimeInMillisecs); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;void setHoverComponent (Component\* const newSourceComponent); &nbsp;&nbsp; &nbsp;protected: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;virtual void mouseHovered (int mouseX, int mouseY) = 0; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;virtual void mouseMovedAfterHover() = 0; &nbsp;&nbsp; &nbsp;}; } // // // DIRECTORS // %{ #include \<iostream\> %} %feature("director"); %feature("director:except") { &nbsp;&nbsp; &nbsp;if($error) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PyErr\_Print(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw Swig::DirectorMethodException(); &nbsp;&nbsp; &nbsp;} } %exception { &nbsp;&nbsp; &nbsp;try &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$action; &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;catch(const Swig::DirectorException &e) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SWIG\_exception(SWIG\_UnknownError, e.getMessage()); &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;catch(const std::runtime\_error &e) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SWIG\_exception(SWIG\_RuntimeError, e.what()); &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;catch(const std::exception &e) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SWIG\_exception(SWIG\_UnknownError, e.what()); &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;catch(...) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;SWIG\_exception(SWIG\_UnknownError, ""); &nbsp;&nbsp; &nbsp;} } // Some problems with variable length arguments %feature("nodirector") OutputStream; %feature("nodirector") FileOutputStream; %feature("nodirector") GZIPCompressorOutputStream; %feature("nodirector") MemoryOutputStream; %feature("nodirector") LookAndFeel; %feature("nodirector") NativeDesktopWindow; // Those classes are abstract but SWIG generates constructors wrappers anyway ... %ignore InputStream::InputStream; %ignore AudioFormatReader::AudioFormatReader; // Not implemented in JUCE 1.9 (bug ?) %ignore SystemStats::getEnvironmentVariable; %ignore ThreadPoolJob::setJobName; %ignore Label::actionListenerCallback; #define \_WIN32 // VisualStudio specific keywords #define \_\_int64 long long #define \_\_fastcall // JUCE specific keywords #define forcedinline #define inline\_assembly %include \<juce/juce.h\> /////////////////////////////////////////////////////////////////////////////// // // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; JUCE CORE // /////////////////////////////////////////////////////////////////////////////// // // // JUCE CORE - BASICS // // defines juce\_UseDebuggingNewOperator --\> include it first %include \<juce/modules/juce\_core/memory/juce\_Memory.h\> // @see http://www.swig.org/Doc1.3/Preprocessor.html#Preprocessor\_nn5 // %include \<juce/modules/juce\_core/system/juce\_PlatformDefs.h\> %include \<juce/modules/juce\_core/memory/juce\_Atomic.h\> //%include \<juce/modules/juce\_core/basics/juce\_DataConversions.h\> %include \<juce/modules/juce\_core/logging/juce\_FileLogger.h\> %include \<juce/modules/juce\_core/logging/juce\_Logger.h\> %include \<juce/modules/juce\_core/maths/juce\_MathsFunctions.h\> %include \<juce/modules/juce\_core/maths/juce\_Random.h\> %include \<juce/modules/juce\_core/time/juce\_RelativeTime.h\> %include \<juce/modules/juce\_core/memory/juce\_Singleton.h\> %include \<juce/modules/juce\_core/system/juce\_StandardHeader.h\> %include \<juce/modules/juce\_core/system/juce\_SystemStats.h\> %include \<juce/modules/juce\_core/time/juce\_Time.h\> // // // JUCE CORE - CONTAINERS // %include \<juce/modules/juce\_core/containers/juce\_Array.h\> %include \<juce/modules/juce\_core/containers/juce\_ArrayAllocationBase.h\> //%include \<juce/modules/juce\_core/containers/juce\_BitArray.h\> %include \<juce/modules/juce\_core/containers/juce\_ElementComparator.h\> %apply String &OUTPUT { String &destString }; // MemoryBlockBase::to64BitEncoding // AlignedMemoryBlock::AlignedMemoryBlock(int) is ambiguous !! // %include \<juce/modules/juce\_core/containers/juce\_MemoryBlock.h\> %clear String &destString; %include \<juce/modules/juce\_core/containers/juce\_OwnedArray.h\> %include \<juce/modules/juce\_core/containers/juce\_ReferenceCountedArray.h\> %include \<juce/modules/juce\_core/memory/juce\_ReferenceCountedObject.h\> %include \<juce/modules/juce\_core/containers/juce\_SortedSet.h\> %include \<juce/modules/juce\_core/containers/juce\_SparseSet.h\> //%include \<juce/modules/juce\_core/containers/juce\_VoidArray.h\> // // // JUCE CORE - CRYPTOGRAPHY // %include \<juce/modules/juce\_cryptography/encryption/juce\_BlowFish.h\> %include \<juce/modules/juce\_cryptography/hashing/juce\_MD5.h\> %include \<juce/modules/juce\_cryptography/encryption/juce\_Primes.h\> %include \<juce/modules/juce\_cryptography/encryption/juce\_RSAKey.h\> // // // JUCE CORE - IO // %include \<juce/modules/juce\_core/streams/juce\_InputStream.h\> %include \<juce/modules/juce\_core/streams/juce\_OutputStream.h\> %include \<juce/modules/juce\_core/files/juce\_DirectoryIterator.h\> %include \<juce/modules/juce\_core/files/juce\_File.h\> %include \<juce/modules/juce\_core/files/juce\_FileInputStream.h\> %include \<juce/modules/juce\_core/files/juce\_FileOutputStream.h\> %include \<juce/modules/juce\_core/files/juce\_FileSearchPath.h\> %include \<juce/modules/juce\_core/network/juce\_URL.h\> %include \<juce/modules/juce\_core/streams/juce\_BufferedInputStream.h\> %include \<juce/modules/juce\_core/zip/juce\_GZIPCompressorOutputStream.h\> %include \<juce/modules/juce\_core/zip/juce\_GZIPDecompressorInputStream.h\> %include \<juce/modules/juce\_core/streams/juce\_MemoryInputStream.h\> %include \<juce/modules/juce\_core/streams/juce\_MemoryOutputStream.h\> %include \<juce/modules/juce\_core/streams/juce\_SubregionStream.h\> // Zlib don t compile // %include \<juce/modules/juce\_core/io/streams/zlib/deflate.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/infblock.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/infcodes.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/inffast.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/inffixed.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/inftrees.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/infutil.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/trees.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/zconf.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/zlib.h\> // %include \<juce/modules/juce\_core/io/streams/zlib/zutil.h\> // // // JUCE CORE - MISC // %include \<juce/modules/juce\_core/time/juce\_PerformanceCounter.h\> //%include \<juce/modules/juce\_core/misc/juce\_PlatformUtilities.h\> %include \<juce/modules/juce\_core/misc/juce\_Uuid.h\> %include \<juce/modules/juce\_core/zip/juce\_ZipFile.h\> // // // JUCE CORE - TEXT // %include \<pystrings.swg\> %fragment(SWIG\_AsPtr\_frag(String),"header", fragment="SWIG\_AsCharPtrAndSize") { &nbsp;&nbsp; &nbsp;SWIGINTERN int SWIG\_AsPtr(String)(PyObject\* obj, String \*\*val) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;static swig\_type\_info \*string\_info = SWIG\_TypeQuery("String \*"); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String \*vptr; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(SWIG\_ConvertPtr(obj, (void\*\*)&vptr, string\_info, 0) != -1) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(val) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\*val = vptr; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return SWIG\_OLDOBJ; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PyErr\_Clear(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;char \*buf = 0; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;size\_t size = 0; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(SWIG\_AsCharPtrAndSize(obj, &buf, &size)) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(buf) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(val) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\*val = new String(buf, size - 1); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return SWIG\_NEWOBJ; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PyErr\_Clear(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(val) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PyErr\_SetString(PyExc\_TypeError,"a string is expected"); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return 0; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;} } %fragment(SWIG\_From\_frag(String),"header", fragment="SWIG\_FromCharArray") { &nbsp;&nbsp; &nbsp;SWIGINTERNSHORT PyObject \*SWIG\_From(String)(const String &s) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return SWIG\_FromCharArray((const char\*)(s), s.length()); &nbsp;&nbsp; &nbsp;} } %fragment(SWIG\_AsVal\_frag(String),"header", fragment=SWIG\_AsPtr\_frag(String)) { &nbsp;&nbsp; &nbsp;SWIGINTERN int SWIG\_AsVal(String)(PyObject\* obj, String \*val) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String \*s; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;int res = SWIG\_AsPtr(String)(obj, &s); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(res && s) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(val) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\*val = \*s; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(res == SWIG\_NEWOBJ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;delete s; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return res; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(val) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PyErr\_SetString(PyExc\_TypeError,"a string is expected"); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return 0; &nbsp;&nbsp; &nbsp;} } %typemap\_asptrfromn(SWIG\_CCode(STRING), String); %include \<juce/modules/juce\_core/text/juce\_String.h\> %include \<juce/modules/juce\_core/text/juce\_LocalisedStrings.h\> %include \<juce/modules/juce\_core/text/juce\_StringArray.h\> %include \<juce/modules/juce\_core/text/juce\_StringPairArray.h\> //%include \<juce/modules/juce\_core/text/juce\_TextFunctions.h\> %include \<juce/modules/juce\_core/xml/juce\_XmlDocument.h\> %include \<juce/modules/juce\_core/xml/juce\_XmlElement.h\> // // // JUCE CORE - THREADS // %include \<juce/modules/juce\_core/threads/juce\_CriticalSection.h\> %include \<juce/modules/juce\_core/threads/juce\_InterProcessLock.h\> %include \<juce/modules/juce\_core/threads/juce\_Process.h\> %include \<juce/modules/juce\_core/threads/juce\_ReadWriteLock.cpp\> %include \<juce/modules/juce\_core/threads/juce\_ReadWriteLock.h\> %include \<juce/modules/juce\_core/threads/juce\_ScopedLock.h\> %include \<juce/modules/juce\_core/threads/juce\_ScopedReadLock.h\> %include \<juce/modules/juce\_core/threads/juce\_ScopedWriteLock.h\> %include \<juce/modules/juce\_core/threads/juce\_Thread.h\> %include \<juce/modules/juce\_core/threads/juce\_ThreadPool.h\> %include \<juce/modules/juce\_core/threads/juce\_TimeSliceThread.h\> %include \<juce/modules/juce\_core/threads/juce\_WaitableEvent.h\> /////////////////////////////////////////////////////////////////////////////// // // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;JUCE APPLICATION FRAMEWORK // /////////////////////////////////////////////////////////////////////////////// %{ &nbsp;&nbsp; &nbsp;class PyJUCEApplication : public JUCE::JUCEApplication &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;public: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PyJUCEApplication(const JUCE::String &applicationName, PyObject \*initialiseCallback, PyObject \*shutdownCallback) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;: applicationName(applicationName), initialiseCallback(initialiseCallback), shutdownCallback(shutdownCallback) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;virtual void initialise(const String &commandLineParameters) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!initialiseCallback || (initialiseCallback == Py\_None)) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyObject \*args = ::PyTuple\_New(0); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!args) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw this; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyObject \*result = ::PyObject\_Call(initialiseCallback, args, NULL); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!result && ::PyErr\_Occurred()) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyErr\_Print(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw this; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Py\_XDECREF(args); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Py\_XDECREF(result); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;virtual void shutdown() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!shutdownCallback || (shutdownCallback == Py\_None)) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyObject \*args = ::PyTuple\_New(0); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!args) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw this; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyObject \*result = ::PyObject\_Call(shutdownCallback, args, NULL); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if(!result && ::PyErr\_Occurred()) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyErr\_Print(); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw this; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Py\_XDECREF(args); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Py\_XDECREF(result); &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;const String getApplicationName() &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return applicationName; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;private: &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;JUCE::String applicationName; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;::PyObject \*initialiseCallback, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \*shutdownCallback; &nbsp;&nbsp; &nbsp;}; %} %inline %{ &nbsp;&nbsp; &nbsp;void mainLoop(const JUCE::String &applicationName, ::PyObject \*initialiseCallback = 0, ::PyObject \*shutdownCallback = 0) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;JUCE::JUCEApplication::main(0, new PyJUCEApplication(applicationName, initialiseCallback, shutdownCallback)); &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;void quit(bool useMaximumForce = false) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;JUCE::JUCEApplication::quit(useMaximumForce); &nbsp;&nbsp; &nbsp;} %} // We use our own Application // %include \<juce/modules/juce\_appframework/application/juce\_Application.h\> %include \<juce/modules/juce\_events/messages/juce\_DeletedAtShutdown.h\> %include \<juce/modules/juce\_gui\_basics/keyboard/juce\_SystemClipboard.h\> // // // JUCE APPLICATION FRAMEWORK - EVENTS // %include \<juce/modules/juce\_events/messages/juce\_Message.h\> %include \<juce/modules/juce\_events/messages/juce\_MessageListener.h\> %include \<juce/modules/juce\_events/broadcasters/juce\_ActionBroadcaster.h\> %include \<juce/modules/juce\_events/broadcasters/juce\_ActionListener.h\> //%include \<juce/modules/juce\_appframework/events/juce\_ActionListenerList.h\> %include \<juce/modules/juce\_events/broadcasters/juce\_AsyncUpdater.h\> %include \<juce/modules/juce\_events/broadcasters/juce\_ChangeBroadcaster.h\> %include \<juce/modules/juce\_events/broadcasters/juce\_ChangeListener.h\> //%include \<juce/modules/juce\_appframework/events/juce\_ChangeListenerList.h\> %include \<juce/modules/juce\_events/messages/juce\_MessageManager.h\> %include \<juce/modules/juce\_events/timers/juce\_Timer.h\> // // // JUCE APPLICATION FRAMEWORK - AUDIO // //%include \<juce/modules/juce\_appframework/audio/juce\_ASIOAudioIODevice.h\> %include \<juce/modules/juce\_audio\_devices/audio\_io/juce\_AudioIODevice.h\> %include \<juce/modules/juce\_audio\_basics/buffers/juce\_AudioSampleBuffer.h\> %include \<juce/modules/juce\_audio\_basics/midi/juce\_MidiFile.h\> %include \<juce/modules/juce\_audio\_devices/midi\_io/juce\_MidiInput.h\> %apply int &OUTPUT { int &hours, int &minutes, int &seconds, int &frames }; // MidiMessage::getFullFrameParameters %apply SmpteTimecodeType &OUTPUT { SmpteTimecodeType &timecodeType }; // MidiMessage::getFullFrameParameters %apply int &INOUT { int &hours, int &minutes, int &seconds, int &frames }; // MidiMessage::isMidiMachineControlGoto&nbsp; %apply int &INOUT { int &numBytesUsed }; // MidiMessage::readVariableLengthVal %include \<juce/modules/juce\_audio\_basics/midi/juce\_MidiMessage.h\> %clear int &numBytesUsed; %clear int &hours, int &minutes, int &seconds, int &frames; %clear SmpteTimecodeType &timecodeType; %clear int &hours, int &minutes, int &seconds, int &frames; %include \<juce/modules/juce\_audio\_basics/midi/juce\_MidiMessageSequence.h\> %apply float &OUTPUT { float &leftVol, float &rightVol }; // MidiOutput::getVolume %include \<juce/modules/juce\_audio\_devices/midi\_io/juce\_MidiOutput.h\> %clear float &leftVol, float &rightVol; %include \<juce/modules/juce\_audio\_formats/format/juce\_AudioFormat.h\> %apply float &OUTPUT { float& lowestLeft, float& highestLeft, float& lowestRight, float& highestRight }; %include \<juce/modules/juce\_audio\_formats/format/juce\_AudioFormatReader.h\> %clear float& lowestLeft, float& highestLeft, float& lowestRight, float& highestRight; %include \<juce/modules/juce\_audio\_formats/codecs/juce\_AiffAudioFormat.h\> %nodefault; // SWIG don t see AudioCDReader already has a contructor with arguments %include \<juce/modules/juce\_audio\_devices/audio\_cd/juce\_AudioCDReader.h\> %makedefault; %include \<juce/modules/juce\_audio\_formats/format/juce\_AudioFormatWriter.h\> %include \<juce/modules/juce\_audio\_formats/format/juce\_AudioSubsectionReader.h\> %include \<juce/modules/juce\_audio\_formats/codecs/juce\_WavAudioFormat.h\> %include \<juce/modules/juce\_audio\_basics/sources/juce\_AudioSource.h\> %include \<juce/modules/juce\_audio\_basics/sources/juce\_PositionableAudioSource.h\> %include \<juce/modules/juce\_audio\_formats/format/juce\_AudioFormatReaderSource.h\> %include \<juce/modules/juce\_audio\_devices/sources/juce\_AudioSourcePlayer.h\> %include \<juce/modules/juce\_audio\_devices/sources/juce\_AudioTransportSource.h\> %include \<juce/modules/juce\_audio\_basics/sources/juce\_BufferingAudioSource.h\> %include \<juce/modules/juce\_audio\_basics/sources/juce\_MixerAudioSource.h\> %include \<juce/modules/juce\_audio\_basics/sources/juce\_ResamplingAudioSource.h\> // // // JUCE APPLICATION FRAMEWORK - GUI (GRAPHICS) // %extend AffineTransform { &nbsp;&nbsp; &nbsp;AffineTransform \_\_mul\_\_(AffineTransform \*x) &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return self-\>followedBy(\*x); &nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;%pythoncode &nbsp;&nbsp; &nbsp;{ &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;def transform(self, point): &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;(x, y) = point &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;self.transformPoint(xp, yp) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return (x, y) &nbsp;&nbsp; &nbsp;} }; %implicit(Justification, int); %inline { int get(const Justification &justification) { &nbsp;&nbsp; &nbsp;return justification.getFlags(); } } //%include \<juce/modules/juce\_appframework/gui/graphics/brushes/juce\_Brush.h\> //%include \<juce/modules/juce\_appframework/gui/graphics/brushes/juce\_GradientBrush.h\> //%include \<juce/modules/juce\_appframework/gui/graphics/brushes/juce\_ImageBrush.h\> //%include \<juce/modules/juce\_appframework/gui/graphics/brushes/juce\_SolidColourBrush.h\> %apply float &OUTPUT { float& hue, float& saturation, float& brightness }; %include \<juce/modules/juce\_graphics/colour/juce\_Colour.h\> %clear float& hue, float& saturation, float& brightness; %include \<juce/modules/juce\_graphics/colour/juce\_Colours.h\> %include \<juce/modules/juce\_graphics/colour/juce\_PixelFormats.h\> %include \<juce/modules/juce\_graphics/geometry/juce\_EdgeTable.h\> %apply float &OUTPUT { int &originX, int &originY }; // Graphics::getUnderlyingImage&nbsp; %include \<juce/modules/juce\_graphics/juce\_Graphics.h\> %clear int &originX, int &originY; %apply int &OUTPUT { int &x, int &y }; // Justification::applyToRectangle&nbsp; %include \<juce/modules/juce\_graphics/placement/juce\_Justification.h\> %clear int &x, int &y; %include \<juce/modules/juce\_graphics/effects/juce\_ImageEffectFilter.h\> %include \<juce/modules/juce\_graphics/effects/juce\_DropShadowEffect.h\> %include \<juce/modules/juce\_graphics/effects/juce\_GlowEffect.h\> //%include \<juce/modules/juce\_graphics/effects/juce\_ReduceOpacityEffect.h\> %include \<juce/modules/juce\_graphics/fonts/juce\_Font.h\> %apply float &OUTPUT { float &left, float &top, float &right, float &bottom }; %include \<juce/modules/juce\_graphics/fonts/juce\_GlyphArrangement.h\> %clear float &left, float &top, float &right, float &bottom; %include \<juce/modules/juce\_graphics/fonts/juce\_TextLayout.h\> %include \<juce/modules/juce\_graphics/fonts/juce\_Typeface.h\> %apply float &INOUT { float& x, float& y }; %include \<juce/modules/juce\_graphics/geometry/juce\_AffineTransform.h\> %clear float& x, float& y; %apply float &OUTPUT { float &intersectionX, float &intersectionY }; // Line::intersects %include \<juce/modules/juce\_graphics/geometry/juce\_Line.h\> %clear float &intersectionX, float &intersectionY; %apply float &OUTPUT { float &x, float &y, float &w, float &h }; // Path::getBounds %include \<juce/modules/juce\_graphics/geometry/juce\_Path.h\> %clear float &x, float &y, float &w, float &h; %include \<juce/modules/juce\_graphics/geometry/juce\_PathIterator.h\> %include \<juce/modules/juce\_graphics/geometry/juce\_PathStrokeType.h\> %include \<juce/modules/juce\_graphics/geometry/juce\_Point.h\> %apply int &INOUT { int &x1, int &y1, int &w1, int &h1 }; // Rectangle::intersectRectangles %include \<juce/modules/juce\_graphics/geometry/juce\_Rectangle.h\> %clear int &x1, int &y1, int &w1, int &h1; %include \<juce/modules/juce\_graphics/geometry/juce\_RectangleList.h\> // SWIG can t parse libjpeg headers // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/deflate.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jconfig.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jdct.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jdhuff.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jerror.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jinclude.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jmemsys.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jmorecfg.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jpegint.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jpeglib.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/jpglib/jversion.h\> // Don t use GIFLoader directly in an application // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/juce\_GIFLoader.h\> // SWIG can t parse libpng headers // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/pnglib/png.h\> // %include \<juce/modules/juce\_appframework/gui/graphics/imaging/image\_file\_formats/pnglib/pngconf.h\> %include \<juce/modules/juce\_graphics/images/juce\_Image.h\> %include \<juce/modules/juce\_graphics/images/juce\_ImageCache.h\> %include \<juce/modules/juce\_graphics/images/juce\_ImageConvolutionKernel.h\> %include \<juce/modules/juce\_graphics/images/juce\_ImageFileFormat.h\> // // // JUCE APPLICATION FRAMEWORK - GUI (COMPONENTS) // %include \<juce/modules/juce\_gui\_basics/keyboard/juce\_KeyListener.h\> %include \<juce/modules/juce\_gui\_basics/keyboard/juce\_KeyPress.h\> %include \<juce/modules/juce\_gui\_basics/commands/juce\_KeyPressMappingSet.h\> %include \<juce/modules/juce\_gui\_basics/keyboard/juce\_ModifierKeys.h\> %apply JUCE::Colour &OUTPUT { JUCE::Colour &text, JUCE::Colour &background, JUCE::Colour &highlightText, JUCE::Colour &highlightBackground }; // LookAndFeel::getPopupMenuColours %apply int &OUTPUT { int &idealWidth, int &idealHeight }; // LookAndFeel::getIdealPopupMenuItemSize %apply JUCE::Colour &OUTPUT { JUCE::Colour &background, JUCE::Colour &textColour, JUCE::Colour &outlineColour, JUCE::Colour &buttonColour, JUCE::Colour &popupBackground, JUCE::Colour &popupText, JUCE::Colour &popupHighlight }; // LookAndFeel::getComboBoxColours // LookAndFeel::getComboBoxFonts // LookAndFeel::getSliderColours&nbsp; // LookAndFeel::getSliderFont&nbsp; // LookAndFeel::getTooltipSize&nbsp; %include \<juce/modules/juce\_gui\_basics/lookandfeel/juce\_LookAndFeel.h\> %clear JUCE::Colour &background, JUCE::Colour &textColour, JUCE::Colour &outlineColour, JUCE::Colour &buttonColour, JUCE::Colour &popupBackground, JUCE::Colour &popupText, JUCE::Colour &popupHighlight; %clear int &idealWidth, int &idealHeight; %clear JUCE::Colour &text, JUCE::Colour &background, JUCE::Colour &highlightText, JUCE::Colour &highlightBackground; %include \<juce/modules/juce\_gui\_basics/mouse/juce\_MouseCursor.h\> %include \<juce/modules/juce\_gui\_basics/mouse/juce\_MouseEvent.h\> // Nested class MouseHoverDetector::HoverDetectorInternal is not supported by SWIG parser // Use a "manual" proxy class // %include \<juce/modules/juce\_appframework/gui/gui\_components/mouse/juce\_MouseHoverDetector.h\> %include \<juce/modules/juce\_gui\_basics/mouse/juce\_MouseListener.h\> %apply RectangleList &OUTPUT { RectangleList &result }; %include \<juce/modules/juce\_gui\_basics/components/juce\_Component.h\> %clear RectangleList &result; %include \<juce/modules/juce\_gui\_basics/components/juce\_ComponentListener.h\> %apply int &OUTPUT { int &x, int &y }; // Desktop::getMousePosition, Desktop::getLastMouseDownPosition %include \<juce/modules/juce\_gui\_basics/components/juce\_Desktop.h\> %clear int &x, int &y; //%include \<juce/modules/juce\_gui\_basics/menus/juce\_MenuBar.h\> %include \<juce/modules/juce\_gui\_basics/menus/juce\_PopupMenu.h\> //%include \<juce/modules/juce\_gui\_basics/menus/juce\_PopupMenuCustomComponent.h\> %include \<juce/modules/juce\_gui\_basics/misc/juce\_BubbleComponent.h\> %include \<juce/modules/juce\_gui\_extra/misc/juce\_ColourSelector.h\> %include \<juce/modules/juce\_gui\_basics/widgets/juce\_ComboBox.h\> %include \<juce/modules/juce\_gui\_basics/mouse/juce\_DragAndDropContainer.h\> %include \<juce/modules/juce\_gui\_basics/mouse/juce\_DragAndDropTarget.h\> %include \<juce/modules/juce\_gui\_basics/misc/juce\_DropShadower.h\> %include \<juce/modules/juce\_gui\_basics/filebrowser/juce\_FilenameComponent.h\> %include \<juce/modules/juce\_gui\_basics/widgets/juce\_ListBox.h\> //%include \<juce/modules/juce\_gui\_basics/widgets/juce\_OpenGLComponent.h\> //%include \<juce/modules/juce\_gui\_basics/widgets/juce\_SimpleListBox.h\> %include \<juce/modules/juce\_gui\_extra/misc/juce\_KeyMappingEditorComponent.h\> %include \<juce/modules/juce\_gui\_basics/widgets/juce\_TextEditor.h\> %include \<juce/modules/juce\_gui\_basics/widgets/juce\_Label.h\> %include \<juce/modules/juce\_video/playback/juce\_QuickTimeMovieComponent.h\> //%include \<juce/modules/juce\_gui\_basics/widgets/juce\_ResizerComponent.h\> %include \<juce/modules/juce\_gui\_basics/layout/juce\_ScrollBar.h\> %include \<juce/modules/juce\_gui\_basics/widgets/juce\_Slider.h\> %include \<juce/modules/juce\_gui\_basics/layout/juce\_TabbedComponent.h\> %include \<juce/modules/juce\_gui\_basics/windows/juce\_ThreadWithProgressWindow.h\> %include \<juce/modules/juce\_gui\_basics/windows/juce\_ToolTipWindow.h\> %include \<juce/modules/juce\_gui\_basics/widgets/juce\_TreeView.h\> %include \<juce/modules/juce\_gui\_basics/layout/juce\_Viewport.h\> // SWIG bug ! // %include \<juce/modules/juce\_appframework/gui/gui\_components/buttons/juce\_Button.h\> %include \<juce/modules/juce\_gui\_basics/buttons/juce\_ArrowButton.h\> %include \<juce/modules/juce\_gui\_basics/buttons/juce\_HyperlinkButton.h\> %include \<juce/modules/juce\_gui\_basics/buttons/juce\_ImageButton.h\> %include \<juce/modules/juce\_gui\_basics/buttons/juce\_ShapeButton.h\> %include \<juce/modules/juce\_gui\_basics/buttons/juce\_TextButton.h\> %include \<juce/modules/juce\_gui\_basics/buttons/juce\_ToggleButton.h\> %include \<juce/modules/juce\_gui\_basics/windows/juce\_AlertWindow.h\> %include \<juce/modules/juce\_gui\_basics/windows/juce\_DialogWindow.h\> %include \<juce/modules/juce\_gui\_basics/filebrowser/juce\_FileChooser.h\> %apply int &OUTPUT { int &x, int &y, int &w, int &h }; // NativeDesktopWindow::getBounds %apply int &OUTPUT { int &leftThickness, int &topThickness, int &bottomThickness, int &rightThickness }; // NativeDesktopWindow::getFrameSize //%include \<juce/modules/juce\_gui\_basics/windows/juce\_NativeDesktopWindow.h\> %clear int &x, int &y, int &w, int &h; %clear int &leftThickness, int &topThickness, int &bottomThickness, int &rightThickness; %include \<juce/modules/juce\_gui\_extra/misc/juce\_SplashScreen.h\> // // // JUCE APPLICATION FRAMEWORK - TOOLBAG // %include \<juce/modules/juce\_data\_structures/app\_properties/juce\_PropertiesFile.h\> %include \<juce/modules/juce\_data\_structures/undomanager/juce\_UndoableAction.h\> %include \<juce/modules/juce\_data\_structures/undomanager/juce\_UndoManager.h\>
```

---

<div class="post-metadata">

**Author:** ![synth](https://avatars.discourse-cdn.com/v4/letter/s/e9a140/32.png) [@synth](https://forum.juce.com/u/synth)\
**Post date:** [October 1, 2014, 2:06pm UTC](https://forum.juce.com/t/python-bindings-using-swig/13655/2 "2014-10-01T14:06:53Z")

</div>

I get an error when running swig :

juce\modules\juce\_core\memory\juce\_Atomic.h(73) : Warning 362: operator= ignored  
juce\modules\juce\_core\memory\juce\_Atomic.h(76) : Warning 362: operator= ignored  
juce\modules\juce\_core\memory\juce\_Atomic.h(79) : Warning 321: 'set' conflicts with a built-in name in python  
juce\modules\juce\_core\memory\juce\_Atomic.h(91) : Warning 383: operator++ ignored  
juce\modules\juce\_core\memory\juce\_Atomic.h(94) : Warning 384: operator-- ignored  
juce\modules\juce\_core\memory\juce\_Atomic.h(146) : Error: Syntax error in input(3).

&nbsp;

This seems to do with the&nbsp;JUCE\_ALIGN macro at juce\_Atomic.h(146) . I wonder if anyone knows how to ensure proper macro processing with SWIG.

---

<div class="post-metadata">

**Author:** ![jamiebullock](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jamiebullock/32/459_2.png) [@jamiebullock](https://forum.juce.com/u/jamiebullock)\
**Post date:** [November 15, 2018, 10:49am UTC](https://forum.juce.com/t/python-bindings-using-swig/13655/3 "2018-11-15T10:49:36Z")

</div>

@synth did you get this working in the end? I notice there is [a git repo](https://github.com/abhijitnandy2011/PyJuce), what’s the status of that?

Jamie

---

<div class="post-metadata">

**Author:** ![stpope](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stpope/32/3002_2.png) [@stpope](https://forum.juce.com/u/stpope)\
**Post date:** [August 10, 2020, 8:05pm UTC](https://forum.juce.com/t/python-bindings-using-swig/13655/4 "2020-08-10T20:05:07Z")

</div>

I’m also trying to make a SWIG interface to JUCE for python scripting of JUCE DSP networks.  
Does anyone have any advice?  
I worked through most of the start-up issues, and had to comment out several c++11-specific things, but can’t get the compile commands set up so that I don’t get a load of syntax errors in juce\_MathsFunctions.h about the type specs missing.  
I used to use SWIG with JUCE 4 with no problems.

---

<div class="post-metadata">

**Author:** ![stpope](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stpope/32/3002_2.png) [@stpope](https://forum.juce.com/u/stpope)\
**Post date:** [August 11, 2020, 12:22am UTC](https://forum.juce.com/t/python-bindings-using-swig/13655/5 "2020-08-11T00:22:32Z")

</div>

> [@stpope](#):
>
> he start-up issues, and had to comment out several c++11-specific things, but can’t get the compile commands set up so that I don’t get a load of syntax errors in juce\_MathsFunctions.h abou

So, is there anybody out there using SWIG with JUCE?
