Python Forum
Modern version of XPM files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modern version of XPM files
#1
I want to make status indicator lamps for my Qt based GUI. The lamps will display a different image based on the value of the signal they monitor.

In the past I used .xpm files to define my lamp icons. XPM files have a color table that defines all the colors used in the icon. I allocated the first 9 colors in the table to be background, background highlight, background shadow, foreground, foreground highlight, foreground shadow, fill color, fill color highlight and fill color shadow. My icon class had methods for setting the background, foreground and fill color that used an algorithm to calculate the shadow and highlight versions of each color and modify the color table. With shadow and highlight colors it was easy to make a lamp with a bezel that matched the background, or to make a hot spot or a shadow in my lamp bulb.

I would like to do something similar with my new indicator lamps and am looking for graphics file formats where you can define "programmable colors". What file formats and Python packages should I investigate?
Reply
#2
Is there any reason why you can't still use XPM files? Gimp supports this file type so you can create what ever you need or even convert an existing image. I drew a red dot and saved it to .xpm file. It created the file below. It's in C syntax but it seems like it would be fairly easy to use in python.

/* XPM */
static char * light_xpm[] = {
"41 41 12 1",
" 	c None",
".	c #FFAAAA",
"+	c #FF8383",
"@	c #FF5C5C",
"#	c #FF2E2E",
"$	c #FF0000",
"%	c #FF8D8D",
"&	c #FF7171",
"*	c #FF9393",
"=	c #FF5A5A",
"-	c #FF1C1C",
";	c #FF0D0D",
"                .+@#$#@+.                ",
"             %$$$$$$$$$$$$$%             ",
"           &$$$$$$$$$$$$$$$$$&           ",
"         *$$$$$$$$$$$$$$$$$$$$$*         ",
"        =$$$$$$$$$$$$$$$$$$$$$$$=        ",
"       -$$$$$$$$$$$$$$$$$$$$$$$$$-       ",
"      ;$$$$$$$$$$$$$$$$$$$$$$$$$$$;      ",
"     -$$$$$$$$$$$$$$$$$$$$$$$$$$$$$-     ",
"    =$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$=    ",
"   *$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*   ",
"   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$   ",
"  &$$$$$$$$$$$$$$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$$$$$$$$$-       ",
"        =$$$$$$$$$$$$$$$$$$$$$$$=        ",
"         *$$$$$$$$$$$$$$$$$$$$$*         ",
"           &$$$$$$$$$$$$$$$$$&           ",
"             %$$$$$$$$$$$$$%             ",
"                .+@#$#@+.                "};
Note: Pillow supports .xpm files.
Reply
#3
I would like to explore options.
Reply
#4
Scaled Vector Graphics (.svg) look promising. Anyone know of any Python tools I could use to manipulate these files? I would like to see an SVG file as a list of graphics primitives with attributes like fill and pen colors
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Modern looking GUI Cuz 14 72,831 Jan-11-2019, 09:30 PM
Last Post: Cuz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020