[Anygui-devel] [patch] Unicode support for GTK, QT, TK
by Sascha Silbe other posts by this author
Aug 21 2003 4:45PM messages near this date
Re: [Anygui-devel] Questions about anygui
|
[Anygui-devel] Anygui on Zaurus
--Avw2VvEbzfULB0h1
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hi!
I've attached a patch against the current CVS version that fixes the=20
handling of strings in the GTK, QT and TK backends. They now use=20
unicode(x) instead of str(x) for all text values.
All three widget sets seem to handle Unicode strings properly. At least=20
I can use german Umlauts in my MUA prototype. :)
CU/Lnx Sascha
--=20
Registered Linux User #77587 (http://counter.li.org/)
bomb terrorist afghanistan PGP encrypt CIA FBI BND MAD StaSi anschlag=20
strike sex pussy xxx kill bj hitler Gates MS Windows ZV ZDV
--Avw2VvEbzfULB0h1
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="anygui-cvs-unicode.patch"
Content-Transfer-Encoding: quoted-printable
Index: lib/anygui/backends/gtkgui.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 @@
=20
def setText(self, text):
if not self.widget: return
- self.widget.set_text(str(text))
+ self.widget.set_text(unicode(text))
=20
class _ComboBoxWrapper(ComponentWrapper):
def widgetFactory(self, *args, **kws):
@@ -214,7 +214,7 @@
self.widget._listbox.clear()
self._items =3D items[:]
for item in items:
- self.widget._listbox.append([str(item)])
+ self.widget._listbox.append([unicode(item)])
=20
def getItems(self):
"""
@@ -281,9 +281,9 @@
if not self.widget: return
=20
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 =3D gtk.Label(str(text))
+ label =3D gtk.Label(unicode(text))
label.show()
self.widget.add(label)
=20
@@ -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))
=20
def getText(self):
"""
@@ -477,7 +477,7 @@
=20
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))
=20
def setSelection(self, selection):
if not self.widget: return
@@ -562,7 +562,7 @@
=20
def setTitle(self,title):
if not self.widget: return
- self.widget.set_title(str(title))
+ self.widget.set_title(unicode(title))
=20
def _getContainer(self):
if not hasattr(self, '_gtk_container'):
Index: lib/anygui/backends/qtgui.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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
=20
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 =3D items[:]
for item in self.items:
- self.widget.insertItem(QString(str(item)),-1)
+ self.widget.insertItem(QString(unicode(item)),-1)
=20
def getItems(self):
if self.widget:
@@ -351,7 +351,7 @@
self.widget.setReadOnly(not editable)
=20
def qtText(self):
- return QString(str(self.text))
+ return QString(unicode(self.text))
=20
def keyReleaseHandler(self, event):
if DEBUG: print 'in keyReleaseHandler of: ', self.widget
@@ -439,7 +439,7 @@
paras =3D []
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 @@
=20
def setText(self, text):
if self.widget:
- self.mainWindow.setCaption(QString(str(text)))
+ self.mainWindow.setCaption(QString(unicode(text)))
=20
def getText(self):
- return str(self.widget.title())
+ return unicode(self.widget.title())
=20
def setTitle(self, title):
if self.widget:
- self.mainWindow.setCaption(QString(str(title)))
+ self.mainWindow.setCaption(QString(unicode(title)))
=20
def getTitle(self):
- return str(self.widget.title())
+ return unicode(self.widget.title())
=20
def widgetSetUp(self):
if not self.connected:
Index: lib/anygui/backends/tkgui.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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 =3D items[:]
for item in self.items:
- self.widget.insert(Tkinter.END, str(item))
+ self.widget.insert(Tkinter.END, unicode(item))
=20
def getItems(self):
assert self.widget,"?! wrapper getXxx w/o widget"
Index: lib/anygui/backends/tkgui2.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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))
=20
def _ensure_selection(self):
if self._tk_comp:
--Avw2VvEbzfULB0h1--
Attachments:
unknown1
Thread:
Sascha Silbe
Magnus Lie Hetland
|