From tfa.signup.test1 at gmail.com Tue Jun 20 14:03:59 2017 From: tfa.signup.test1 at gmail.com (Goku Balu) Date: Tue, 20 Jun 2017 23:33:59 +0530 Subject: [python-win32] Context menu example not working in Win10 Message-ID: Hi, The context menu example provided with pywin32 isn't working in Windows 10. Have you had any luck running it from Windows 10? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tfa.signup.test1 at gmail.com Thu Jun 22 06:04:38 2017 From: tfa.signup.test1 at gmail.com (Goku Balu) Date: Thu, 22 Jun 2017 15:34:38 +0530 Subject: [python-win32] Context menu example not working in Win10 Message-ID: Hi All, To explain things bit more clearly, I'm trying to add my own menu item to the context menu that appears for files and folders. When I was searching about how to achieve it in Python, I found this example provided with pywin32 under folder " *python36-32\Lib\site-packages\win32comext\shell\demos\servers\context_menu.py". * When I run the program, I could see that the entries are added into the registry correctly under "Python.File>shellex>ContextMenuHandlers". But the menu item is not showing up in explorer. However if I add any entry manually like the way mentioned here (under Python.File>shell) it's working fine even without explorer restart. I'm quite new to this win32 APIs and stuff. Any help would be appreciated. I've attached the sample code for your reference. Thanks. Hi, > > The context menu example provided with pywin32 isn't working in Windows 10. > Have you had any luck running it from Windows 10? > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- # A sample context menu handler. # Adds a 'Hello from Python' menu entry to .py files. When clicked, a # simple message box is displayed. # # To demostrate: # * Execute this script to register the context menu. # * Open Windows Explorer, and browse to a directory with a .py file. # * Right-Click on a .py file - locate and click on 'Hello from Python' on # the context menu. import pythoncom from win32com.shell import shell, shellcon import win32gui import win32con class ShellExtension: _reg_progid_ = "Python.ShellExtension.ContextMenu" _reg_desc_ = "Python Sample Shell Extension (context menu)" _reg_clsid_ = "{6D2DFAAD-72B9-4FB0-8935-5BE30F3945FE}" _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu] _public_methods_ = shellcon.IContextMenu_Methods + shellcon.IShellExtInit_Methods def Initialize(self, folder, dataobj, hkey): print("Init", folder, dataobj, hkey) self.dataobj = dataobj def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags): print("QCM", hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags) # Query the items clicked on format_etc = win32con.CF_HDROP, None, 1, -1, pythoncom.TYMED_HGLOBAL sm = self.dataobj.GetData(format_etc) num_files = shell.DragQueryFile(sm.data_handle, -1) if num_files>1: msg = "&Hello from Python (with %d files selected)" % num_files else: fname = shell.DragQueryFile(sm.data_handle, 0) msg = "&Hello from Python (with '%s' selected)" % fname idCmd = idCmdFirst items = ['First Python content menu item'] if (uFlags & 0x000F) == shellcon.CMF_NORMAL: # Check == here, since CMF_NORMAL=0 print("CMF_NORMAL...") items.append(msg) elif uFlags & shellcon.CMF_VERBSONLY: print("CMF_VERBSONLY...") items.append(msg + " - shortcut") elif uFlags & shellcon.CMF_EXPLORE: print("CMF_EXPLORE...") items.append(msg + " - normal file, right-click in Explorer") elif uFlags & CMF_DEFAULTONLY: print("CMF_DEFAULTONLY...\r\n") else: print("** unknown flags", uFlags) win32gui.InsertMenu(hMenu, indexMenu, win32con.MF_SEPARATOR|win32con.MF_BYPOSITION, 0, None) indexMenu += 1 for item in items: win32gui.InsertMenu(hMenu, indexMenu, win32con.MF_STRING|win32con.MF_BYPOSITION, idCmd, item) indexMenu += 1 idCmd += 1 win32gui.InsertMenu(hMenu, indexMenu, win32con.MF_SEPARATOR|win32con.MF_BYPOSITION, 0, None) indexMenu += 1 return idCmd-idCmdFirst # Must return number of menu items we added. def InvokeCommand(self, ci): mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci win32gui.MessageBox(hwnd, "Hello", "Wow", win32con.MB_OK) def GetCommandString(self, cmd, typ): # If GetCommandString returns the same string for all items then # the shell seems to ignore all but one. This is even true in # Win7 etc where there is no status bar (and hence this string seems # ignored) return "Hello from Python (cmd=%d)!!" % (cmd,) def DllRegisterServer(): import winreg key = winreg.CreateKey(winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex") subkey = winreg.CreateKey(key, "ContextMenuHandlers") subkey2 = winreg.CreateKey(subkey, "PythonSample") winreg.SetValueEx(subkey2, None, 0, winreg.REG_SZ, ShellExtension._reg_clsid_) print(ShellExtension._reg_desc_, "registration complete.") def DllUnregisterServer(): import winreg try: key = winreg.DeleteKey(winreg.HKEY_CLASSES_ROOT, "Python.File\\shellex\\ContextMenuHandlers\\PythonSample") except WindowsError as details: import errno if details.errno != errno.ENOENT: raise print(ShellExtension._reg_desc_, "unregistration complete.") if __name__=='__main__': from win32com.server import register register.UseCommandLine(ShellExtension, finalize_register = DllRegisterServer, finalize_unregister = DllUnregisterServer) From gklein at xs4all.nl Thu Jun 22 06:17:48 2017 From: gklein at xs4all.nl (Gertjan Klein) Date: Thu, 22 Jun 2017 12:17:48 +0200 Subject: [python-win32] Context menu example not working in Win10 In-Reply-To: References: Message-ID: Goku Balu schreef: > To explain things bit more clearly, I'm trying to add my own menu item > to the context menu that appears for files and folders. When I was > searching about how to achieve it in Python, I found this example > provided with pywin32 under folder > "/python36-32\Lib\site-packages\win32comext\shell\demos\servers\context_menu.py". This suggests that you use a 32-bit Python. Do you also have a 32-bit Windows? The bitness of Python and Windows must be the same. Regards, Gertjan. From tfa.signup.test1 at gmail.com Thu Jun 22 13:39:48 2017 From: tfa.signup.test1 at gmail.com (Goku Balu) Date: Thu, 22 Jun 2017 23:09:48 +0530 Subject: [python-win32] python-win32 Digest, Vol 171, Issue 2 In-Reply-To: References: Message-ID: Hi Gertjan, Thanks for the response. That's a great find. Yes I've installed 32-bit python in my 64-bit windows machine. I hope you've narrowed down the issue. Is there any way to get it working? Goku Balu schreef: > > > To explain things bit more clearly, I'm trying to add my own menu item > > to the context menu that appears for files and folders. When I was > > searching about how to achieve it in Python, I found this example > > provided with pywin32 under folder > > "/python36-32\Lib\site-packages\win32comext\shell\ > demos\servers\context_menu.py". > > This suggests that you use a 32-bit Python. Do you also have a 32-bit > Windows? The bitness of Python and Windows must be the same. > > Regards, > Gertjan. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gklein at xs4all.nl Thu Jun 22 14:31:25 2017 From: gklein at xs4all.nl (Gertjan Klein) Date: Thu, 22 Jun 2017 20:31:25 +0200 Subject: [python-win32] python-win32 Digest, Vol 171, Issue 2 In-Reply-To: References: Message-ID: Goku Balu schreef: > Thanks for the response. That's a great find. Yes I've installed 32-bit > python in my 64-bit windows machine. I hope you've narrowed down the > issue. Is there any way to get it working? I am by no means an expert, but as far as I know this can't work. The way to get your context menu would be to install a 64-bit Python and use that. Regards, Gertjan. From wenyunlong at gcidesign.com Thu Jun 22 20:31:56 2017 From: wenyunlong at gcidesign.com (wenyunlong at gcidesign.com) Date: Fri, 23 Jun 2017 08:31:56 +0800 Subject: [python-win32] python-win32 Digest, Vol 171, Issue 2 In-Reply-To: References: , , Message-ID: <2017062308315609027812@gcidesign.com> Goku Balu schreef: > Thanks for the response. That's a great find. Yes I've installed 32-bit > python in my 64-bit windows machine. I hope you've narrowed down the > issue. Is there any way to get it working? I am by no means an expert, but as far as I know this can't work. The way to get your context menu would be to install a 64-bit Python and use that. Regards, Gertjan. _______________________________________________ python-win32 mailing list python-win32 at python.org https://mail.python.org/mailman/listinfo/python-win32 -------------- next part -------------- An HTML attachment was scrubbed... URL: From gulsumramazanoglu at gmail.com Fri Jun 23 00:20:47 2017 From: gulsumramazanoglu at gmail.com (Gugu Rama) Date: Fri, 23 Jun 2017 07:20:47 +0300 Subject: [python-win32] To connect to a remote DB2(AS400) over Python, in any case do we have to pay to IBM for the driver? Message-ID: Hi everybody, I am new here and need an answer, if you can help I will be really happy... I just wonder a point about connecting to an AS400 DB2 over Python.. To connect to a DB2 of a remote AS400 over any one of the Python DB API interfaces (ibm_db, pyodbc, pyDB2 or any other one) from Python on Windows10, in any case do we have to pay for the license of the IBM ODBC driver? I tried ibm_db and it seems its for free to connect to a DB2 on Windows, but due to pay for a license to connect to a remote AS400.. Is there any other way of connecting to a remote AS400 without IBM licensing "solutions", from Python3.x?... BTW if here is not the proper email list to ask this kind of a question, would you please lead me to another one if its more fitting for such a question.. for I am new in Python, I try to learn proper community grounds for Q&A as well.. Thank you in advance.. -------------- next part -------------- An HTML attachment was scrubbed... URL: From damien at dcpendleton.plus.com Fri Jun 23 01:15:40 2017 From: damien at dcpendleton.plus.com (Damien Sykes-Lindley) Date: Fri, 23 Jun 2017 06:15:40 +0100 Subject: [python-win32] pythonw.exe Message-ID: Hi, I?m relatively new to Python so please excuse me if this question has a pretty obvious answer that I may have missed somewhere. Since I work exclusively with Windows, the majority of my projects are orientated towards GUI interfaces, meaning that the console often gets in the way. >From what I understand, *.pyw files open in pythonw.exe, which is a version of python.exe with no console. What I also assumed was that since there is no console, unhandled exceptions would be displayed in a message box or logged somewhere. I seem to be wrong on both counts ? no message is displayed and I can find no logs. Is there a way to view such messages without resorting to running them through the standard python.exe? Cheers. Damien. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at timgolden.me.uk Fri Jun 23 04:11:31 2017 From: mail at timgolden.me.uk (Tim Golden) Date: Fri, 23 Jun 2017 09:11:31 +0100 Subject: [python-win32] pythonw.exe In-Reply-To: References: Message-ID: <62321ff7-45f0-2959-569c-e155adb484e1@timgolden.me.uk> On 23/06/2017 06:15, Damien Sykes-Lindley wrote: > Hi, > I?m relatively new to Python so please excuse me if this question has a > pretty obvious answer that I may have missed somewhere. > Since I work exclusively with Windows, the majority of my projects are > orientated towards GUI interfaces, meaning that the console often gets > in the way. > From what I understand, *.pyw files open in pythonw.exe, which is a > version of python.exe with no console. > What I also assumed was that since there is no console, unhandled > exceptions would be displayed in a message box or logged somewhere. I > seem to be wrong on both counts ? no message is displayed and I can find > no logs. Is there a way to view such messages without resorting to > running them through the standard python.exe? So the short answer is: nothing happens automatically to re-route exceptions etc. You have all the options you might expect: running with a console active (ie via python.exe or by adding a console); using sys.excepthook; using explicit logging of some sort; re-routing sys.stderr to a file [haven't tried that one but it should work]. But, yes, you have to do something. Nothing happens normally. TJG From vernondcole at gmail.com Fri Jun 23 21:37:48 2017 From: vernondcole at gmail.com (Vernon D. Cole) Date: Fri, 23 Jun 2017 19:37:48 -0600 Subject: [python-win32] To connect to a remote DB2(AS400) over Python, in any case do we have to pay to IBM for the driver? In-Reply-To: References: Message-ID: This forum is appropriate. It has been a number of years since I looked at the code I used for what you ask (perhaps I have an old copy of source laying around) but if I recall correctly, I used the OLE DB Provider. I am not aware of any licensing issues -- perhaps the company already had some kind of license I did not know about. Anybody who can afford to run an AS-400 should not shrink from the cost of a license to actually access the data that it hosts, I suppose. My best source for finding how to connect with anything is https://www.connectionstrings.com/. Since C-Python cannot run .NET code, you cannot use any of the .NET connection methods. I think the method you want will be based on https://www.connectionstrings.com/ibm-client-access-ole-db-provider/ Pull and install the zip file from http://sourceforge.net/projects/adodbapi which has some documentation and samples that don't get shipped with pywin32. (The PIP install from pypi is the same thing,too.) The SQL-Server and ACCESS examples both use OLE-DB providers so get your ideas from them. The samples and the quickstart document ought to get you going. If not, feel free to email me directly. Of course, you will have to get DB-2 provider software from IBM or somewhere. (That may be where they get you with a license fee.) Also, be aware that the OLE-DB provider is complete/y different from the ODBC driver. You can use either one from adodbapi, but the connection string is completely different. Once you have all of the correct software installed and permissions and passwords set up, the database manipulation itself is very straight forward, and adodbapi has enhancements to eliminate some of the worst problems with SQL, such as argument counting. DB-2 hums along quite nicely. In my best production application, I was pulling customer data from a distant AS-400 and combining it with local GIS data. Having the geographical data on a Microsoft SQL Server turned out to be a severe bottleneck. But, since everything was written using the Python DB-API, it was easy to convert to using MySQL locally (which worked quite well) and then to sqlite3, which became the final solution. Note that (even though adodbapi can do some magic) you are still talking in the SQL dialect of the target database engine. Don't expect to send Microsoft T-SQL commands to a DB-2 server. Good luck. On Thu, Jun 22, 2017 at 10:20 PM, Gugu Rama wrote: > Hi everybody, I am new here and need an answer, if you can help I will be > really happy... > > I just wonder a point about connecting to an AS400 DB2 over Python.. To > connect to a DB2 of a remote AS400 over any one of the Python DB API > interfaces (ibm_db, pyodbc, pyDB2 or any other one) from Python on > Windows10, in any case do we have to pay for the license of the IBM ODBC > driver? I tried ibm_db and it seems its for free to connect to a DB2 on > Windows, but due to pay for a license to connect to a remote AS400.. Is > there any other way of connecting to a remote AS400 without IBM licensing > "solutions", from Python3.x?... > > BTW if here is not the proper email list to ask this kind of a question, > would you please lead me to another one if its more fitting for such a > question.. for I am new in Python, I try to learn proper community grounds > for Q&A as well.. > > Thank you in advance.. > > _______________________________________________ > python-win32 mailing list > python-win32 at python.org > https://mail.python.org/mailman/listinfo/python-win32 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oz at akan.me Mon Jun 26 15:10:11 2017 From: oz at akan.me (Oz Akan) Date: Mon, 26 Jun 2017 15:10:11 -0400 Subject: [python-win32] Microsoft Speech Engine implementation with Python Message-ID: Hi All I have been working on implementing Microsoft Speech API with Python. My goal is to call AWS Polly service when a windows app uses TTS. I am stuck as debug more provides little information about what I am doing wrong. I put all the code here: https://gitlab.com/ozgurakan/polly-sapi error.txt has the error message I get. polly.py implements the engine as com object talk.py runs the test code. I can call com objects methods from another python script but when MS SAPI calls it, it creates the object but fails to call the methods. I get a ?Catastrophic failure? message for ?Speak? call. I see this as I log into a file. I also run the code in debug mode but there is little output I can get. I have this error: pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147418113), None) I have 64 bit versions for python and win32com, so it is not the problem as I saw in a few other posts. best wishes, Oz -------------- next part -------------- An HTML attachment was scrubbed... URL: