Re: [python-win32] Pywin32 local variable
On 12/08/21 9:17 pm, Salih KUYUMCU via python-win32 wrote: I create a String value before the methods and try to return these values in another method. I get the problem local variable 'xxx' referenced before assignment. It sounds like you may want to store the value in an attribute of an object instead of a local variable. If you show us your code and the exact error message you're getting, we will be able to help you better. -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Using win32gui.FindWindow() results in black or white screen
On 4/06/21 4:59 am, Dennis Lee Bieber wrote: Many video apps don't display in "Windows". The window you grabbed is a basically a hole through which the graphics chips are rendering and are not available, and the render is not part of the window itself. When grabbing the entire screen, you are getting the screen buffer which includes the video. Maybe you could find the size and position of the window, and then extract the relevant part from a full screen capture? -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
[python-win32] Registering COM servers doesn't work out of the box any more
I recently tried to install a COM server written in Python and ran into a small problem. The procedure I used was this: 1. Install Python 3 using the standard Windows installer, as Administrator, for All Users, adding Python to the path. 2. pip install pypiwin32 3. Run my script for registering the COM server, which calls win32com.server.register.UseCommandLine. This didn't work, and the reason turned out to be that the InprocServer32 registry was just the filename of the dll, rather than a full pathname. When I changed it to an absolute pathname, the server worked fine. The standard win32com code for server registration seems to be assuming that pythoncom.dll and winctypes.dll have been installed in C:\Windows\System32. However, pip doesn't put them there, and I get the impression that installing all DLLs there is no longer considered best practice. I found an old sourceforge bug report about this: https://sourceforge.net/p/pywin32/bugs/393/ which suggests a one-line change to win32com\server\register.py to address this problem, but it was closed with works-for-me. Am I right that using a relative pathname for InprocServer32 is no longer the right thing to do? Should I reopen this issue? -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] python-win32 Digest, Vol 165, Issue 3
Tim Roberts wrote: Is it possible your 2008 laptop had had the registry changes necessary to associate .P files with Excel, but your current laptop does not? He's running a program that explicitly tells Excel to open the file, so extension associations don't come into it. What matters is whether Excel uses the extension to tell what kind of file it is, or just looks at the contents. Possibly different versions of Excel behave differently in that regard. -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Calling unregistered COM libraries via Python
Manowitz, David wrote: Is it possible, either via the win32com extensions or the comtypes package (or some other package), to call to an unregistered COM library? It does appear to be possible, using a manifest file: https://msdn.microsoft.com/en-us/library/ms973913.aspx -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Storing Passwords.
Bob Hood wrote: I'm probably missing some crucial point here, but with Python being the host environment, why wouldn't the Python keyring module provide the hardened storage the OP is seeking? The same problem arises. If the program can get the password out of the keyring, then so can any user who is capable of running the program. If nothing else, by inserting a print statement into the program at the point just after it has retrieved the password. Keyrings allow a user to keep his or her passwords secret from *other* users. The OP seems to want to keep the *user* of the password from being able to know it, which is fundamentally impossible. The best you can do is obfuscate it, but with Python code being so easy to reverse-engineer, you can't get much security that way. -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Windows automation basics
Alan Gauld wrote: And for interest only, where is COM in the world of .NET and Windows 8+ etc? Are there better options today? As far as I understand, not always. If the functionality you're after happens to exist in the form of a .NET library, and you're willing to use a .NET-compatible language, you can access it directly, but otherwise you still need to go through COM. As for discovering an app's COM interface, if any, I think the only way to find out in general is to read the app's documentation. It's possible for an app to make its COM interface introspectable, but not every app does that. -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] optimizing code to read serial port
Tony Cappellini wrote: Do you have any ides why running a terminal program written in (presumably C, mentioned in my original message) doesn't seem to suffer from the problems that my python app does, even when transferring the data at much higher baud rates? Could the terminal program possibly be using some protocol such as xon/xoff for flow control? If so, that might account for the difference. -- Greg ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Pythonwin Combobox
Manfred Schulte-Oversohl wrote: I'd like to use a combobox control. Getting it with dialog is no problem. But I could not create a combobox on a window. I had the same problem -- pywin32 is missing a CreateComboBox function. After much frustration, I found the following workaround: hwnd = win32gui.CreateWindow(COMBOBOX, ...) pycwnd = win32ui.CreateWindowFromHandle(hwnd) -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Finding out whether there are any visible windows
In PyGUI I have a need to find out whether the application has any visible windows, so I can quit when the last visible window is closed. However, I can't seem to find a way of iterating over all the windows belonging to the application, without also getting windows belonging to *other* applications. Any suggestions? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Finding out whether there are any visible windows
Tim Golden wrote: Just for information, my nearly-what-you-want is here: http://timgolden.me.uk/python/win32_how_do_i/find-the-window-for-my-subprocess.html Yep, I came up something similar -- was just wondering whether there was some more obvious way that I was missing. Seems not. Thanks, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [Pygui] Convert RGBA to BGRA using standard library?
geoff wrote: Greg, I had to solve this problem in another application and ended up using the array module and the with the slice syntax. import array input = rgbaRGBA1234 ba = array.array('c', input) ba[0::4], ba[2::4] = ba[2::4], ba[0::4] Yep, I was thinking the same thing myself. I'll give it a try next time I'm working on the problem. Thanks, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [Pygui] Installing PyGUI-2.5 on Mac OSX 10.5.8 fails
Colin Brown wrote: Macintosh:PyGUI-2.5 colin$ python setup.py install Traceback (most recent call last): File setup.py, line 12, in module from distutils_extensions import pygui_build_py ImportError: No module named distutils_extensions Sorry about that! The missing file is attached, and I'll upload a fixed distribution soon. -- Greg # # # PyGUI - Distutils hackery # # import os, sys from glob import glob from distutils.dist import Distribution if sys.version_info = (3, 0): try: from distutils.command.build_py import build_py_2to3 as build_py except ImportError: raise ImportError(build_py_2to3 not found in distutils - it is required for Python 3.x) else: from distutils.command.build_py import build_py # class pygui_build_py(build_py): An extension of the distutils build_py command that supports gathering .py files for a package from multiple source directories. It provides a new option 'package_subdirs' that is a mapping from a package name to a list of directory paths: package_subdirs = {'package_name': ['source_dir', ...], ...} The directory paths are interpreted relative to the primary source directory for the package. In addition to .py files from the primary source directory, any .py files from the specified directories will be copied into the package during installation. Distribution.package_subdirs = {} def initialize_options(self): build_py.initialize_options(self) self.package_subdirs = {} def finalize_options(self): build_py.finalize_options(self) self.package_subdirs = self.distribution.package_subdirs def find_package_modules(self, package, package_dir): #print distutils_extensions: Searching subdirectories of package, repr(package) ### modules = build_py.find_package_modules(self, package, package_dir) subdirs = self.package_subdirs.get(package, ()) for subdir in subdirs: #print Looking in subdir, repr(subdir), of, repr(package_dir) ### module_files = glob(os.path.join(package_dir, subdir, *.py)) for f in module_files: module = os.path.splitext(os.path.basename(f))[0] #print Found module, repr(module), in, repr(f) ### modules.append((package, module, f)) return modules ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.5
PyGUI 2.5 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Lots of new stuff in this version. Highlights include: - Improved facilities for customising the standard menus. - Functions for creating PyGUI Images from PIL images and numpy arrays. - ListButton - a pop-up or pull-down menu of choices. - GridView - a user-defined view consisting of a regular grid of cells. - PaletteView - a GridView specialised for implementing tool palettes. There is also a big pile of other improvements and bug fixes. See the CHANGES file for full details. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Creating PyCComboBox?
Mark Hammond wrote: I think you just want a CreateWindow(Ex) with Combobox as the class. Yes, but the puzzle was how to get a PyCComboBox object rather than a raw window handle. I discovered it can be done by calling CreateWindowFromHandle on the resulting handle, but I don't think I should have to do that. All the other PyCFoo classes have a corresponding CreateFoo function, but CreateComboBox seems to be missing. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Creating PyCComboBox?
How are you supposed to create a PyCComboBox? There doesn't seem to be a CreateComboBox function anywhere. I tried using CreateControl(COMBOBOX, ...) but it says that the CLSID is invalid. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Creating PyCComboBox?
Vernon Cole wrote: The problem is that the Windows combobox does not allow for the user to type more than one letter to select an item from the list I'm not sure it's necessary to replace the entire thing just to fix that -- it ought to be possible to override the keyboard event handling and do that part differently. Writing a complete replacement might be a good idea in the long run, but for the moment I just want to get something working for a particular project. Surely *someone* out there has used the PyComboBox object in pywin32? Google is being particularly unhelpful on this. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Convert RGBA to BGRA using standard library?
Can anyone think of an efficient way to convert a string full of RGBA image data to BGRA, using only what's available in the standard library? I'm trying to add a function to PyGUI for creating an Image object from arbitrary data. The problem I'm having is that GDI+ on Windows expects BGRA, whereas most other platforms deal with RGBA. I don't want to require the user to supply the data in different formats on different platforms, so PyGUI needs to be able to convert where necessary. I know the conversion can be done easily using something like PIL or numpy, but I'm after a solution that doesn't depend on any third-party libraries. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Bit of a strange one using py2exe
Tim Golden wrote: Backticks are a little-used alternative to the repr () function -- deprecated in Python 3 ISTR. Actually it's been *removed* in Python 3: Python 3.1.2 (r312:79147, Mar 2 2011, 17:43:12) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type help, copyright, credits or license for more information. `exit` File stdin, line 1 `exit` ^ SyntaxError: invalid syntax Good riddance, IMO -- there was never a good reason for having it in the first place. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Bundling font with application?
Gabriel Genellina wrote: I think AddFontResourceEx is what you are looking for. http://msdn.microsoft.com/en-us/library/dd183327(v=VS.85).aspx Yes, that sounds like it may do what I want, thanks. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Bundling font with application?
Is there a way to tell an ordinary Windows application to look for fonts in a specific directory, or load a font from a specific file? The only things I've been able to find about this using Google all relate to .NET. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] PyGUI Window Always Starts Behind Others
A PyGUI user has reported a problem on Windows XP whereby an application's window is not on top when it starts up. Apparently launching it with with pythonw doesn't entirely fix the problem, but making it a py2exe application does. Anyone here have any idea what might be causing this? Is there something I should do when creating a window to make sure it appears on top? Original Message Subject:Re: [Pygui] Window Always Starts Behind Others Date: Mon, 28 Mar 2011 10:17:10 -0400 From: Mark Melvin mark.mel...@gmail.com To: Greg Ewing greg.ew...@canterbury.ac.nz CC: py...@python.org References: AANLkTikrV8QcjKzWzSoieMrtrdmicUeJkdDhjDwCh=i...@mail.gmail.com 4d8cde4a.9080...@inteli-com.com aanlktimz1re_yy5y0_vrtp9apvrcp1zfhxcmsghr_...@mail.gmail.com 4d8d331d.4080...@canterbury.ac.nz On Fri, Mar 25, 2011 at 8:28 PM, Greg Ewing greg.ew...@canterbury.ac.nz mailto:greg.ew...@canterbury.ac.nz wrote: Mark Melvin wrote: I'm on Windows XP - 32-bit using the latest PyGUI. How are you launching the app? If you're not doing so already, try running it with pythonw.exe rather than python.exe, or give it a .pyw extension and double click. -- Greg Hi Greg, I was indeed launching as a console app, and I even had console in my py2exe setup. I've changed to using the 'windows' version of the launcher and it seems to have fixed the issue of the GUI launching behind almost every other window and being hidden from view entirely. However, it still pops up behind the console window I launch it from, and the py2exe'd executable version of the application pops up behind the Windows Explorer window from which I launched it. I checked a py2exe'd app I wrote that uses wxPython, and it always pops up on top when launched. Could there be a small issue on Windows with this in PyGUI? Regards, Mark. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Fonts behaving differently - The plot thickens a bit
Roger Upole wrote: The conversion in win32ui has changed since 212. At one time it was negating the height that was passed in: if (PyInt_Check (v)) pLF-lfHeight = -PyInt_AsLong(v); Ah, that explains it all! You can also extract the version embedded in the pyd's using win32api.GetFileVersionInfo. That sounds great, thanks. Do you happen to know exactly which version the change was made in, so I can get the version test right? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Fonts behaving differently with Py3/216
Tim Roberts wrote: Are you running this on a different computer? No, it's the same computer. I can run 2.x and 3.x versions of the same test side by side, and the 2.x one has normal sized text whereas the 3.x one has tiny text. Oddly, it only seems to affect text drawn by the standard win32 controls. Text that I draw myself using GDI+ comes out the same size in both cases. So it looks like GDI and GDI+ are doing different things with the fonts, somehow. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Possible trouble with pywin23-216 on python 3.2
Tim Golden wrote: Re: [python-win32] Possible trouble with pywin23-216 on python 3.2 Aha! There's your problem: you're trying to install pywin23. Unless of course you're using one of those rare machines based on Intel's little-known 23-bit architecture. (There was a typo early on in the design phase that wasn't spotted until an embarrassingly late stage of the development process. They hijacked the time machine and tried to cover it up, but a few prototype machines slipped through.) -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Fonts behaving differently with Py3/216
I recently tried running PyGUI on Python 3 using pywin32 build 216, and a couple of things are not working quite the same way as they were with Python 2 and build 213. 1) The default font used for control labels etc. is slightly smaller. 2) When I calculate the width of a piece of text using DC.GetTextExtent() I get a value that is too small, and doesn't match the actual size of the text as it is drawn. Anyone have any idea what might have changed, and what I can do about it? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Fonts behaving differently with Py3/216
Mark Hammond wrote: What version of python and how many bits? I'm guessing you tried 3.2, which means you must have used the 64bit version No, it's 3.1, and 32 bit. It can't be 64, because the machine I'm running it on can't handle that. (And it's definitely not 23 bit either. :-) The only other thing I can think if is the manifest changes - windows uses the manifest of the owning hmodule for some things I don't really know anything about these manifest things. Is there some tool I can use to examine them and see whether anything is different? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Possible future direction for PyGUI on Win32
Octavian Rasnita wrote: From: Greg Ewing greg.ew...@canterbury.ac.nz No, if I go this way, I would probably stop maintaining the current implementation. Oh, in that case imho I think this is a very bad idea. Can you elaborate on exactly what is bad about it, and suggest an alternative? The standard Windows GUI API is severely crippled compared to what is available natively in Cocoa and Gtk. The only alternatives I see at the moment are: * Allow Windows to hold back the development of PyGUI on all the other platforms. * Implement the missing functionality on Windows in pure Python -- a lot of work, and probably not practical for something complex such as a rich text or HTML widget. * Rely on a third party library to supply the missing functionality on Windows. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Possible future direction for PyGUI on Win32
Tim Golden wrote: Python.NET seems to sit in an awkward place in the ecosystem. Its niche seems to be: where you want a small bit of .NET technology (such as SQL-SMO in my case) but don't want to migrate any win-specific Python code. (ie stuff relying on pywin32) Or, as in my case, you are developing a library and want to make use of some .NET technology, but don't want to force all the users of your library to use a non-standard Python implementation. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Possible future direction for PyGUI on Win32
From: Octavian Rasnita [mailto:orasn...@gmail.com] If it will still be possible to use the standard Win32 GUI, it is OK to be able to use Windows Forms as an adition. No, if I go this way, I would probably stop maintaining the current implementation. I don't want to have to support two backends on Windows, and some of the things I intend to do with Windows Forms would be impractical to do using the raw Win32 API. -- Greg This email may be confidential and subject to legal privilege, it may not reflect the views of the University of Canterbury, and it is not guaranteed to be virus free. If you are not an intended recipient, please notify the sender immediately and erase all copies of the message and any attachments. Please refer to http://www.canterbury.ac.nz/emaildisclaimer for more information. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Find containing window given a control handle
Reckoner wrote: Given the handle of a text field or button embedded in some window, how can I find the parent window that contains the handle? Use the win32gui.GetParent() function? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Prevent a (Tkinter) window from maximizing via win32 api call?
pyt...@bdurham.com wrote: I have a *resizable* Tkinter window with min and max sizes set. I want to prevent users from attempting to maximize this window because the window pops over to the upper left of the display - a behavior that my users find very frustrating (and of little value). If they find it annoying, why can't they simply refrain from maximising the window? Nobody's forcing them to *use* the maximise button... -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] How to block ctrl-alt-delete on Windows 7?
Does the kiosk application need all 3 of those keys? If not, you could remove one of them from the keyboard and glue something over the hole. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PyGUI blobedit creashes with pywin32-214 but not 212 - traceback - related problems
Roger Upole wrote: The resource is actually in win32ui.pyd, rather than in Pythonwin itself. I've just verified that this method works from plain python.exe. That's great news! I thought I had already tried something very much like what you suggested, but maybe I hadn't hit upon the right resource ID. (It would help if the available resources were actually *documented* somewhere...) Looks like we may have a solution, thanks. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PyGUI blobedit creashes with pywin32-214 but not 212 - traceback - related problems
Roger Upole wrote: You instantiate the MFC view object without a document, but in order to actually create a window and do anything useful with it, it needs a valid document. Are you absolutely sure about that? At the MFC level, I can't see anything to stop you from instantiating a CView and calling its Create method without ever mentioning a CDocument. The RichEditView kludge ends up creating a PyDocument object wrapping a null pointer, and MFC seemed to be happy with whatever pywin32 build 212 and earlier did with that. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] does pipes.quote() work properly on Windows?
Bill Janssen wrote: myprogram --title=That's the game! says Mike Hammer Brotsky --file=... Since cmd.exe also supports pipelines, I'd sort of expect it to do the right thing on Windows, too. Don't know about later versions, but in Python 2.5 the pipes module is listed under Unix specific services, so I guess it was never designed with Windows in mind. The reason it fails on Windows is that it assumes single quotes can be used to quote a string containing double quotes. But Windows usually requires double quotes around arguments, so you will have to escape the inner quotes: --title=That's the game! says Mike \Hammer\ Brotsky A quick test suggests that this will work, at least in the case where the program being passed the args is a Python program. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] recent spam
Mark Hammond wrote: as they were replies to legitimate mailing-list messages, I was fooled into approving them. Spammers are getting more obnoxiously devious all the time. You have to wonder at the mentality of someone who goes to such lengths to try to trick people into reading messages that they are clearly not at all interested in -- if they were, no such tricks would be necessary in the first place! -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Win API call to display a BMP/PNG file as a splash screen for a console app?
Andrew MacIntyre wrote: Is it possible to draw directly to the desktop? I vaguely recall reading somewhere that that is how some splash screens are done to avoid the overhead of a window... Somehow I doubt that. I have a hard time imagining that displaying a splash screen could be a serious performance bottleneck! Not the window-creation part of it, anyway. Although if by overhead you mean that some programmer was too lazy to write the necessary code, I could probably believe that... -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Python Windows Socket problem after Py2exe and install
pyt...@bdurham.com wrote: ...'Choosing a collection of common modules/packages for a general purpose reusable PY2EXE runtime'. This post got zero feedback so our idea is either too stupid or too obvious to warrant further conversation :) I think the problem is that in the rare cases when you need a kitchen-sink approach, the set of appropriate modules to include isn't going to be covered by a single project-independent choice. Different kitchens need different-sized sinks. :-) -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Technique to limit number of instances of our application under Terminal Server
Here's another possible solution. Each process tries to open a socket connection to a server process. When the maximum number of processes are connected, the server stops accepting connections. The server also selects all of its open connections for reading. When a process dies, the server will notice because it will see an EOF condition on its connection. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [Correction] Trying to get the Win32_PortableBattery and Win32_SystemEnclosure classes to work
pyt...@bdurham.com wrote: I'm not entirely clear on why there are 2 battery classes and why I would choose to use vs. the other, but I suspect the Win32_PortableBattery class is for machines with advanced power supply management capabilities. Obviously it's for machines that have a *wireless* battery. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Solved - Printing coordinate system problem
Thomas Heller wrote: I would guess that GetDeviceCaps() returns the information that you need. Yep, this turns out to be right, although it's *very* difficult to find this out if you start looking in the area of the docs that talks about printing! My margins are spot-on now. I'm happy. Need sleep now. Thanks, everyone. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Printing coordinate system problem
I'm wrestling with printing support for PyGUI on Windows. I'd like to set up the coordinate system during printing so that (0, 0) is at the corner of the paper, so that I can arrange for the margins to have predictable sizes. However, the device context I get from calling PrintDlg() seems to be set up so that the origin is at the corner of the printable area of the page, which is smaller by some amount that depends on the printer being used. If I could find out the limits of the printable area, I could correct for this, but there doesn't seem to be any straightforward way of getting this information. It doesn't seem to appear anywhere in any of the structs returned by PrintDlg(), and I can't find any call that might extract it from the device context. Am I missing something? Surely this an issue that most applications that print have to deal with. How do they do it? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [Pygui] Printing coordinate system problem
Vernon Cole wrote: In searching for documentation, remember a quirk in Microsoft vocabulary... a printer is software, not hardware. The device on the corner of your desk with the paper in it is not a printer, it is a printing device. Yes, I know. I'll be happy if I can somehow find out what the driver for whichever printer has been selected in the PrintDlg box thinks the printable area is for the selected paper size. If that doesn't match what the actual printer uses, that's not my problem. :-) Delving a bit further, it looks like I may be able to find out via GetPrinter() and GetForm()... I'll try an experiment shortly. Using Crystal Reports, a rather expensive commercial product which uses Windows very well, I designed a very fancy Purchase Order form, which I tested on three or four different Windows printers. When I installed the application, the purchase orders would not print out correctly on another printer Configuring printer drivers on Windows can be a massively confusing and frustrating experience, especially when a network is involved. Chance are there was a setting somewhere in the maze of dialog boxes that would have made it work properly... or maybe not... -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] PyCPrintDialog - Is it any use?
The PyCPrintDialog in pywin32 doesn't seem to have any methods or attributes. How are you supposed to get information out of it? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI Mailing List
Thomas Heller wrote: Is the list available on gmane? I have received a reply from gmane saying that a subscription request has been sent and that the gmane group would be created when the first message arrives. I'm not a gmane user myself, so someone may want to take a look over there and see if it's working. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI Mailing List
Thomas Heller wrote: Is the list available on gmane? I have received a reply from gmane saying that a subscription request has been sent and that the gmane group would be created when the first message arrives. I'm not a gmane user myself, so someone may want to take a look over there and see if it's working. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] RichEditCtrl scrolling doesn't work properly
I'm trying to create a PyRichEditCtrl with scroll bars. I can get scroll bars to appear using the appropriate style flags in CreateWindow, but they don't entirely work. Clicking on the scrolling arrows causes the text to scroll, but the position of the thumb doesn't get updated to match. Can anyone point me to a piece of example code that shows the minimum necessary steps to get this to work? I've looked at the editor example that comes with pywin32, but the details are hidden under several layers of abstraction, making it hard to tell what's essential. Also, it seems to use a RichEditView/RichEditDoc combination instead of a RichEditCtrl. Does this make a difference? Is it possible to get a plain RichEditCtrl to scroll properly, or do I need to use a RichEditView? The code I'm currently using looks like this: import win32con as wc, win32ui as ui win_style = wc.ES_MULTILINE | wc.ES_WANTRETURN win = ui.CreateRichEditCtrl() win.CreateWindow(win_style, (0, 0, 100, 100), parent_win, 0) flags = 0 if 'h' in scrolling: flags |= wc.WS_HSCROLL if 'v' in scrolling: flags |= wc.WS_VSCROLL win.ModifyStyle(0, flags) win.ShowWindow() -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI Mailing List
Thomas Heller wrote: Is the list available on gmane? Not yet, but I'll look into making it so. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.1.1
PyGUI 2.1.1 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ This is an emergency bugfix release to repair some major breakage in the gtk version. Also corrects some other problems. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [pygtk] ANN: PyGUI 2.1
John Finlay wrote: Start your own list for the community that is interested in your project. That's not going to reach anyone who doesn't already know about it. It's probably a good idea for ongoing discussion, though. Any suggestions on the best way of going about it? I could start a Google Group, but I'd prefer a real mailing list server if possible. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [pygtk] ANN: PyGUI 2.1
Vernon Cole wrote: If it produces code for a cross platform GUI API then the resulting application will be cross platform. I would love to find one such that actually works and produces good code. Code produced by a GUI designer shouldn't be getting edited by humans, so the quality of the code is immaterial (as long as it works). -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI 2.0.5
Roger Upole wrote: Greg Ewing wrote: Randy Syring wrote: win32ui.error: The object has been destroyed. I looked at this a while ago, and have a good idea where the problem is. I'll try to get a fix in before the next build. If it's because of the screwy things I'm doing to get a dummy PyCDocument, can I suggest that you fix it by providing a way to create a PyCScrollView without having to supply any PyCDocument at all? It seems to be entirely possible to do this at the MFC level, and in fact MFC doesn't even provide any way to supply a CDocument at creation time of a CScrollView. Pywin32 is currently going through unnatural contortions to support it. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [pygtk] ANN: PyGUI 2.1
Sturla Molden wrote: The only GUI API that doesn't suck is no API at all. GUIs should be designed visually. There's a lot more to a GUI API than just specifying the layout. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] [pygtk] ANN: PyGUI 2.1
John Finlay wrote: Greg, Why do you post to mailing lists that are unrelated to your project? I would appreciate it if in future you didn't post a message about your project ot the PyGTK mailing list. I posted the announcement to the pyobjc, pygtk and pywin32 lists because PyGUI uses all of those libraries, and because I don't know of any single mailing list where people interested in Python GUIs in general can be found. However, if the consensus is that PyGUI announcements are not welcome on those lists, I will be happy to cease posting them there. What is the general feeling out there? Should I stop posting PyGUI messages to these lists? Is there another GUI-related list that would be more appropriate? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI 2.0.5
Randy Syring wrote: I am still seeing the bug noted below in 2.1. Do you have plans to tackle it? win32ui.error: The object has been destroyed. Reportedly it can be worked around by reverting to build 212 of pywin32. I haven't had a chance to investigate what's causing it yet, sorry. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.1
PyGUI 2.1 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Highlights of this version: * Win32: Fixed bug preventing PyGUI apps from working under pythonw Fixed incorrect mouse coordinates in ScrollableView Added more standard cursors * MacOSX: Application menu now has working Hide, Hide Others and Show All commands. Plus a few other bug fixes and improvements. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Pywin32 GUI not working with pythonw
I have a bizarre problem. The following program: import win32ui app = win32ui.GetApp() app.Run() works fine when run from a command window using python.exe -- it happily sits there waiting for events until I kill it with the task manager. However, if I run it using pythonw.exe, the GetApp() call returns immediately with a value of 0. I've tried diverting stdout and stderr into a file to see if there are any error messages or tracebacks, but there is nothing. Anyone have any idea what might be wrong? I'm using Python 2.5.4 and Pywin32 build 213 on Windows 2000. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] daemonized child
Elias Fotinis wrote: From: Antoine Martin I had forgotten about the pipes (doh), I guess I should start the child with stdin=stdout=stderr=None then? That won't necessarily close the OS-level file descriptors, though. If you want that, you need to do something like for i in xrange(3): os.close(i) -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] regarding invoking command prompt using python
Tim Roberts wrote: Depending on your point of view, that's either a usage problem or a design flaw in the os module. The design of the os module does seem rather screwy in this area. Since os.environ is a custom mapping type, I don't know why it doesn't just pass all get and set operations on to the real process environment instead of keeping a copy of it. It's not just Windows, btw, it seems to work the same way on Unix too. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI 2.0.5
Randy Syring wrote: I am wondering if the problems with build 213 have ever been resolved on Windows. Or was I mistaken that build 213 was the problem? I don't know. I haven't heard any more about it from anyone since then. Has anyone else out there that's having this problem successfully cured it by reverting to 212? If so, I could look into what's changed between 212 and 213 to see if it gives any clue to what's going on. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Extract icon from exe files
Nicolas EISEN wrote: the icon have the tranparence but the bmp take this in black. In win32ui, there are not attribute to set the background in white before write the bmp in DC ... an idea ? Draw a white rectangle over the bmp before calling DrawIcon? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.0.5
PyGUI 2.0.5 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ More bug fixes for various platforms. Still no idea what's causing the object has been destroyed error on Windows XP, though. Does this happen for everyone? Is there anyone who *has* got 12-scroll.py working for them on XP? What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI 2.0.5
Randy Syring wrote: Could you tell me briefly how this project differs from something like wxPython? It wraps platform-specific libraries directly, rather than being a wrapper around another cross-platform library. This means less bloat and less dependencies. Chances are you already have the necessary libraries installed. The API is designed to be very straightforward and Pythonic, and it's fully documented in its own terms, so you don't have to consult the documentation for some other library in some other language and translate into Python. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.0.4
PyGUI 2.0.4 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Fixes a few more bugs and hopefully improves things on Windows, although I can't be sure it will fix all the Windows problems people are having, because I haven't been able to reproduce some of them. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI 2.0.4
Christian K. wrote: I'm afraid, that error is stil there: File c:\pythonxy\python\Lib\site-packages\GUI\Win32\ScrollableViews.py, line 31, in __init__ GScrollableView.__init__(self, _win = win) win32ui.error: The object has been destroyed. That's a bit of a problem, since it works for me on all the Windows systems I have readily available. Please tell me if I can help, If you can do any debugging and find out more about what's causing the problem, that would be helpful. Thanks, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] ANN: PyGUI 2.0.2
Christian K. wrote: TypeError: 'pitch_and_family' is an invalid keyword argument for this function Looking at the source of pywin32, I can see why this happens -- it really is expecting 'pitch and family' with spaces (and it's abusing ParseTupleAndKeywords to unpack a dict, which is why it's reporting a keyword argument error even though it's not really a keyword). What's really puzzling is why I *don't* get this error on my system! Anyway, since that parameter isn't being used any more, just take it out and let me know if it fixes the problem. Thanks, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.0.2
PyGUI 2.0.2 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Fixes problem on Windows causing This file should not be imported error. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.0.1
PyGUI 2.0.1 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Fixes some problems in setup.py affecting installation on Linux and Windows. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] ANN: PyGUI 2.0
PyGUI 2.0 is available: http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ Highlights of this release: * Native Windows implementation, based on pywin32 and ctypes. * Full set of Postscript-style path construction operators available on all platforms. * Mouse and keyboard events can be intercepted for all component classes. Plus numerous minor improvements, see CHANGES on the website for details. What is PyGUI? -- PyGUI is a cross-platform GUI toolkit designed to be lightweight and have a highly Pythonic API. Acknowledgements Thanks are due to Patrick Forget and Erez-Sh for getting me started on the Windows implementation. Even though I didn't use much of their code in the end, I appreciate their efforts and may draw more from it in the future. -- Gregory Ewing greg.ew...@canterbury.ac.nz http://www.cosc.canterbury.ac.nz/greg.ewing/ ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] PyGUI 2.0 setup.py fixes
france...@promotux.it wrote: error: package directory 'Gtk' does not exist Smeg, there's a bug in the installer. I'll release a fix soon. In the meantime, try replacing the following line in setup.py: packages.append(Gtk) with packages.append(GUI.Gtk) I've also noticed another problem that could affect Windows installations. If anyone is having trouble installing on Windows, try copying the __init__.py file from GUI/Gtk to GUI/Win32. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Rendering to bitmap with OpenGL
I'm trying to create an OpenGL context for rendering to an offscreen bitmap. The attached program gets as far as trying to call wglCreateContext, then fails with WindowsError: [Errno 8] Not enough storage is available to process this command. Can anyone see what's going wrong here? Thanks, Greg import win32con as wc, win32ui as ui, win32gui as gui from OpenGL import WGL as wgl def main(): # Create device context and bitmap win = ui.CreateFrame() win.CreateWindow(None, , 0, (0, 0, 1, 1), None, None, 0, 0) dc0 = win.GetDC() dc = dc0.CreateCompatibleDC(dc0) bm = ui.CreateBitmap() bm.CreateCompatibleBitmap(dc0, 10, 10) dc.SelectObject(bm) hdc = dc.GetSafeHdc() print Bitmap: dump_bitmap(bm) # Create pixel format descriptor flags = wgl.PFD_SUPPORT_OPENGL | wgl.PFD_DRAW_TO_BITMAP #| wgl.PFD_SUPPORT_GDI pf = wgl.PIXELFORMATDESCRIPTOR() pf.dwFlags = flags 0x pf.cColorBits = 32 pf.iLayerType = wgl.PFD_MAIN_PLANE # Choose pixel format ipf = wgl.ChoosePixelFormat(hdc, pf) print Using pixel format no., ipf pf2 = wgl.PIXELFORMATDESCRIPTOR() wgl.DescribePixelFormat(hdc, ipf, pf2.nSize, pf2) print Pixel format chosen: dump_pixelformat(pf2) # Set pixel format and create opengl context print Setting pixel format wgl.SetPixelFormat(hdc, ipf, pf2) print Creating opengl context ctx = wgl.wglCreateContext(hdc) print Context created def dump_pixelformat(pf): print nSize =, pf.nSize print nVersion =, pf.nVersion print dwFlags = 0x%08x % pf.dwFlags print iPixelType =, pf.iPixelType print cColorBits =, pf.cColorBits print cRedBits =, pf.cRedBits print cRedShift =, pf.cRedShift print cGreenBits =, pf.cGreenBits print cGreenShift =, pf.cGreenShift print cBlueBits =, pf.cBlueBits print cBlueShift =, pf.cBlueShift print cAlphaBits =, pf.cAlphaBits print cAlphaShift =, pf.cAlphaShift print cAccumBits =, pf.cAccumBits print cAccumRedBits =, pf.cAccumRedBits print cAccumGreenBits =, pf.cAccumGreenBits print cAccumBlueBits =, pf.cAccumBlueBits print cDepthBits =, pf.cDepthBits print cStencilBits =, pf.cStencilBits print cAuxBuffers =, pf.cAuxBuffers print iLayerType =, pf.iLayerType print bReserved =, pf.bReserved print dwLayerMask =, pf.dwLayerMask print dwVisibleMask =, pf.dwVisibleMask print dwDamageMask =, pf.dwDamageMask def dump_bitmap(bm): info = bm.GetInfo() print bmType =, info['bmType'] print bmWidth =, info['bmWidth'] print bmHeight =, info['bmHeight'] print bmWidthBytes =, info['bmWidthBytes'] print bmPlanes =, info['bmPlanes'] print bmBitsPixel =, info['bmBitsPixel'] main() ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] GDI+ text rendering screwed up
I'm trying to use GDI+ (via ctypes) to draw text. It works for some fonts but messes up with others. Using Times, for example, it seems to be using the glyphs for one character earlier in the code sequence, so that Times comes out as Shldr -- except that it uses the widths of the original characters for positioning. Can someone please run the attached code and tell me whether it works for them or not? And any ideas on what I could be doing wrong to cause this? -- Greg import os, traceback from ctypes import * from ctypes.wintypes import * gdiplus = windll.gdiplus SW_HIDE = 0 SW_SHOW = 5 GWL_WNDPROC = -4 GWL_STYLE = -16 CS_VREDRAW = 0x0001 CS_HREDRAW = 0x0002 CS_GLOBALCLASS = 0x4000 WS_OVERLAPPEDWINDOW = 13565952 WS_VISIBLE = 0x1000 WS_SYSMENU = 0x0008 WM_QUIT = 0x0012 WM_PAINT = 0x000f WM_CLOSE = 0x0010 LF_FACESIZE = 32 WNDPROC = WINFUNCTYPE(c_long, c_int, c_uint, c_int, c_int) class WNDCLASS(Structure): _fields_ = [ ('style', c_uint), ('lpfnWndProc', WNDPROC), ('cbClsExtra', c_int), ('cbWndExtra', c_int), ('hInstance', c_int), ('hIcon', c_int), ('hCursor', c_int), ('hbrBackground', c_int), ('lpszMenuName', c_char_p), ('lpszClassName', c_char_p), ] class PAINTSTRUCT(Structure): _fields_ = [ ('hdc', c_int), ('fErase', c_int), ('rcPaint', RECT), ('fRestore', c_int), ('fIncUpdate', c_int), ('rgbReserved', c_char * 32), ] lo_byte = lambda x : x 0xff hi_byte = lambda x : x 8 0xff lo_word = lambda x : x 0x hi_word = lambda x : x 16 0x class RectF(Structure): _fields_ = [ ('x', c_float), ('y', c_float), ('w', c_float), ('h',c_float), ] class LOGFONT(Structure): _fields_ = [ ('lfHeight', c_long), ('lfWidth', c_long), ('lfEscapement', c_long), ('lfOrientation', c_long), ('lfWeight', c_long), ('lfItalic', c_byte), ('lfUnderline', c_byte), ('lfStrikeOut', c_byte), ('lfCharSet', c_byte), ('lfOutPrecision', c_byte), ('lfClipPrecision', c_byte), ('lfQuality', c_byte), ('lfPitchAndFamily', c_byte), ('lfFaceName', c_char * LF_FACESIZE), ] def __init__(self): self.lfHeight, self.lfWidth = 10, 10 self.lfEscapement = 10 self.lfOrientation = 0 self.lfUnderline = 0 self.lfStrikeOut = 0 self.lfCharSet = 0 # ANSI_CHARSET self.lfPitchAndFamily = 0 self.lfOutPrecision = 0 self.lfClipPrecision = 0 self.lfQuality = 0 self.lfPitchAndFamily = 2 class GdiplusStartupInput(Structure): _fields_ = [ ('GdiplusVersion', c_uint), ('DebugEventCallback', c_void_p), ('SuppressBackgroundThread', BOOL), ('SuppressExternalCodecs', BOOL), ] def __init__(self): Structure.__init__(self) self.GdiplusVersion = 1 self.DebugEventCallback = None self.SuppressBackgroundThread = 0 self.SuppressExternalCodecs = 0 StartupInput = GdiplusStartupInput() token = c_ulong() gdiplus.GdiplusStartup(pointer(token), pointer(StartupInput), None) class Font(object): def __init__(self, family, size = 12, style = []): logfont = LOGFONT() logfont.lfFaceName = family logfont.lfHeight = -size logfont.lfWidth = 0 if 'italic' in style: logfont.lfItalic = 1 else: logfont.lfItalic = 0 if 'bold' in style: logfont.lfWeight = 10 else: logfont.lfWeight = 0 self._size = size self._win32_object = windll.gdi32.CreateFontIndirectA(byref(logfont)) self._free_object = True self._family = family # should came elsewhere class Canvas(object): def __init__(self, hdc): self._hdc = hdc self._GpGraphics = c_void_p() gdiplus.GdipCreateFromHDC(hdc, byref(self._GpGraphics)) self._GpFont = c_void_p() self._GpBrush = c_void_p() gdiplus.GdipCreateSolidFill(0xff00, byref(self._GpBrush)) print Canvas: brush =, self._GpBrush.value ### self._GpPen = c_void_p()
Re: [python-win32] GDI+ text rendering screwed up
Tim Roberts wrote: Sadly, I see Times Italic 48 in black-on-yellow. Do you really have a font called Times? I'm not sure, but I can use the name Times with plain GDI and it works fine, so it seems to be able to find something equivalent. But I'll try using the exact name and see if it works any better. Thanks, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] GDI+ text rendering screwed up
Turns out I *sort* of have a font called Times... I've got Times Bold, Times Italic and Times Bold Italic, but no plain Times! Times New Roman works fine, though, and it seems that the same is true of all the other fonts for which there is a full set of variations. So it looks like I'll be building in my own translation table. Thanks for the help, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PyCSlider notification messages
Mark Hammond wrote: Works for me. In sliderdemo.py, directly after the creation of the control I added: self.HookMessage(self.OnSliderMove, win32con.WM_HSCROLL) Okay, I've modified that demo similarly and it works for me too. I can investigate further from there, thanks. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] PyCSlider notification messages
I'm having trouble getting notification messages from a Slider control. According to MS, a Slider is supposed to send WM_HSCROLL messages to its parent window when the user changes it, but this isn't happening. I can get WM_HSCROLL messages from a normal scroll bar, but either the Slider isn't sending them or I'm somehow failing to intercept them. Is HookMessage the right way to catch these? Or is there some other trick to this that I'm missing? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] PyCScrollView with no PyCDocument?
Is there any way of creating a ScrollView without needing a Document? I just want a scrollable user-drawable area, but CreateView insists that I supply a Document. What's more, the only way to create a Document seems to be to use a DocTemplate, and the only way to get one of those is to use a resource. But I don't have any resources. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PyCScrollView with no PyCDocument?
Mark Hammond wrote: No not only can I no longer answer your question, I'm quite confident I never could :( Alternatively, is there a way of getting a valid DocTemplate without having to put a resource in the executable? Some kind of in-memory resource creation or something? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] PyCScrollView with no PyCDocument?
Well, I think I've found a workaround. The following hack seems to create something looking enough like a PyCDocument to keep it happy while creating a PyCView: dummy = win32ui.CreateRichEditView().GetDocument() The result of this appears to be a PyCDocument that's wrapping a null pointer. The fact that CreateView accepts this suggests that there's really no need to supply a document at creation time as far as the C++ level is concerned. I can't find anything in the MS docs to say there's any such need. Looking at the source, you seem to be doing some very strange things. In the PyCView constructor, first you're hacking around protected members to stuff the CDocument pointer into the m_pDocument member. Then in CreateWindow you're taking it out again and putting it in the CCreateContext. I don't know why you can't just leave all this alone at creation time, or at least make the document argument optional, and expose the AddView method of CDocument as a way of setting the document afterwards. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Focus lost when switching windows
The following program creates a FrameWnd with an Edit control in it. If I select some text in the control, then switch to another window and back again, the Edit control has lost the keyboard focus. Normal Windows applications don't behave that way. What do I have to do to get my controls to stay focused? #-- import os, win32con as wc, win32ui as ui, win32gui as gui class Test(object): def __init__(self): frame = ui.CreateFrame() self.frame = frame frame.CreateWindow(None, Test Focus, wc.WS_CAPTION | wc.WS_SYSMENU, (100, 100, 300, 200)) frame.AttachObject(self) edit = ui.CreateEdit() edit.CreateWindow(wc.WS_VISIBLE, (10, 10, 90, 30), frame, 1) frame.ShowWindow() def OnClose(self): gui.PostQuitMessage(0) test = Test() app = ui.GetApp() app.Run() #-- -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Confused about PreTranslateMessage
I'm having trouble understanding how PreTranslateMessage is supposed to work. According to M$: Return value: Nonzero if the message was translated and should not be dispatched; 0 if the message was not translated and should be dispatched. and according to the pywin32 docs: The result should be a tuple of the same format as the msg param, in which case the MSG structure will be updated and TRUE returned from the C++ function. If all of that is true, I don't see what the purpose is of updating the MSG, since it's just going to be ignored when TRUE is returned. But in any case it doesn't seem to be working -- the original message gets dispatched anyway, regardless of what I return from my PreTranslateMessage method. So I'm totally confused at this point. Should I be able to prevent the original message from being dispatched, and if so, how do I go about it? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Finding attached object?
Mark Hammond wrote: Hrm - m_pMenu (and m_pSubMenu) is *supposed* to return a PyCMenu object - what are you seeing? They're returning a PyCMenu, but not the object that I have attached to the PyCMenu. This seems to happen automatically in some other places, e.g. ui.GetFocus(). If m_pMenu behaved that way as well, I wouldn't have had a problem. While on the subject, there's something I'm a bit confused about. According to the MS docs, when you destroy an HMENU that has sub-menus attached, the sub-menus are destroyed as well. This suggests that the only reasonable way to attach a PyCMenu as a sub-menu is to Detach its menu handle first. If that's true, then the PyCMenu object isn't much use any more, so you might as well throw it away, and not getting the attached object from m_pMenu probably isn't so much of a problem. But what happens if a PyCMenu object returned by m_pMenu or m_pSubMenu gets deallocated before the parent menu? It seems as though it will end up destroying an HMENU that it doesn't really own, and stuff up the menu that contains it. On another topic, another thing it would have really been handy to have access to is the m_bAutoMenuEnable property of CFrameWnd. PyGUI has its own scheme for managing menu item enabling, and MFC's one just gets in the way. If I could turn it off, it would save me a lot of hassle. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Finding attached object?
Mark Hammond wrote: Apparently not from Python. It would be easy to add, If you do happen to add this, another thing you might want to investigate is why PyCCmdUI isn't automatically doing this when you read the m_pMenu property, as seems to happen in most other places if you call a method that returns a wrapped MFC object. but I guess that doesn't help you much now (or parse the repr() and use ctypes to de-ref the pointer, then wash your hands ;) I was hoping to avoid having to use ctypes:-(. I'm working around it for now using weak refs and a global dict to make my own reverse mapping, but it's disappointing having to do this when the information is hidden in there all along. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] OnCtlColor not working?
Mike Driscoll wrote: I'm probably being naive, but why don't you just use one of Python excellent GUI toolkits? I'm implementing my own cross-platform toolkit, because I don't like any of the existing ones. See http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] OnCtlColor not working?
Vernon Cole wrote: So, Greg, can we anticipate a python_gui flavor for Windows in native mode? Yes, it looks like there's a reasonable chance of that happening fairly soon. There are actually two possible ways it could go. I have a partial implementation contributed by one of my users based on ctypes, but it has some issues, and programming at the raw win32api level is a bit much for me to cope with just yet. So I'm working on an alternative implementation based on the mfc layer of pywin32. This does mean an extra dependency, but I consider pywin32 to be fairly standard equipment and not too much of an imposition to require. Also it will work with older versions of Python that don't come with ctypes. It's coming along nicely -- tests up to 07 are working well enough. It's a bit disappointing that buttons don't play fair with respect to colour customisation, but not a serious problem. Now, on to menus... -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] OnCtlColor not working?
Has anyone successfully used the PyCWnd.OnCtlColor virtual function to change the appearance of a control? The program below tries to use it to set the colour of the text in a PyCButton. My OnCtlColor method gets called, but it doesn't have any effect on the appearance of the button. Also, if I attempt to return a PyCBrush from the OnCtlColor method as the docs suggest, I get TypeError: An integer is required errors. Am I doing something wrong? # import win32con, win32ui from pywin.mfc.object import Object class MyFrame(Object): def OnCtlColor(self, dc, btn, typ): print MyFrame.OnCtlColor:, self ### dc.SetTextColor(0xff) # Doing the following causes TypeError: An integer is required #b = win32ui.CreateBrush() #b.CreateSolidBrush(0x00ff00) #return b frame = MyFrame(win32ui.CreateFrame()) frame.CreateWindow(None, Test, win32con.WS_CAPTION, (100, 100, 300, 300)) button = win32ui.CreateButton() style = win32con.BS_CHECKBOX button.CreateWindow(Hello, style, (20, 20, 100, 40), frame, 0) button.ShowWindow(win32con.SW_SHOW) frame.ShowWindow() app = win32ui.GetApp() app.Run() # -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] OnCtlColor not working?
Roger Upole wrote: OnCtlColor is expected to return a GDI handle rather than a full MFC object. Ah, okay. It does say so, now that I come to look at the docs carefully enough. It works fine now. Thanks, Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] OnCtlColor not working?
Well, it *almost* works now... it's okay for all the button styles except BS_PUSHBUTTON. My OnCtlColor is still getting called, but the pushbutton seems to ignore the results. All the other button styles are okay. Am I still doing something wrong, or is this a known limitation of pushbuttons? #- import win32con, win32ui, win32gui, win32api from pywin.mfc.object import Object b = win32ui.CreateBrush() b.CreateSolidBrush(0x00ff00) hb = b.GetSafeHandle() class MyFrame(Object): def OnCtlColor(self, dc, btn, typ): print MyFrame.OnCtlColor:, self ### dc.SetTextColor(0xff) dc.SetBkColor(0x00ff00) return hb def add_button(title, style, y): button = win32ui.CreateButton() button.CreateWindow(title, style, (20, y, 100, y + 20), frame, 0) button.ShowWindow(win32con.SW_SHOW) frame = MyFrame(win32ui.CreateFrame()) frame.CreateWindow(None, Test, win32con.WS_CAPTION, (100, 100, 300, 300)) add_button(Push, win32con.BS_PUSHBUTTON, 20) add_button(Check, win32con.BS_CHECKBOX, 50) add_button(Radio, win32con.BS_RADIOBUTTON, 80) add_button(Group, win32con.BS_GROUPBOX, 110) add_button(3State, win32con.BS_3STATE, 140) frame.ShowWindow() app = win32ui.GetApp() app.Run() #- -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Error with VixCom operation; TypeError: The VARIANT type is unknown (0x00000015)
Tim Roberts wrote: It's kind of loony for an API to use a 64-bit integer as an error number, but that's what they're doing. This is Windows, remember. There are large numbers of things that can go wrong. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Writing to Excel performance
Tim Roberts wrote: Dahlstrom, Roger wrote: My opinion is that determining file type by extension (arbitrary at that) is a bad thing to begin with. This is veering a bit off-topic for this mailing list, but I'd be curious to hear what alternatives you would suggest. The way classic MacOS handled it was much better. The file type was a separate piece of metadata that the user never normally saw or changed. The file type info is still available in MacOSX, but Apple seems to be discouraging its use, which is disappointing. -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Does Python need a native Windows GUI toolkit?
Thomas Heller wrote: Does Python need a native, pure Python, Windows GUI toolkit, one that uses win32 api calls directly to use native windows controls? I believe so. One of the long-term goals for PyGUI is to give it a native Windows backend. I share your dislike of layers on layers. Are there people that share these ideas? Are they willing to join a coordinated effort to develop a framework like this, Would you be willing to work on a Windows implementation of PyGUI? http://www.cosc.canterbury.ac.nz/greg.ewing/python_gui/ -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Python COM: Automatic wrap/unwrap?
I'm creating a COM server in Python that will have one main class, with methods that create and return instances of other classes. I've found that I need to use win32com.server.util.wrap and unwrap on these objects when they pass over a COM connection. This doesn't seem very convenient, especially for methods that can be called either via COM or internally from other Python code. It seems that the basic Python types are wrapped and unwrapped automatically when needed. Is there some way of extending this mechanism? Is there a class I can inherit from, or a magic attribute I can set, or some registration process I can use, to get instances of my class automatically wrapped and unwrapped? -- Greg ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32