Skip to content

Commit

Permalink
Make modal dialog the default again in combrowse.main()
Browse files Browse the repository at this point in the history
.. 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.
  • Loading branch information
kxrob committed Aug 11, 2022
1 parent 5c0b62b commit 475b1ef
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Pythonwin/pywin/framework/toolmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
),
("Edit Python Path", "from pywin.tools import regedit;regedit.EditRegistry()"),
("COM Makepy utility", "from win32com.client import makepy;makepy.main()"),
("COM Browser", "from win32com.client import combrowse;combrowse.main()"),
(
"COM Browser",
"from win32com.client import combrowse;combrowse.main(modal=False)",
),
(
"Trace Collector Debugging tool",
"from pywin.tools import TraceCollector;TraceCollector.MakeOutputWindow()",
Expand Down
12 changes: 5 additions & 7 deletions com/win32com/client/combrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Command Prompt
Use the command *"python.exe catbrowse.py"*. This will display
Use the command *"python.exe combrowse.py"*. This will display
display a fairly small, modal dialog.
Pythonwin
Expand Down Expand Up @@ -591,17 +591,15 @@ def GetSubList(self):
return ret


def main(modal=False):
def main(modal=True, mdi=False):
from pywin.tools import hierlist

root = HLIRoot("COM Browser")
if "app" in sys.modules:
# do it in a window
if mdi and "pywin.framework.app" in sys.modules:
# do it in a MDI window
browser.MakeTemplate()
browser.template.OpenObject(root)
else:
# list=hierlist.HierListWithItems( root, win32ui.IDB_BROWSER_HIER )
# dlg=hierlist.HierDialog("COM Browser",list)
dlg = browser.dynamic_browser(root)
if modal:
dlg.DoModal()
Expand All @@ -611,7 +609,7 @@ def main(modal=False):


if __name__ == "__main__":
main()
main(modal=win32api.GetConsoleTitle())

ni = pythoncom._GetInterfaceCount()
ng = pythoncom._GetGatewayCount()
Expand Down
5 changes: 2 additions & 3 deletions com/win32com/client/tlbrowse.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,7 @@ def GetTemplate(self):
except:
pass
dlg = TypeBrowseDialog(fname)
try:
win32api.GetConsoleTitle()
if win32api.GetConsoleTitle(): # empty string w/o console
dlg.DoModal()
except:
else:
dlg.CreateWindow(win32ui.GetMainFrame())

0 comments on commit 475b1ef

Please sign in to comment.