Setting dialog position

I want a user to be able to move a dialog (that I have created using wx.dialog) to a convenient place on their screen and thereafter have it open in that position. How do I achieve this? Thanks.

well, don’t shed the floating position & next time simply use it :flushed:

I assume that is very clever but how does it answer the question?

I simply kept the ‘answer’ as vaguely as your question (context sensitive); the nearest class of your wx.dialog is wx.Dialog which is a subclass of wx.Window and that one has more methods than I can remember (getter & setter orgy); of course, between the get and set you’ll have to employ some data persistency (another orgy) and so on…

If you think the question vague, please ask for more information. How does flippancy contribute anything?

I am aware of GetPosition() but it seems to return the initial position of the dialog, not the position when it is closed. It returns (68, 87) if no position is set when the dialog is created. If a position is set then that is returned regardless of where the dialog actually resides.

That’s probably because IIRC (some) dialogs are but a thin
wrapper around native platform dialogs so wxPython(Widgets)
perhaps doesn’t have the code (or powers) to ask the desktop
manager for the current coordinates, and so returns a best?
guess …

Karsten

Quite often on here someone with a helping mind begged for a piece of coding in order to give a useful hint and I have tried it twice in this thread alone - so I don’t think it was all flippancy
In all my Frames and Dialogs I do ‘pos = window.GetPosition().Get()’ at quit, save it in sqlite3 and do right at the beginning of the constructor ‘window.SetPosition((px, py))’!
so far no problem whatsoever :sweat_smile:
P.S.
of course, if you are talking about these ‘popup’ dialogues you may use the reflection ‘mro’ like

    @staticmethod
    def show_help(parent, text):
        with wx.MessageDialog(
                parent, text, 'About', wx.OK | wx.CENTRE) as md:
            print(md.__class__.__mro__)
            md.ShowModal()

only to find out that ‘wx._core.Window’ is actually a super class of the dialogue, but the method you are looking for doesn’t work: I would imagine the magic is in the ‘wx._core’ (although, personally, I’ve no need for positioning pop-ups: just place them bang into the middle of the parent, maybe flashing)