re.finditer() skips unicode into selection
I am using the following Highlighter class for Spell Checking to work on my QTextEdit. class Highlighter(QSyntaxHighlighter): pattern = ur'\w+' def __init__(self, *args): QSyntaxHighlighter.__init__(self, *args) self.dict = None def setDict(self, dict): self.dict = dict def highlightBlock(self, text): if not self.dict: return text = unicode(text) format = QTextCharFormat() format.setUnderlineColor(Qt.red) format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) unicode_pattern=re.compile(self.pattern,re.UNICODE|re.LOCALE) for word_object in unicode_pattern.finditer(text): if not self.dict.spell(word_object.group()): print word_object.group() self.setFormat(word_object.start(), word_object.end() - word_object.start(), format) But whenever I pass unicode values into my QTextEdit the re.finditer() does not seem to collect it. When I pass "I am a नेपाली" into the QTextEdit. The output is like this: I I I a I am I am I am a I am a I am a I am a I am a I am a I am a I am a It is completely ignoring the unicode. What might be the issue. I am new to PyQt and regex. Im using Python 2.7 and PyQt4. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unable to import NHunspell.dll using ctypes in Python
Thanks everyone. But it still did not work. I instead used a Python wrapper for Hunspell called Pyhunspell. The actual link in PyPi does not work for Python 2.7 but it has been improved and upgraded in [here](https://github.com/akshaylb/nepali-spellchecker-v2/tree/master/pyhunspell). -- http://mail.python.org/mailman/listinfo/python-list
Re: Unable to import NHunspell.dll using ctypes in Python
On Tuesday, June 25, 2013 12:08:17 PM UTC+5:45, aksha...@gmail.com wrote: > Im required to import ha certain dll called 'NHunspell.dll' which is used for > Spell Checking purposes. I am using Python for the software. Although I > checked out several websites to properly use ctypes, I have been unable to > load the dll properly. > > > > When I use this code. > > > > from ctypes import * > > hunspell = cdll.LoadLibrary['Hunspellx64.dll'] > > > > I get an error > > > > hunspell = cdll.LoadLibrary['Hunspellx64.dll'] > > TypeError: 'instancemethod' object has no attribute '__getitem__' > > > > I guess it might a problem with the structure of the dll. But I have no idea > how to import the dll properly. @Chris I understand that. But then I am supposed to create something that works on a Windows environment using a Windows Dll.Aaandd Im stuck. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unable to import NHunspell.dll using ctypes in Python
Thanks Dave. I'm using Python 2.7 and am working on Linux Mint. Does it mean that I cant load the functions within the dll whilst on Linux. I thought that was what ctypes was used for. Please correct me if I misunderstood what you meant. -- http://mail.python.org/mailman/listinfo/python-list
Re: Unable to import NHunspell.dll using ctypes in Python
Thanks for the reply Mark. I did what you suggested. But now I'm getting an error like this. Traceback (most recent call last): File "start.py", line 15, in hunspell = cdll.LoadLibrary('/home/kuro/Desktop/notepad/Hunspellx64.dll') File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary return self._dlltype(name) File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__ self._handle = _dlopen(self._name, mode) OSError: /home/kuro/Desktop/notepad/Hunspellx64.dll: invalid ELF header I am really new to using ctypes and dll files. Can you please guide me out. -- http://mail.python.org/mailman/listinfo/python-list
Unable to import NHunspell.dll using ctypes in Python
Im required to import ha certain dll called 'NHunspell.dll' which is used for Spell Checking purposes. I am using Python for the software. Although I checked out several websites to properly use ctypes, I have been unable to load the dll properly. When I use this code. from ctypes import * hunspell = cdll.LoadLibrary['Hunspellx64.dll'] I get an error hunspell = cdll.LoadLibrary['Hunspellx64.dll'] TypeError: 'instancemethod' object has no attribute '__getitem__' I guess it might a problem with the structure of the dll. But I have no idea how to import the dll properly. -- http://mail.python.org/mailman/listinfo/python-list