MySQL Forums
Forum List  »  MySQL Workbench

MForms boxes rendering random indents
Posted by: Karsten Wutzke
Date: March 14, 2019 11:05AM

Hello,

I am facing a problem with a Python plugin UI that randomly changes the MForms panel/box indent on subsequent dialog displays.

When executing the plugin a dialog is displayed:

https://pasteboard.co/I5pggx5.png

This is the correct rendering (the _ _ before the sub check boxes is just to show there is some intended indent).

Now closing the dialog and redisplaying the dialog results in random indents for all 4 sub boxes below the one with the dropdown box:

Wrongly rendered dialogs:

https://pasteboard.co/I5pgPNe.png
https://pasteboard.co/I5ph8Ea.png
https://pasteboard.co/I5phnPC.png
https://pasteboard.co/I5phwCE.png
https://pasteboard.co/I5pibOi.png

Notice the random left indents with all other images.

**QUESTION**:

What's wrong here? Why is this happening?

Here's the code for a full example. You only have to hook this into a Python plugin:

def ask_for_options():

    # main tab
    main_bx = create_relationships_box()

    # build tab view
    main_tv = TabView(False)
    main_tv.add_page(main_bx, 'Relationships')
    main_tv.set_active_tab(0)
    main_tv.relayout()

    # buttons
    export_btn = Button()
    export_btn.set_text('Export')

    cancel_btn = Button()
    cancel_btn.set_text('Cancel')

    # button box
    buttons_bx = Box(True)
    buttons_bx.set_spacing(5)
    buttons_bx.set_padding(3)

    # uses OS-specific positioning
    Utilities.add_end_ok_cancel_buttons(buttons_bx, export_btn, cancel_btn)

    # main + button boxes
    content_bx = Box(False)
    content_bx.set_spacing(5)
    content_bx.set_padding(5)

    content_bx.add(main_tv, True, True)
    content_bx.add(buttons_bx, False, True)

    # create centered options dialog
    form = Form(None, FormDialogFrame)
    form.set_title('Export Options')
    form.set_content(content_bx)
    form.set_size(500, 260)
    form.center()

    all_valid = False

    # check validity on return
    while not all_valid and form.run_modal(export_btn, cancel_btn):
        all_valid = True

    form.close()  # needed?

    return all_valid


def create_relationships_box():

    collection_full_class_name_se = Selector()

    # collection class name (x-to-many)
    collection_full_class_name_bx = Box(True)

    collection_full_class_name = Label('Default collection class for @XToMany:')
    collection_full_class_name.set_wrap_text(False)

    collection_type_names = ['Set', 'Collection', 'List', 'Map']

    collection_full_class_name_se.add_items(collection_type_names)
    collection_full_class_name_se.set_value(collection_type_names[0])

    collection_full_class_name_bx.add(collection_full_class_name, False, True)
    collection_full_class_name_bx.add(collection_full_class_name_se, False, True)

    # special collection mapping annotations
    special_collection_mappings_bx = Box(True)

    special_collection_mappings_ck = CheckBox()
    special_collection_mappings_ck.set_text('Detect special collection mapping annotations in foreign key comments')
    special_collection_mappings_ck.set_active(True)

    special_collection_mappings_bx.add(special_collection_mappings_ck, False, True)

    # special collection mapping writablility
    writable_on_order_or_map_key_column_bx = Box(True)

    writable_on_order_or_map_key_column_ck = CheckBox()
    writable_on_order_or_map_key_column_ck.set_text('Put writable onto @OrderColumn or @MapKeyColumn if detected')
    writable_on_order_or_map_key_column_ck.set_active(True)

    # add dummy indentation
    add_indentation_to(writable_on_order_or_map_key_column_bx)  # dummy indentation label
    writable_on_order_or_map_key_column_bx.add(writable_on_order_or_map_key_column_ck, False, True)

    # join tables
    pure_join_tables_bx = Box(True)

    pure_join_tables_as_many_to_many_ck = CheckBox()
    pure_join_tables_as_many_to_many_ck.set_text('Map pure join tables as @ManyToMany + @JoinTable')
    pure_join_tables_as_many_to_many_ck.set_active(True)

    pure_join_tables_bx.add(pure_join_tables_as_many_to_many_ck, False, True)

    # join table order columns
    join_table_special_collection_mappings_bx = Box(True)

    join_table_special_collection_mappings_ck = CheckBox()
    join_table_special_collection_mappings_ck.set_text('Consider special collection mapping annotations for pure join table detection')
    join_table_special_collection_mappings_ck.set_active(True)

    # add dummy indentation
    add_indentation_to(join_table_special_collection_mappings_bx)  # dummy indentation label
    join_table_special_collection_mappings_bx.add(join_table_special_collection_mappings_ck, False, True)

    collection_mapping_bx = Box(False)
    collection_mapping_bx.set_spacing(2)
    collection_mapping_bx.set_padding(3)
    collection_mapping_bx.set_homogeneous(True)
    collection_mapping_bx.add(collection_full_class_name_bx, False, True)
    collection_mapping_bx.add(special_collection_mappings_bx, False, True)
    collection_mapping_bx.add(writable_on_order_or_map_key_column_bx, False, True)
    collection_mapping_bx.add(pure_join_tables_bx, False, True)
    collection_mapping_bx.add(join_table_special_collection_mappings_bx, False, True)

    collection_mapping_pn = Panel(TitledGroupPanel)
    collection_mapping_pn.set_title('Collection Mapping')
    collection_mapping_pn.add(collection_mapping_bx)

    tab_bx = Box(False)
    tab_bx.set_spacing(3)
    tab_bx.set_padding(3)

    tab_bx.add(collection_mapping_pn, False, True)

    return tab_bx


def add_indentation_to(bx):
    """Add a (somewhat faked) indentation label to a box."""
    bx.add(Label('_ _'), False, True)

Can the team please look into this issue?

I have no idea why this is happening and the code looks correct to me.

Here's a plugin stub:

@ModuleInfo.plugin("wb.catalog.util.custom_plugin",
                   caption="Custom Plugin...",
                   input=[wbinputs.currentCatalog()],
                   pluginMenu='Catalog')
@ModuleInfo.export(grt.INT, grt.classes.db_Catalog)
def custom_plugin(catalog):

    print "Executing custom_plugin(catalog)..."

    ask_for_options()
    return 0

Please help.

Karsten

Options: ReplyQuote


Subject
Views
Written By
Posted
MForms boxes rendering random indents
684
March 14, 2019 11:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.