[patch] Unicode support for GTK, QT, TK
Sascha Silbe <[email protected]> Thu, 21 Aug 2003 18:45:43 +0200
| Newsgroups | gmane.comp.python.anygui.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi! I've attached a patch against the current CVS version that fixes the handling of strings in the GTK, QT and TK backends. They now use unicode(x) instead of str(x) for all text values. All three widget sets seem to handle Unicode strings properly. At least I can use german Umlauts in my MUA prototype. :) CU/Lnx Sascha -- Registered Linux User #77587 (http://counter.li.org/) bomb terrorist afghanistan PGP encrypt CIA FBI BND MAD StaSi anschlag strike sex pussy xxx kill bj hitler Gates MS Windows ZV ZDV
anygui-cvs-unicode.patch
(text/plain, 5.7 KB)
Index: lib/anygui/backends/gtkgui.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/backends/gtkgui.py,v
retrieving revision 1.27
diff -u -r1.27 gtkgui.py
--- lib/anygui/backends/gtkgui.py 26 Jan 2003 21:29:55 -0000 1.27
+++ lib/anygui/backends/gtkgui.py 21 Aug 2003 16:31:20 -0000
@@ -174,7 +174,7 @@
def setText(self, text):
if not self.widget: return
- self.widget.set_text(str(text))
+ self.widget.set_text(unicode(text))
class _ComboBoxWrapper(ComponentWrapper):
def widgetFactory(self, *args, **kws):
@@ -214,7 +214,7 @@
self.widget._listbox.clear()
self._items = items[:]
for item in items:
- self.widget._listbox.append([str(item)])
+ self.widget._listbox.append([unicode(item)])
def getItems(self):
"""
@@ -281,9 +281,9 @@
if not self.widget: return
if self.widget.get_children():
- self.widget.get_children()[0].set_text(str(text))
+ self.widget.get_children()[0].set_text(unicode(text))
else:
- label = gtk.Label(str(text))
+ label = gtk.Label(unicode(text))
label.show()
self.widget.add(label)
@@ -417,7 +417,7 @@
"""
if not self.widget: return
self.widget.delete_text(0, -1)
- self.widget.insert_text(str(text))
+ self.widget.insert_text(unicode(text))
def getText(self):
"""
@@ -477,7 +477,7 @@
def setText(self, text):
if not self.widget: return
- self.widget._textview.get_buffer().set_text(str(text))
+ self.widget._textview.get_buffer().set_text(unicode(text))
def setSelection(self, selection):
if not self.widget: return
@@ -562,7 +562,7 @@
def setTitle(self,title):
if not self.widget: return
- self.widget.set_title(str(title))
+ self.widget.set_title(unicode(title))
def _getContainer(self):
if not hasattr(self, '_gtk_container'):
Index: lib/anygui/backends/qtgui.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/backends/qtgui.py,v
retrieving revision 1.29
diff -u -r1.29 qtgui.py
--- lib/anygui/backends/qtgui.py 17 Feb 2003 02:53:15 -0000 1.29
+++ lib/anygui/backends/qtgui.py 21 Aug 2003 16:31:20 -0000
@@ -160,14 +160,14 @@
def setText(self, text):
if self.widget:
try:
- self.widget.setText(QString(str(text)))
+ self.widget.setText(QString(unicode(text)))
except:
pass
def getText(self):
if self.widget:
try:
- return str(self.widget.text())
+ return unicode(self.widget.text())
except:
# Widget has no text.
return ""
@@ -236,7 +236,7 @@
self.widget.clear()
self.items = items[:]
for item in self.items:
- self.widget.insertItem(QString(str(item)),-1)
+ self.widget.insertItem(QString(unicode(item)),-1)
def getItems(self):
if self.widget:
@@ -351,7 +351,7 @@
self.widget.setReadOnly(not editable)
def qtText(self):
- return QString(str(self.text))
+ return QString(unicode(self.text))
def keyReleaseHandler(self, event):
if DEBUG: print 'in keyReleaseHandler of: ', self.widget
@@ -439,7 +439,7 @@
paras = []
if self.widget is not None:
for n in range(self.widget.paragraphs()):
- paras.append(str(self.widget.text(n)))
+ paras.append(unicode(self.widget.text(n)))
if DEBUG:
print 'paragraphs are: \n'
for para in paras:
@@ -499,17 +499,17 @@
def setText(self, text):
if self.widget:
- self.mainWindow.setCaption(QString(str(text)))
+ self.mainWindow.setCaption(QString(unicode(text)))
def getText(self):
- return str(self.widget.title())
+ return unicode(self.widget.title())
def setTitle(self, title):
if self.widget:
- self.mainWindow.setCaption(QString(str(title)))
+ self.mainWindow.setCaption(QString(unicode(title)))
def getTitle(self):
- return str(self.widget.title())
+ return unicode(self.widget.title())
def widgetSetUp(self):
if not self.connected:
Index: lib/anygui/backends/tkgui.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/backends/tkgui.py,v
retrieving revision 1.86
diff -u -r1.86 tkgui.py
--- lib/anygui/backends/tkgui.py 13 Nov 2002 17:19:22 -0000 1.86
+++ lib/anygui/backends/tkgui.py 21 Aug 2003 16:31:20 -0000
@@ -449,7 +449,7 @@
self.widget.delete(0, Tkinter.END)
self.items = items[:]
for item in self.items:
- self.widget.insert(Tkinter.END, str(item))
+ self.widget.insert(Tkinter.END, unicode(item))
def getItems(self):
assert self.widget,"?! wrapper getXxx w/o widget"
Index: lib/anygui/backends/tkgui2.py
===================================================================
RCS file: /cvsroot/anygui/anygui/lib/anygui/backends/tkgui2.py,v
retrieving revision 1.5
diff -u -r1.5 tkgui2.py
--- lib/anygui/backends/tkgui2.py 31 May 2002 04:35:49 -0000 1.5
+++ lib/anygui/backends/tkgui2.py 21 Aug 2003 16:31:20 -0000
@@ -215,7 +215,7 @@
if self._tk_comp:
self._tk_comp.delete(0, END)
for item in self._items:
- self._tk_comp.insert(END, str(item))
+ self._tk_comp.insert(END, unicode(item))
def _ensure_selection(self):
if self._tk_comp:
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iD8DBQE/RPc3Fu2Z2HTlz4cRAtWwAJ9EeJLDkZBSdZrWDZm8AR0jz4Rc5gCfQ/el gBKgJnybw5zSnpigAtu72Ik= =hN/y -----END PGP SIGNATURE-----