def list_icon():
    import os
    ret = []
    for f in os.listdir('./normal'):
        if f[-4:] == '.png':
            ret.append(f[7:-4])
    return ret

def gen_icon_css():
    icons = list_icon()
    for ico in icons:
        print('.'+ico+"icon {")
        print("  background-image: url('./normal/normal_"+ico+".png');")
        print("}")
        print('.'+ico+"icon-disabled {")
        print("  background-image: url('./disable/disable_"+ico+".png');")
        print("}")
        print('.'+ico+"icon:hover {")
        print("  background-image: url('./hover/hover_"+ico+".png');")
        print("}")
        print('.'+ico+"icon:active {")
        print("  background-image: url('./pressed/pressed_"+ico+".png');")
        print("}")

if __name__ == '__main__':
    gen_icon_css()
@@ -151,16 +151,88 @@
 rn ret%0A%0A
+def file_exist(fname):%0A    import os%0A    return os.path.isfile(fname) %0A%0A
 def gen_
@@ -239,24 +239,24 @@
 icon_css():%0A
-
     icons = 
@@ -405,32 +405,92 @@
      print(%22%7D%22)%0A
+        if file_exist('./disable/disable_'+ico+'.png'):%0A    
         print('.
@@ -510,24 +510,28 @@
 isabled %7B%22)%0A
+    
         prin
@@ -593,32 +593,36 @@
 ng');%22)%0A        
+    
 print(%22%7D%22)%0A     
@@ -608,32 +608,88 @@
      print(%22%7D%22)%0A
+        if file_exist('./hover/hover_'+ico+'.png'):%0A    
         print('.
@@ -710,32 +710,36 @@
 ver %7B%22)%0A        
+ 
+   
 print(%22  backgro
@@ -785,32 +785,36 @@
 ng');%22)%0A        
+    
 print(%22%7D%22)%0A     
@@ -800,32 +800,92 @@
      print(%22%7D%22)%0A
+        if file_exist('./pressed/pressed_'+ico+'.png'):%0A    
         print('.
@@ -903,24 +903,28 @@
 :active %7B%22)%0A
+    
         prin
@@ -978,32 +978,36 @@
 +ico+%22.png');%22)%0A
+    
         print(%22%7D

Check icon file existance