Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Icon serialize

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
atz6975
Posts: 21
Joined: Mon Dec 01, 2008 6:36 am

Icon serialize

Post by atz6975 »

Hi,
could someone tell me how to create the serialized string of a plugin icon?
I would like to add one for my new plugin.
Thank you.
eg 0.3.7.1076
Vista, x32, SP1
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Icon serialize

Post by jinxdone »

Make a 16x16 24bpp png file of the icon, then you can to convert it into base64 form, or you could also leave it as a file and just put the file name in your plugin icon property.

The base64 functions are available in a default python installation, you could make a little script that converts a given file into base64. Or you can use an online converter like this one; just input the image in the file box and hit convert.
http://www.motobit.com/util/base64-decoder-encoder.asp

Finally insert the base64 encoded icon file in the icon property, look for examples in the other plugins that have icons in them.

Hope this helped! :)

-jinxdone
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Icon serialize

Post by Pako »

Try this script from Bitmonster:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="884">
    <Macro Name="Convert PNG to Python" Expanded="True">
        <Action Name="Convert PNG to Python">
            EventGhost.PythonScript(u'import base64\nimport wx\n\ndef Main():\n    dialog = wx.FileDialog(None, wildcard="PNG files (*.png)|*.png")\n    dialog.ShowModal()\n    filePath = dialog.GetPath()\n    dialog.Destroy()\n    if not filePath:\n        return\n    \n    fd = open(filePath, "rb")\n    data = base64.b64encode(fd.read())\n    fd.close()\n\n    s = "    icon = (\\n"\n    while len(data) > 68:\n        s += \'        "\' + data[:68] + \'"\\n\'\n        data = data[68:]\n    s += \'        "\' + data + \'"\\n\'\n    s += "    )\\n"\n            \n    eg.result = s\n\n\neg.CallWait(Main)\n\n')
        </Action>
        <Action>
            System.SetClipboard(u'{eg.result}')
        </Action>
    </Macro>
</EventGhost>
Found here:http://www.eventghost.org/forum/viewtopic.php?f=1&t=245
Pako
atz6975
Posts: 21
Joined: Mon Dec 01, 2008 6:36 am

Re: Icon serialize

Post by atz6975 »

Will try, thanks.
eg 0.3.7.1076
Vista, x32, SP1
atz6975
Posts: 21
Joined: Mon Dec 01, 2008 6:36 am

Re: Icon serialize

Post by atz6975 »

It doesnt like my png...Any specs for png format? I tried 16x16x24 but no luck.
eg 0.3.7.1076
Vista, x32, SP1
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Icon serialize

Post by jinxdone »

You could open one of the existing .png icons that come with EG with your image editing program, for example \EventGhost\plugins\TechnoTrendIr\icon.png. I hope you can pick the correct properties for the image that way. I didn't have any problems creating icons though using GIMP.

Does the image show up in EG if you save the icon as icon.png file in the same directory as the plugin? If that is working ok then the image file itself should be fine.
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: Icon serialize

Post by Bitmonster »

It must have an alpha channel, so it needs to have 32bits depth.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
jinxdone
Plugin Developer
Posts: 443
Joined: Tue Jan 02, 2007 4:08 pm

Re: Icon serialize

Post by jinxdone »

Yep.. Sorry! That one was my mistake. The image has to be with alpha channel as well.

Thanks for correcting me Bitmonster.
Post Reply