wxPython: Icon aus base64 decoded Image

2006-12-11 Thread Roland Rickborn
Hallo zusammen,

in meine Anwendung ist ein Bild eingebettet und oben in der Leiste soll
ein Icon erscheinen.
Ausserdem will ich nur _eine_ Datei ausgeben, also ohne zusärtliche
Bild-Dateien etc.

Dazu habe ich das Bild in base64 codiert und als String im Skript
gespeichert, siehe unten. Beim Ausführen des Skripts wird dieser
String decodiert, in ein Image umgewandelt und als Bitmap dargestellt.
Funzt prima.

# Base64 codiertes Bild, einmalig ausserhalb des Skripts
import base64
file = open('smallPic.png',rb)
pic = file.read()
pic_b64 = pic.encode(base64)
# ergibt einen String wie 'iVBORw0KGgoTkSuQmCC\n'

# Danach im Skript:
self.staticImage =
wx.ImageFromStream(StringIO(pic_b64.decode(base64)))
self.staticBitmap =
wx.StaticBitmap(bitmap=wx.BitmapFromImage(self.staticImage,
  wx.BITMAP_TYPE_PNG),
  name='staticBitmap3', parent=self.panel1, pos=wx.Point(8,
96),
  size=wx.Size(168, 72), style=0)

Wie gesagt, funkzt  prima!


Und jetzt das Icon:
# Base64 codiertes Bild, einmalig ausserhalb des Skripts
import base64
file = open('smallIcon.ico',rb)
ico = file.read()
ico_b64 = ico.encode(base64)
# ergibt einen String wie
'==123445342gsgadfgdghsfhsdhxfghxfghTRGdfg\n'

# Danach im Skript:
icon = base64.b64decode(ico_b64)
self.SetIcon(wx.Icon(icon, wx.BITMAP_TYPE_ICO))

-- Fehler beim Start der Anwendung: Failed to load icom from the
file

Wo ist der Fehler und was muss ich machen, damit das Icon angezeigt
wird?

Besten Dank und schöne Grüsse,
Roland

--

E-Mail-Adresse ist reply-fähig, wird aber nicht gelesen.
Besser: r_2 bei Ge Em Ix oder hier in der NG

-- 
http://mail.python.org/mailman/listinfo/python-list


Feed wxComboBox with dictionary/hash

2006-06-22 Thread Roland Rickborn
Hi folks,

I am relatively new to Python. Although I read a lot of howtos,
introductions and wikis, I am still having trouble ;-)

My querstion:
As the subject says, I'd like to feed a wx.ComboBox with a
dictionary/hash. According to the posting of Stano Paska (wxComboBox
 combobox, 20 Jul. 2004), there seems to be a way to do this:

 You must use something like
 combo.Append('aaa', 'a')
 combo.Append('bbb', 'b')
 ...

My problem is:
my data has thousands of entries. Therefore, I'd like to feed the
combobox with a dictionary (which itself is fed by a database query).

My first question:
how can a wx.ComboBox be fed by a dictionary?

For further help, Stano says:

 read manual for more details...

Ok, I'd like to. But which one?
I was reading http://www.wxpython.org/docs/api/wx.ComboBox-class.html
and didn't even find the above mentioned append method :-(

TIA,
Roland R.

-- 
http://mail.python.org/mailman/listinfo/python-list