-
Notifications
You must be signed in to change notification settings - Fork 812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix modeless COM browser dialog #1895
Conversation
.. after d10d559 (non-modal COM browser inside PythonWin IDE). combrowse.py may be run / called from outside PythonWin as a standalone GUI in a console (mhammond#1895). Run the browser modeless when called from PythonWin tool menu or when run as script inside PythonWin GUI. Fix similar startup of tlbrowse.py: win32api.GetConsoleTitle() meanwhile returns empty string when no console.
.. after d10d559 (non-modal COM browser inside PythonWin IDE). combrowse.py may be run / called from outside PythonWin as a standalone GUI in a console (mhammond#1895). Run the browser modeless when called from PythonWin tool menu or when run as script inside PythonWin GUI. Fix similar startup of tlbrowse.py: win32api.GetConsoleTitle() meanwhile returns empty string when no console.
I think the problem in that SO question just came from me making the browser default modal in d10d559. I was not aware (or forgot) that combrowse.py may be run / called from a shell outside PythonWin as a standalone mini GUI. The low-level |
* Make modal dialog the default again in combrowse.main() .. after d10d559 (non-modal COM browser inside PythonWin IDE). combrowse.py may be run / called from outside PythonWin as a standalone GUI in a console (#1895). Run the browser modeless when called from PythonWin tool menu or when run as script inside PythonWin GUI. Fix similar startup of tlbrowse.py: win32api.GetConsoleTitle() meanwhile returns empty string when no console. * Make scintilla build again on github CI * freeze setuptools<=63.2.0 for now: XXX With setuptools 63.4.3 .. 64.0.0 the scintilla nmake run won't compile. (setuptools.msvc._msvc14_get_vc_env() won't get the VC\INCLUDE into os.environ.) Let's see if this will be fixed again in higher versions of setuptools. * print the cl.exe full path and environ INCLUDE during _build_scintilla() / nmake for future tracking * use and fixup scintilla.mak instead of scintilla_vc6.mak (which is outdated lacks some dependencies)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CristiFati any chance you can check if the problem still exists after #1924? There are some nice improvements here, but is seems like we might as well avoid do_modeless
if we can.
Thank you for feedbacks. I didn't explicitly stated it in the description, but do_modeless is a (lame) workaround (gainarie). Will check it, but give me some time. I will post another comment when done. |
I completed my tests. This is the current situation (build with latest changes):
Now regarding the commits:
|
I guess you are trying to run For curiosity I run it from a console script "pseudo-modeless" with minial non-MFC "main message loop" in a further MessageBox - works surprisingly:
|
I finally got the modeless purpose. So setting it from a script (like in SO) is not supported. I think it's fine. As a note: changing mdi has no effect. Yes! the message box trick works! |
Heh - yeah, or a trivial |
A follow-up for #1894.
Fixes [SO]: win32com.client combrowse.main() (Python Object Browser) is not responding Python 3.9.
As I mentioned I am neither a COM expert nor an MFC enthusiast, and this part of PyWin32 is new to me, although I've seen some unorthodox (to me) stuff here :).
The actual fix is the 3rd commit. It's the best compromise I found. After the crash fix, ShowWindow wasn't starting the dialog message loop, so calling RunModalLoop was required. But for some reason when dialog was closed with IDCANCEL (Esc or by clicking the X button), the dialog disappeared, but the loop didn't exit, so Ctrl + Break was required in the console in order to kill the process (this didn't happen for IDOK (Enter) - which worked fine).
That's why EndModalLoop is needed in OnCancel (even if [MS.Docs]: CDialog::OnCancel instructs to call DestroyWindow for modeless dialogs, that doesn't work (probably to PyWin32 extra wrapping layer)).
Overriding RunModalLoop would have been the elegant solution, but dialog.Dialog doesn't have it, so the do_modal wrapper was born (its naming style suggests that it doesn't come from MFC).
Modeless dialog works now (as seen in the image from the answer).
I don't know, maybe in the future, this functionality could be moved up to Dialog, but that's a task far from trivial, which would require extensive testing.