Re: [Pyobjc-dev] Subclassing from NibClassBuilder-generated files
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-12-02 21:04:53
|
On 2 dec 2003, at 1:40, Jordan Krushen wrote: > Going through the tutorial and other examples, I'm wondering why the > (implied) common practice is to directly edit the > NibClassBuilder-generated python files. Will regeneration upon > changes in IB destroy changes to the file? Regeneration would destroy changes to the file, that's why we never regenerate the file :-). The generated file doesnt' contain code that cannot be easily typed into it, you only have to add methods that implement the actions and that can easily done by hand. > > I tried creating another file for CurrencyConverter which imported > CurrencyConverter.py's classes (which were renamed to _Converter and > _ConverterController), subclassed them, and attempted to call > runEventLoop() from there, but the runtime is complaining that the > classes already exist: > > File "Resources/t.py", line 6, in ? > class Converter(_Converter): > objc.error: Class already exists in Objective-C runtime In Objective-C, and therefore also in PyObjC, classnames must be unique across your entire program (including linked frameworks/libraries). That's why renaming doesn't work. > If this is in fact a problem, how does one get around this? Perhaps > I'm just used to wxglade, where it exports classes to be used > elsewhere, knowing that they will be generated often. If it's > something else, please let me know :) I usually generate the file once and update it by hand later on, often I don't bother with generating the first generation file and create it manually as well. I don't know wxglade but at least some code-generation tools used to create files that contained the actual code for building the widgets. The files generated by nibclassbuilder only contain the placeholders for the methods that implement the application logic, the NIB file contains a 'pickled' version of the actual widgets. Ronald |