Skip to content

Commit

Permalink
Make modal dialog the default again in combrowse.main() (mhammond#1924)
Browse files Browse the repository at this point in the history
* 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 (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.

* 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)
  • Loading branch information
kxrob committed Aug 13, 2022
1 parent b233706 commit a22bd62
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 18 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ jobs:
run: |
python --version
pip --version
pip install --upgrade setuptools wheel
# XXX With setuptools 63.4.3 .. 64.0.0 the scintilla nmake won't compile (
# setuptools.msvc._msvc14_get_vc_env() won't get the VC\INCLUDE into os.environ)
# Lets see if this will be fixed again in higher versions
pip install --upgrade setuptools<=63.2.0 wheel
- name: Build and install
run: |
Expand Down Expand Up @@ -80,7 +83,7 @@ jobs:
run: |
python --version
pip --version
pip install --upgrade setuptools wheel
pip install --upgrade setuptools<=63.2.0 wheel
- name: Obtain ARM64 library files
run: |
Expand Down
6 changes: 4 additions & 2 deletions Pythonwin/Scintilla/makefile_pythonwin
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ all: ..\pywin\scintilla\scintillacon.py Scintilla


clean:
cd win32 && $(MAKE) /$(MAKEFLAGS) -f scintilla_vc6.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) clean & cd..
cd win32 && $(MAKE) /$(MAKEFLAGS) -f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) clean & cd..

Scintilla:
@if not exist $(DIR_O) md $(DIR_O)
@if not exist $(DIR_BIN) md $(DIR_BIN)
@set DEBUG=$(DEBUG)
@set CL=$(CL) /nologo
@set LINK=$(LINK) /nologo
@cd win32 && $(MAKE) /$(MAKEFLAGS) /f scintilla_vc6.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) LEXCOMPONENT=$(SCINTILLA_DLL) COMPONENT=dummy $(SCINTILLA_DLL) & cd..
where cl
set INCLUDE
@cd win32 && $(MAKE) /$(MAKEFLAGS) /f scintilla.mak DIR_BIN=$(SUB_DIR_BIN) DIR_O=$(SUB_DIR_O) LEXCOMPONENT=$(SCINTILLA_DLL) COMPONENT=dummy $(SCINTILLA_DLL) & cd..

..\pywin\scintilla\scintillacon.py: Include\Scintilla.h Include\SciLexer.h
@if not exist $(DIR_PYTHON)\tools\scripts\h2py.py echo ***** Can't find h2py.py in '$(DIR_PYTHON)\tools\scripts - please pass DIR_PYTHON to this script *******
Expand Down
8 changes: 5 additions & 3 deletions Pythonwin/Scintilla/win32/scintilla.mak
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ CC=cl
RC=rc
LD=link

CXXFLAGS=-Zi -TP -W4 -Zc:forScope -Zc:wchar_t -D_CRT_SECURE_NO_DEPRECATE=1
#~ -Zc:forScope -Zc:wchar_t -D_CRT_SECURE_NO_DEPRECATE=1
CXXFLAGS=-Zi -TP -W4
# For something scary:-Wp64
CXXDEBUG=-Od -MTd -DDEBUG
CXXNDEBUG=-O1 -MT -DNDEBUG -GL
CXXNDEBUG=-O1 -MT -DNDEBUG
#~ -GL
NAME=-Fo
LDFLAGS=-OPT:NOWIN98 -OPT:REF -LTCG -DEBUG
#~ LDFLAGS=-OPT:NOWIN98 -OPT:REF -LTCG -DEBUG
LDDEBUG=
LIBS=KERNEL32.lib USER32.lib GDI32.lib IMM32.lib OLE32.LIB
NOLOGO=-nologo
Expand Down
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())
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,13 @@ def _build_scintilla(self):
cwd = os.getcwd()
old_env = os.environ.copy()
os.chdir(path)
print("-- _build_scintilla INCLUDE old:", os.environ.get("INCLUDE"))
if not self.compiler.initialized:
print("-- _build_scintilla compiler.initialize()")
self.compiler.initialize()
os.environ["INCLUDE"] = os.pathsep.join(self.compiler.include_dirs)
os.environ["LIB"] = os.pathsep.join(self.compiler.library_dirs)
print("-- _build_scintilla INCLUDE new:", os.environ.get("INCLUDE"))
try:
cmd = [nmake, "/nologo", "/f", makefile] + makeargs
self.compiler.spawn(cmd)
Expand Down

0 comments on commit a22bd62

Please sign in to comment.