Re: [python-win32] Clipboard Documentation
I've been using the code below for 20 years now for text copy & paste. No guarantees, though. Regards, Dietmar def copy_to_clipboard(text, window_handle=0): """copy_to_clipboard(window_handle, text): copy a string to the clipboard.""" win32clipboard.OpenClipboard(window_handle) try: win32clipboard.EmptyClipboard() if sys.version_info.major==2: is_unicode = isinstance(text, str) else: is_unicode = True if is_unicode: win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, text) else: win32clipboard.SetClipboardText(text) finally: win32clipboard.CloseClipboard() _formats = {} def _format_to_number(format): if not format in _formats: number = win32clipboard.RegisterClipboardFormat(format) _formats[format] = number return _formats[format] #def copy_from_clipboard(format=win32clipboard.CF_TEXT, window_handle=0): def copy_from_clipboard(format=win32clipboard.CF_UNICODETEXT, window_handle=0): win32clipboard.OpenClipboard(window_handle) if isinstance(format, str): format = _format_to_number(format) try: ret = win32clipboard.GetClipboardData(format) except TypeError: return None finally: win32clipboard.CloseClipboard() return ret #def check_clipboard_format(format=win32clipboard.CF_TEXT, window_handle=0): def check_clipboard_format(format=win32clipboard.CF_UNICODETEXT, window_handle=0): if isinstance(format, str): format = _format_to_number(format) win32clipboard.OpenClipboard(window_handle) try: return win32clipboard.IsClipboardFormatAvailable(format) finally: win32clipboard.CloseClipboard() def get_clipboard_formats(window_handle=0): format = 0 formats = [] win32clipboard.OpenClipboard(window_handle) standard_formats = {} for n in dir(win32clipboard): if not n.startswith("CF_"): continue standard_formats[getattr(win32clipboard, n)] = n[3:] try: while True: format = win32clipboard.EnumClipboardFormats(format) if not format: break if format in standard_formats: formats.append(standard_formats[format]) else: formats.append( win32clipboard.GetClipboardFormatName(format) ) finally: win32clipboard.CloseClipboard() return formats ___ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Anti-reverse Python-based binaries?
Am 10.02.2012 09:03, schrieb niki: On 9.02.2012 20:41, Tim Roberts wrote: Yes. If this is an issue for you, then you should not be using an interpreted language at all. You need to use something that is compiled, like C++. Even compiled code can be reverse-engineered, but it's much harder. IMHO not true. Professional decompilers for C++ are much better than python decompilers. Example: hex-rays Might be. But I would think that the most C[++] sources are still harder to understand than Python bytecode... To the OP: Cross-posting is not nice. Posting to two lists without any indication is even worse. Regards, Dietmar ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Running Python + pywin32 portably
Am 04.02.2012 02:38, schrieb Mark Hammond: Not running the postinstall script just means that pywintypesxx.dll and pythoncomxx.dll aren't in system32. Assuming you have control over the environment this is running in, just ensuring those files are on the PATH should be sufficient. Yes, I have been running portable Python installations for years. In the sitecustomize.py I'm just adding the required directories to the path: import sys, os # add DLL directories to path environment variable path = original_path = os.environ[path] splitted = path.split(;) splitted_l = path.lower().split(;) dlls = os.path.join(sys.exec_prefix, DLLs) pythonwin = os.path.join(sys.exec_prefix, rLib\site-packages\pythonwin) pythonwin_system32 = os.path.join(sys.exec_prefix, rLib\site-packages\pywin32_system32) dlldirs = [sys.exec_prefix, dlls, pythonwin, pythonwin_system32] for dlldir in dlldirs: if dlldir.lower() in splitted_l: continue path = path+;+dlldir if path!=original_path: os.environ[path] = path del dlls, dlldir, dlldirs, pythonwin, pythonwin_system32 Regards, Dietmar ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] python 3 support
Am 01.02.2012 20:56, schrieb Roman Morawek: Is there any alternativ package available, which allows me to import/export MS project files? MS Project can write and read XML files. Maybe that's good enough for you. Just save a project as XML and have a look. The structure is not too complicated. Much easier to use than e.g. XML files from Word or Excel. Regards, Dietmar ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] Interaction between wxPython and win32ui on Win 7
Am 09.05.2011 03:03, schrieb Mark Hammond: Where exactly does things get stuck? Do you see that print statement, or is it app.MainLoop which fails to return? The main loop retuns such that I see the print statement. But the interpreter does not exit. Even if I move the win32ui import right after the mainloop, it does not exit. Regards, Dietmar ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
[python-win32] Interaction between wxPython and win32ui on Win 7
Hi! I'm observing some strange interaction between wxPython and win32ui on Windows 7 PCs. I've been using DDE code from Pythonwin which in turn uses win32ui. When I use win32ui and SetToolTipString from wxPython in the same program, the Python interpreter will not exit any more (until it's killed from the task manager or by closing the console window.) See below for the code. If I omit import win32ui or panel.SetToolTipString(...), then the interpreter will exit as expected. I've posted the problem on the wxPython mailing list and Robin Dunn suggested the workaround of calling wx.Exit(), which is more or less the equivalent to killing the interpreter. Robin's comment: It seems that something that is done during the import of win32ui is conflicting somehow with what is done when a wxToolTip object is created. The wx side of things is not too complex, it basically just adds a new WndProc function to the chain of WndProcs for the window that will respond to the tooltip messages. Maybe win32ui is doing something similar and is getting stuck when it is trying to clean up at exit? Am I missing anything? Is there e.g. a finalize function or something like that? Calling wx.Exit() works for me, but it's not a nice way to finish... The versions: pywin32 build 216 wxPython 2.8.12.0 or 2.8.11.0 Python 2.7 (same with 2.6 and an older version of wxPython and pywin32) With Windows XP or 2000 everything works as expected. I think I had the problem already with Vista, but I'm not sure. One user has reported that the code works for him under Win7 with Python 2.6.5. Regards, Dietmar import wx import win32ui class MyFrame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, -1, test frame) panel = wx.Panel(self, -1) panel.SetToolTipString(test) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) def OnCloseWindow(self, event): self.Destroy() import sys app = wx.App() frame = MyFrame(None) frame.Show(True) app.MainLoop() print calling sys.exit() sys.exit() ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32