472,805 Members | 1,659 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,805 software developers and data experts.

wxPython: Icon aus base64 decoded Image

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 """'iVBORw0KGgoAAAATkSuQmCC\n'"""

# Danach im Skript:
self.staticImage =
wx.ImageFromStream(StringIO(pic_b64.decode("base64 ")))
self.staticBitmap =
wx.StaticBitmap(bitmap=wx.BitmapFromImage(self.sta ticImage,
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
"""'==123445342gsgadfgdghsfhsdhxfghxfghTRG>dfg\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

Dec 11 '06 #1
1 3770
Roland Rickborn wrote:
Wo ist der Fehler und was muss ich machen, damit das Icon
angezeigt wird?
I'm sorry that I can't help you, but you'll probably get more
answers if you write again in English (this is comp.lang.python).

Grüße,
Björn

--
BOFH excuse #126:

it has Intel Inside

Dec 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Karl Pech | last post by:
Hi all, I'm trying to write a program which can read in files in the following format: sos_encoded.txt: --- begin-base64 644 sos.txt UGxlYXNlLCBoZWxwIG1lIQ== ---
4
by: Jive | last post by:
How the heck do you set the icon on a frame using a .ico file, or a .bmp file, or whatever? How do you find out how to do something like that? Apparently there is no documentation to speak of. I...
1
by: mvdevnull | last post by:
hey all currently i use the following piece of code to check if the string passed to me can be converted to base64, it is not very efficient and bad, can someone please suggest another of doing...
27
by: gRizwan | last post by:
Hello all, We have a problem on a webpage. That page is sent some email data in base64 format. what we need to do is, decode the base64 data back to original shape and extract attached image...
4
by: John | last post by:
Hi all, I've been going through google and yahoo looking for a certain base64 decoder in C without success. What I'm after is something that you can pass a base64 encoded string into and get back...
7
by: Neo Geshel | last post by:
Greetings. I have managed to stitch together an awesome method of posting text along with an image to a database, in a way that allows an unlimited number of previews to ensure that text and...
4
by: Tamir Weiss | last post by:
I'm trying to send a byte array (JPG image) from javascript to a servlet for processing. I'm using Base64 to encode the byte array in javascript, and then a base64 decoder in the servlet to decode...
13
by: aruna.eies.eng | last post by:
i am currently trying to convert data into binary data.for that i need to know how to achieve it in c language and what are the libraries that we can use. so if any one can send me a sample code or...
1
by: =?Utf-8?B?U3RldmVU?= | last post by:
I have a structure that contains both 32x32 and 16x16 icons plus some text. I want to write all this to an XML file so that I can recover the icons later in an application. Can someone tell me how...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.