Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #87787 > unrolled thread

Re: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX?

Started by"Timothy W. Grove" <tim_grove@sil.org>
First post2015-03-20 17:17 +0000
Last post2015-03-20 17:17 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX? "Timothy W. Grove" <tim_grove@sil.org> - 2015-03-20 17:17 +0000

#87787 — Re: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX?

From"Timothy W. Grove" <tim_grove@sil.org>
Date2015-03-20 17:17 +0000
SubjectRe: [PyQt] win32api.LoadKeyboardLayout; any solutions for OSX?
Message-ID<mailman.43.1426871861.10327.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Thanks again. Macports didn't have the latest pyobjc, but pip updated my 
installation to the fixed version. Problem solved.

Tim

On 20/03/2015 00:18, michael h wrote:
> Did you see this:
>
> https://bitbucket.org/ronaldoussoren/pyobjc/issue/95/attributeerror-in-some-cases-when-checking
>
>
>
> On Thu, Mar 19, 2015 at 12:20 PM, Timothy W. Grove <tim_grove@sil.org 
> <mailto:tim_grove@sil.org>> wrote:
>
>     A personal reply to my question sent me to the following link:
>     http://stackoverflow.com/questions/23729704/change-osx-keyboard-layoutinput-source-programmatically-via-terminal-or-appl.
>     I seem to have found a solution that worked using PyObjC.
>
>     I'm currently using Python 3.3 installed via macports, and I
>     installed the appropriate ports for my setup (py33-pyobjc,
>     py33-pyobjc-cocoa).
>
>     For my import statement:
>
>         from AppKit import NSTextInputContext
>
>     To find the current keyboard being used:
>
>         ic = NSTextInputContext.new()
>         current_keyboard = ic.selectedKeyboardInputSource()
>
>     To list the currently available keyboards:
>
>         keyboards = ic.keyboardInputSources()
>
>     To change the current keyboard (to 'Arabic', for example):
>
>         ic.setValue_forKey_('com.apple.keylayout.Arabic',
>         'selectedKeyboardInputSource')
>
>
>     Now, that is the good news! This all worked great in my source
>     code, but as an app bundle (created with cx_Freeze 4.3.2) it
>     wouldn't run at all. I'll include the full error trace at the end
>     of this email, but the problems seem to start with the import of
>     AppKit and end with objc/_lazyimport.py.
>
>     I'm not sure if this points to a 'bug' in objc or something else
>     which I've left out of my setup routine, but if anyone has any
>     ideas, I would be interested to hear from you.
>
>     Best regards,
>     Timothy Grove
>
>
>
>     On 05/03/2015 14:51, Timothy W. Grove wrote:
>>     I was looking for a way to change keyboard layouts from within a
>>     Python 3 / PyQt4 application. Win32api.LoadKeyboardLayout has
>>     come to my rescue on Windows, but is anyone aware of a
>>     cross-platform or OSX specific solution for Apple Mac? Thanks for
>>     any suggestions.
>>
>>     Best regards,
>>     Tim
>
>         Traceback (most recent call last):
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/cx_Freeze/initscripts/Console3.py",
>         line 27, in <module>
>
>             exec(code, m.__dict__)
>
>           File "soosl.py", line 6, in <module>
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1565, in _find_and_load
>
>             return _find_and_load_unlocked(name, import_)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1532, in _find_and_load_unlocked
>
>             loader.load_module(name)
>
>           File
>         "/Users/timothygrove/Documents/workspace/SooSL/mainwindow.py",
>         line 19, in <module>
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1565, in _find_and_load
>
>             return _find_and_load_unlocked(name, import_)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1532, in _find_and_load_unlocked
>
>             loader.load_module(name)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/AppKit/__init__.py",
>         line 9, in <module>
>
>             import Foundation
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1565, in _find_and_load
>
>             return _find_and_load_unlocked(name, import_)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1532, in _find_and_load_unlocked
>
>             loader.load_module(name)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/Foundation/__init__.py",
>         line 9, in <module>
>
>             import CoreFoundation
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1565, in _find_and_load
>
>             return _find_and_load_unlocked(name, import_)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/importlib/_bootstrap.py",
>         line 1532, in _find_and_load_unlocked
>
>             loader.load_module(name)
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/CoreFoundation/__init__.py",
>         line 20, in <module>
>
>             }, ())
>
>           File
>         "/opt/local/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/objc/_lazyimport.py",
>         line 82, in __init__
>
>             if nm.startswith(pfx):
>
>         AttributeError: 'NoneType' object has no attribute 'startswith'
>
>         logout
>
>
>         [Process completed]
>
>
>
>     _______________________________________________
>     PyQt mailing list PyQt@riverbankcomputing.com
>     <mailto:PyQt@riverbankcomputing.com>
>     http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web