GioPet Posted December 9, 2015 Share Posted December 9, 2015 (edited) I have used DB6 to generate a simple layout and exported it for Python. The dialog runs perfectly in when I export it in VS, but python reports errors with the following functions: dialog = vs.CreateLayout( GetStr('dialog_title'), True, GetStr('ok_button'), GetStr('cancel_button') ) ERROR: TypeError: Can't content 'int' object to str implicitly vs.CreateGroupBox( dialog, kUnnamed4, GetStr(kUnnamed4), TRUE ) ERROR: NameError: global name 'TRUE' is no defined These appear to be bugs in how DB6 exports the Python code. For anyone who has the same problem, I solved it with the following: dialog = vs.CreateLayout( GetStr(3), True, 'ok_button', 'cancel_button') vs.CreateGroupBox( dialog, kUnnamed4, GetStr(kUnnamed4), True ) Edited December 9, 2015 by GioPet Quote Link to comment
Dieter @ DWorks Posted December 9, 2015 Share Posted December 9, 2015 When using Python for your plugin, you could use DLibrary to easily create dialogs and work with them very very easily. All you need to do is define a dialog through an xml file: (All data- attributes are automatically binded to the ViewModel properties, so no need anymore to call getters and setters on dialog controls, no need to set controls up, no need to play with placements, .... All is done with this one file, while your values will live in the viewmodel!) MODULES data-items="modules" data-value="excerpt" height="25" width="50" data-selected-items="selected_modules"/> GESELECTEERDE MODULES data-items="selected_modules" data-value="config" data-available-items="available_configs"/> And you can use it like this: class ModuleDialogXmlFile(AbstractActivePlugInDialogXmlFile): def __init__(self): super().__init__('Module', ActivePlugInType.OBJECT) class ModuleViewModel(object): # The ViewModel class for a Module item .... class ModuleDialogViewModel(object): # The ViewModel class for the dialog. .... def on_module_dialog(): # Get the plugin parameters. parameters = Parameters() # Create the dialog viewmodel, which will hold the data. dialog_view_model = ModuleDialogViewModel(parameters.module_config) # Run the dialog (from the file with the viewmodel) if Dialog(ModuleDialogXmlFile(), dialog_view_model).show(): # When the user hits ok, save the modules to the plugin parameters. parameters.module_config = [module.config.value for module in dialog_view_model.modules] Quote Link to comment
GioPet Posted December 9, 2015 Author Share Posted December 9, 2015 Wow, this is really useful, so much easier.. thanks for sharing Dieter G Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.