Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/mhammond/pywin32 into clang…
Browse files Browse the repository at this point in the history
…-format
  • Loading branch information
Avasam committed Apr 9, 2024
2 parents 20012a8 + cef71aa commit 6b8fe7b
Show file tree
Hide file tree
Showing 58 changed files with 294 additions and 620 deletions.
12 changes: 1 addition & 11 deletions Pythonwin/Win32uiHostGlue.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,7 @@ inline BOOL Win32uiHostGlue::DynamicApplicationInit(const TCHAR *cmd, const TCHA
(*pfnPyInit)();
}

// In 3.7 and up it's not necessary to call PyEval_InitThreads. In all versions
// it's safe to call multiple times.
#if PY_VERSION_HEX < 0x03070000
void(__cdecl * pfnPyEval_InitThreads)(void);
pfnPyEval_InitThreads = (void(__cdecl *)(void))GetProcAddress(hModCore, "PyEval_InitThreads");
CHECK_PFN(pfnPyEval_InitThreads);
pfnPyEval_InitThreads();
#endif

PyObject *(*pPyImport_ImportModule)(const char *name) =
(PyObject * (*)(const char *name)) GetProcAddress(hModCore, "PyImport_ImportModule");
PyObject* (*pPyImport_ImportModule)(const char *name) = (PyObject* (*)(const char *name))GetProcAddress(hModCore, "PyImport_ImportModule");
CHECK_PFN(pPyImport_ImportModule);
PyObject *(*pPyObject_GetAttrString)(PyObject *o, const char *attr_name) =
(PyObject * (*)(PyObject * o, const char *attr_name)) GetProcAddress(hModCore, "PyObject_GetAttrString");
Expand Down
8 changes: 4 additions & 4 deletions Pythonwin/pywin/Demos/cmdserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ def ServerThread(myout, cmd, title, bCloseOnEnd):

# assist for reloading (when debugging) - use only 1 tracer object,
# else a large chain of tracer objects will exist.
# try:
# writer
# except NameError:
# writer=ThreadWriter()
try:
writer
except NameError:
writer = ThreadWriter()
if __name__ == "__main__":
import demoutils

Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/pywin/Demos/fontdemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def SetFont(self, new_font):
# Change font on the fly
self.font = win32ui.CreateFont(new_font)
# redraw the entire client window
selfInvalidateRect(None)
self.InvalidateRect(None)

def OnSize(self, params):
lParam = params[3]
Expand Down
24 changes: 16 additions & 8 deletions Pythonwin/pywin/Demos/ocx/msoffice.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
import win32con
import win32ui
import win32uiole
from pywin.mfc import docview, object, window
from pywin.mfc import activex, docview, object, window
from win32com.client import gencache

# WordModule = gencache.EnsureModule('{00020905-0000-0000-C000-000000000046}', 1033, 8, 0)
# if WordModule is None:
# raise ImportError, "Microsoft Word version 8 does not appear to be installed."


class OleClientItem(object.CmdTarget):
def __init__(self, doc):
Expand Down Expand Up @@ -122,6 +118,17 @@ def __init__(self, doc=None):
# Dont call base class doc/view version...

def Create(self, title, rect=None, parent=None):
WordModule = gencache.EnsureModule(
"{00020905-0000-0000-C000-000000000046}", 1033, 8, 0
)
if WordModule is None:
raise ImportError(
"Microsoft Word version 8 does not appear to be installed."
)

# WordModule.Word doesn't exist in WordModule, WordModule.Words does, but CreateControl still fails
class MyWordControl(activex.Control, WordModule.Word): ...

style = win32con.WS_CHILD | win32con.WS_VISIBLE | win32con.WS_OVERLAPPEDWINDOW
self._obj_.CreateWindow(None, title, style, rect, parent)

Expand All @@ -141,11 +148,12 @@ def Demo():
docName = None
if len(sys.argv) > 1:
docName = win32api.GetFullPathName(sys.argv[1])
OleTemplate().OpenDocumentFile(None)
OleTemplate().OpenDocumentFile(docName)

# ActiveX not currently working
# f = WordFrame(docName)
# f.Create("Microsoft Office")

# f = WordFrame(docName)
# f.Create("Microsoft Office")

if __name__ == "__main__":
Demo()
6 changes: 0 additions & 6 deletions Pythonwin/pywin/Demos/ocx/ocxtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,6 @@ def test2():
d = None


def test3():
d = TestCOMMDialog(MakeDlgTemplate())
d.DoModal()
d = None


def testall():
test1()
test2()
Expand Down
6 changes: 0 additions & 6 deletions Pythonwin/pywin/debugger/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import sys


# Some cruft to deal with the Pythonwin GUI booting up from a non GUI app.
def _MakeDebuggerGUI():
app.InitInstance()


isInprocApp = -1


Expand Down
8 changes: 4 additions & 4 deletions Pythonwin/pywin/dialogs/ideoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,25 +115,25 @@ def OnFormatTitle(self, command, code):
fmt = self.GetFormat(interact.formatTitle)
if fmt:
formatTitle = fmt
SaveFontPreferences()
interact.SaveFontPreferences()

