parentless modal dialog size problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

parentless modal dialog size problem

Karsten Hilbert
Hi,

I am having trouble properly sizing parentless modal dialogs.
The class used can be seen in the attached file generated
with wxGlade.

Despite my setting an initial size, and despite my Python
code seeing that size (via .GetSize()) right before the
ShowModal() call the dialog will eventually be displayed
maximized.

This is on Debian/wxp4/py3.

        # parent is None
        dlg = cGenericListSelectorDlg(parent, -1, title = caption, msg = msg)
        ... a bunch of setup not size-related ...
        print('before showing dlg', dlg.GetSize(), 'parent:', parent)
        btn_pressed = dlg.ShowModal()
        print('after showing dlg', dlg.GetSize())

Output:

        before showing dlg (640, 500) parent: None
        after showing dlg (1374, 772)

The cGenericListSelectorDlg wrapping wxgGenericListSelectorDlg does this:

        from Gnumed.wxGladeWidgets import wxgGenericListSelectorDlg

        class cGenericListSelectorDlg(wxgGenericListSelectorDlg.wxgGenericListSelectorDlg):
                """A dialog holding a list and a few buttons to act on the items."""

                def __init__(self, *args, **kwargs):

                        try:
                                msg = kwargs['msg']
                                del kwargs['msg']
                        except KeyError:
                                msg = None

                        try:
                                title = kwargs['title']
                                if not title.startswith('GMd: '):
                                        kwargs['title'] = 'GMd: %s' % title
                        except KeyError:
                                kwargs['title'] = 'GMd: %s' % self.__class__.__name__

                        wxgGenericListSelectorDlg.wxgGenericListSelectorDlg.__init__(self, *args, **kwargs)

                        self.message = msg

                        self.left_extra_button = None
                        self.middle_extra_button = None
                        self.right_extra_button = None

                        self.refresh_callback = None # called when new/edit/delete callbacks return True (IOW were not cancelled)
                        self.new_callback = None # called when NEW button pressed, no argument passed in
                        self.edit_callback = None # called when EDIT button pressed, data of topmost selected item passed in
                        self.delete_callback = None # called when DELETE button pressed, data of topmost selected item passed in

                        self.can_return_empty = False
                        self.ignore_OK_button = False # by default do show/use the OK button

                        self.select_callback = None # called when an item is selected, data of topmost selected item passed in
                        self._LCTRL_items.select_callback = self._on_list_item_selected_in_listctrl


Does anyone have an idea which direction I should look ?

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

wxgGenericListSelectorDlg.py (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: parentless modal dialog size problem

Karsten Hilbert
On Wed, Jul 11, 2018 at 08:51:00PM +0200, Karsten Hilbert wrote:

> I am having trouble properly sizing parentless modal dialogs.
> The class used can be seen in the attached file generated
> with wxGlade.

Note that I am not using wx.DIALOG_NO_PARENT because a) it is
advised against in the docs for .Modal() dialogs and b) this
class is used elsewhere in the application where it does have
a parent (the top level window).

I just checked: it actually does not make a difference
whether parent is None or the top level window, the dialog is
maximized despite .GetSize() saying 640/500 right before
.ShowModal().

One thing that comes to mind is that the other type of dialog
often used in GNUmed contains a grid sizer with editing
widgets and *not* a list inside the main sizer such as the
problematic one. Those grid sizer dialogs don't show the size
problem ...

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.