Jump to content

Dialog Builder 6 exporting Python - bug


GioPet

Recommended Posts

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 by GioPet
Link to comment

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]

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...