def OnFormatInput(self, command, code):
global formatInput
fmt = self.GetFormat(formatInput)
if fmt:
formatInput = fmt
SaveFontPreferences()
interact.SaveFontPreferences()

def OnFormatOutput(self, command, code):
global formatOutput
fmt = self.GetFormat(formatOutput)
if fmt:
formatOutput = fmt
SaveFontPreferences()
interact.SaveFontPreferences()

def OnFormatError(self, command, code):
global formatOutputError
fmt = self.GetFormat(formatOutputError)
if fmt:
formatOutputError = fmt
SaveFontPreferences()
interact.SaveFontPreferences()
4 changes: 3 additions & 1 deletion Pythonwin/pywin/framework/dlgappcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ def OnInitDialog(self):
def OnPaint(self):
if not self.IsIconic():
return self._obj_.OnPaint()
dc, paintStruct = self.BeginPaint()
self.DefWindowProc(win32con.WM_ICONERASEBKGND, dc.GetHandleOutput(), 0)
left, top, right, bottom = self.GetClientRect()
left = (right - win32api.GetSystemMetrics(win32con.SM_CXICON)) >> 1
top = (bottom - win32api.GetSystemMetrics(win32con.SM_CYICON)) >> 1
hIcon = win32ui.GetApp().LoadIcon(self.iconId)
self.GetDC().DrawIcon((left, top), hIcon)
dc.DrawIcon((left, top), hIcon)
self.EndPaint(paintStruct)

# Only needed to provide a minimized icon (and this seems
# less important under win95/NT4
Expand Down
11 changes: 10 additions & 1 deletion Pythonwin/pywin/framework/interact.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ def SavePreference(prefName, prefValue):
win32ui.WriteProfileVal(sectionProfile, prefName, prefValue)


def SaveFontPreferences():
win32ui.WriteProfileVal(sectionProfile, valueFormatTitle, str(formatTitle))
win32ui.WriteProfileVal(sectionProfile, valueFormatInput, str(formatInput))
win32ui.WriteProfileVal(sectionProfile, valueFormatOutput, str(formatOutput))
win32ui.WriteProfileVal(
sectionProfile, valueFormatOutputError, str(formatOutputError)
)


def GetPromptPrefix(line):
ps1 = sys.ps1
if line[: len(ps1)] == ps1:
Expand Down Expand Up @@ -333,7 +342,7 @@ def Init(self):
)
)
else:
sys.stderr.write(banner)
sys.stderr.write(self.banner)
rcfile = os.environ.get("PYTHONSTARTUP")
if rcfile:
import __main__
Expand Down
1 change: 1 addition & 0 deletions Pythonwin/pywin/framework/mdi_pychecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import re
import sys
import time
from functools import reduce

import win32api
import win32con
Expand Down
4 changes: 2 additions & 2 deletions Pythonwin/pywin/scintilla/configui.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def OnOK(self):


def test():
page = ColorEditorPropertyPage()
sheet = pywin.mfc.dialog.PropertySheet("Test")
page = ScintillaFormatPropertyPage()
sheet = dialog.PropertySheet("Test")
sheet.AddPage(page)
sheet.CreateWindow()
18 changes: 0 additions & 18 deletions Pythonwin/pywin/scintilla/scintillacon.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
# Generated by h2py from Include\scintilla.h


# Included from BaseTsd.h
def HandleToUlong(h):
return HandleToULong(h)


def UlongToHandle(ul):
return ULongToHandle(ul)


def UlongToPtr(ul):
return ULongToPtr(ul)


def UintToPtr(ui):
return UIntToPtr(ui)


INVALID_POSITION = -1
SCI_START = 2000
SCI_OPTIONAL_START = 3000
Expand Down
10 changes: 5 additions & 5 deletions Pythonwin/pywin/tools/TraceCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ def _StopThread(self):
def Close(self):
self._StopThread()
winout.WindowOutput.Close(self)
# def OnViewDestroy(self, frame):
# return winout.WindowOutput.OnViewDestroy(self, frame)
# def Create(self, title=None, style = None):
# rc = winout.WindowOutput.Create(self, title, style)
return rc
# def OnViewDestroy(self, frame):
# return winout.WindowOutput.OnViewDestroy(self, frame)
# def Create(self, title=None, style = None):
# rc = winout.WindowOutput.Create(self, title, style)
# return rc


def MakeOutputWindow():
Expand Down
3 changes: 0 additions & 3 deletions Pythonwin/win32thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,6 @@ static PyObject *ui_thread_create_thread(PyObject *self, PyObject *args)
CWinThread *pThread = GetCWinThreadPtr(self);
if (!pThread)
return NULL;
#if PY_VERSION_HEX < 0x03070000
PyEval_InitThreads();
#endif
GUI_BGN_SAVE;
BOOL ok = pThread->CreateThread(createFlags, stackSize);
GUI_END_SAVE;
Expand Down
Loading

0 comments on commit 6b8fe7b

Please sign in to comment.