473,549 Members | 2,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("bas e64")
# ergibt einen String wie """'iVBORw0KGgo AAAATkSuQmCC\n' """

# Danach im Skript:
self.staticImag e =
wx.ImageFromStr eam(StringIO(pi c_b64.decode("b ase64")))
self.staticBitm ap =
wx.StaticBitmap (bitmap=wx.Bitm apFromImage(sel f.staticImage,
wx.BITMAP_TYPE_ PNG),
name='staticBit map3', parent=self.pan el1, pos=wx.Point(8,
96),
size=wx.Size(16 8, 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("bas e64")
# ergibt einen String wie
"""'==123445342 gsgadfgdghsfhsd hxfghxfghTRG>df g\n'"""

# Danach im Skript:
icon = base64.b64decod e(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 3871
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.pytho n).

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
2555
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
3667
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 tried looking the in the demo program, but I didn't find the secret..
1
537
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 this private string ConvertBase64ToString(string content) { StringBuilder sb = new StringBuilder(); int i = content.GetUpperBound(0);
27
15001
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 from it. Any help will be highly appriciated. Thanks
4
5347
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 a decoded String. Any help is very much appreciated. Thanks Philip.
7
7875
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 image are perfect before submission. This involves converting any uploaded image to a Base64 String and holding that in a hidden form field until...
4
3834
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 it. The thing is, that even though the String has the same length on both sides, the decoded byte array is shorter then the original one. I've...
13
14733
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 send me the library file which helps that is really grateful. aruna.
1
3893
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 to properly serialize the System.Drawing.Icon structure to an XML file? The following code doesn't write the icon information to the xml file. ...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7469
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5368
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1935
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1057
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
757
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.