+- im.paste(pil_image,(0,ConfigPos))
++ im.paste(pil_image,(ConfigPosX,ConfigPosY))
+ else:
+ WetterType=ConfigType
+- POSX, POSY = 1,0
+- MAX_W,MAX_H = 320,80
+- Wmulti = 1.4 if ConfigType != "1" else 1
+- if ConfigType == "2":
+- MAX_H = 220
+- POSX = 10
++ POSX, POSY = 5,5
++ if ConfigType == "1":
++ MAX_W,MAX_H = 260,110
++ elif ConfigType == "2":
++ MAX_W,MAX_H = 400,110
+ elif ConfigType == "3":
+- MAX_H = 90
+- POSY = POSY-(20*Wmulti)+1
+- elif ConfigType == "4":
+- Wmulti = 3.5
+- MAX_H = 220
+- POSY = POSY-(20*Wmulti)+1
++ MAX_W,MAX_H = 400,240
++ elif ConfigType == "4" or ConfigType == "5":
++ MAX_W,MAX_H = 180,240
+ imW = Image.new('RGB', (MAX_W, MAX_H), (0, 0, 0, 0))
+ drawW = ImageDraw.Draw(imW)
+ dom = parseString(wwwWetter)
+- for node in dom.getElementsByTagName('forecast_information'):
+- for unitsystem in node.getElementsByTagName('unit_system'):
+- UnitSystem = unitsystem.getAttribute('data')
+- if ConfigType != "3" and ConfigType != "4":
+- font = ImageFont.truetype(FONT,20*Wmulti, encoding='unic')
+- Day="?"
+- High="?"
+- Low="?"
+- Icon=""
+- for node in dom.getElementsByTagName('forecast_conditions'):
+- for day_of_week in node.getElementsByTagName('day_of_week'):
+- Day = day_of_week.getAttribute('data')
+- for high in node.getElementsByTagName('high'):
+- High = high.getAttribute('data')
+- if UnitSystem == "US":
+- High = str(int((int(High)-32)*5/9))
+- for low in node.getElementsByTagName('low'):
+- Low = low.getAttribute('data')
+- if UnitSystem == "US":
+- Low = str(int((int(Low)-32)*5/9))
+- for icon in node.getElementsByTagName('icon'):
+- Icon = os.path.basename(icon.getAttribute('data'))
+-# print "WetterData", Day, Low, High, Icon
+- if os.path.isfile(WetterPath + Icon) and Icon.find("gif") > 1:
+- pil_image = Image.open(WetterPath + Icon)
+- if Wmulti != 1:
+- pil_image = pil_image.resize((int(40*Wmulti), int(40*Wmulti)), Image.ANTIALIAS) #BILINEAR)
+-# x,y=pil_image.size
+- imW.paste(pil_image,(POSX,POSY+(20*Wmulti)))
+- w,h = drawW.textsize(Day, font=font)
+- drawW.text((POSX, POSY), Day, font=font)
+- drawW.text((POSX, POSY+(60*Wmulti)), Low, font=font, fill="aquamarine")
+- drawW.text((POSX+(25*Wmulti), POSY+(60*Wmulti)), High, font=font, fill="violet")
+-
+- POSX += (54*Wmulti)
+- if Wmulti != 1:
+- POSX = 10
+- POSY += 90
+-
+- Hum = "?"
+- Wind = "?"
+- Temp_c = "?"
+- Icon=""
+- for node in dom.getElementsByTagName('current_conditions'):
+- for temp_c in node.getElementsByTagName('temp_c'):
+- Temp_c = temp_c.getAttribute('data') + "\xc2\xb0C"
+- for hum in node.getElementsByTagName('humidity'):
+- Hum1 = hum.getAttribute('data').replace("\xc2\xa0","").replace(" ","")
+- Hum1 = Hum1.split(":")
+- if len(Hum1) == 2:
+- Hum = Hum1[len(Hum1)-1].lstrip()
+- for wind in node.getElementsByTagName('wind_condition'):
+- Wind = wind.getAttribute('data')
+- Wind = Wind.split(":")
+- if len(Wind) == 2:
+- Wind = Wind[len(Wind)-1].lstrip()
+- for icon in node.getElementsByTagName('icon'):
+- Icon = os.path.basename(icon.getAttribute('data'))
+-# print "Temp, Hum", Temp_c, Hum, Wind, Icon
+- if os.path.isfile(WetterPath + Icon) and Icon.find("gif") > 1:
+- pil_image = Image.open(WetterPath + Icon)
+- if Wmulti != 1:
+- pil_image = pil_image.resize((int(40*Wmulti), int(40*Wmulti)), Image.ANTIALIAS) #BILINEAR)
+-# x,y=pil_image.size
+- if ConfigType == "4":
+- POSX = 10
+- imW.paste(pil_image,(POSX,POSY+(20*Wmulti)))
+- if ConfigType == "4":
+- font = ImageFont.truetype(FONT,(10*Wmulti), encoding='unic')
+- else:
+- font = ImageFont.truetype(FONT,(15*Wmulti), encoding='unic')
+- minus5 = 0 if Wmulti != 1 else 5
+- drawW.text((POSX-minus5, POSY+(64*Wmulti)), Wind, font=font, fill="silver")
+- if ConfigType == "4":
+- font = ImageFont.truetype(FONT,(20*Wmulti), encoding='unic')
+- else:
+- font = ImageFont.truetype(FONT,(25*Wmulti), encoding='unic')
+- drawW.text((POSX+(45*Wmulti), POSY+(16*Wmulti)), Temp_c, font=font, fill="violet")
+- if len(Hum)>3:
+- if ConfigType == "4":
+- font = ImageFont.truetype(FONT,(16*Wmulti), encoding='unic')
++ weather = dom.getElementsByTagName("weather")
++ if len(weather) == 0:
++ print "get weather failed"
++ return
++ else:
++ weather = weather[0]
++
++ def getFont(size):
++ return ImageFont.truetype(FONT, size, encoding='unic')
++
++ if ConfigType in ("1","2","3","4","5"):
++# forecast 4 days
++ if ConfigType in ("1","2"):
++ Day="?"; High="?"; Low="?"; Icon=""
++ font = getFont(20)
++ drawW.line((POSX, POSY, POSX, MAX_H), fill=ConfigColorLine)
++ forecast_num = 0
++ for node in weather.getElementsByTagName('forecast'):
++ forecast_num += 1
++ if ConfigType == "1" and forecast_num > 2:
++ break
++ elif ConfigType == "2" and forecast_num > 4:
++ break
++ Day = node.getAttribute('shortday')
++ High = node.getAttribute('high')
++ Low = node.getAttribute('low')
++ Icon = node.getAttribute('skycodeday')
++ Skytextday = node.getAttribute('skytextday')
++ Precip = node.getAttribute('precip')
++ iconpath = WetterPath + Icon+'.png'
++ if os.path.isfile(iconpath):
++ pil_image = Image.open(iconpath)
++ imW.paste(pil_image,(POSX+5,POSY+25), pil_image)
++ drawW.text((POSX+13, POSY), Day, font=font, fill=ConfigColorDay)
++ drawW.text((POSX+10, POSY+71), Low, font=font, fill=ConfigColorLow)
++ drawW.text((POSX+37, POSY+71), High, font=font, fill=ConfigColorHigh)
++ drawW.line((POSX+65, POSY, POSX+65, MAX_H), fill=ConfigColorLine)
++ POSX += 65
++ elif ConfigType in ("3", "4", "5"):
++ Day="?"; High="?"; Low="?"; Icon=""
++ if ConfigType == "5":
++ POSX, POSY = 5,120
++# if ConfigType in ("3"):
++# drawW.line((0, 0, MAX_W/2, 0), fill=ConfigColorLine)
++# elif ConfigType in ("4"):
++# drawW.line((0, 0, MAX_W, 0), fill=ConfigColorLine)
++ if ConfigType in ("5"):
++ drawW.line((0, POSY, MAX_W, POSY), fill=ConfigColorLine)
++ forecast_num = 0
++ for node in weather.getElementsByTagName('forecast'):
++ forecast_num += 1
++ if ConfigType in ("3", "4") and forecast_num > 4:
++ break
++ elif ConfigType == "5" and forecast_num > 2:
++ break
++ Day = node.getAttribute('day')
++ Low = node.getAttribute('low') + "\xc2\xb0"
++ High = node.getAttribute('high') + "\xc2\xb0"
++ Icon = node.getAttribute('skycodeday')
++ Skytextday = node.getAttribute('skytextday')
++ Precip = node.getAttribute('precip')
++ iconpath = WetterPath + Icon+'.png'
++ if os.path.isfile(iconpath):
++ pil_image = Image.open(iconpath)
++# icon_w, icon_h = 55,45
++ icon_w, icon_h = int(55*1.2), int(45*1.2)
++ pil_image = pil_image.resize( (icon_w, icon_h), Image.ANTIALIAS) #BILINEAR)
++ imW.paste(pil_image,(POSX, POSY), pil_image)
++ font = getFont(15)
++ drawW.text((POSX+icon_w-20, POSY-2), Precip, font=font, fill="cyan")
++ drawW.text((POSX+icon_w+5, POSY+5), Day, font=font, fill=ConfigColorDay)
++ drawW.text((POSX+icon_w+5, POSY+20), Low, font=font, fill=ConfigColorLow)
++ drawW.text((POSX+icon_w+30, POSY+20), High, font=font, fill=ConfigColorHigh)
++ drawW.text((POSX+icon_w+5, POSY+35), Skytextday, font=font, fill=ConfigColorSky)
++ if ConfigType == "3":
++ drawW.line((POSX, POSY+55, MAX_W/2, POSY+55), fill=ConfigColorLine)
++ else:
++ drawW.line((POSX, POSY+55, MAX_W, POSY+55), fill=ConfigColorLine)
++ POSY += 60
++
++# current info
++ if ConfigType in ("1","2","5"):
++ if ConfigType == "5":
++ POSX, POSY = 15,15
++ Hum = "?"; Wind = "?"; Temp = "?"; Icon=""
++ current = weather.getElementsByTagName('current')
++ if len(current) == 0:
++ print "get current failed"
++ else:
++ current = current[0]
++ ObservationPoint = current.getAttribute('observationpoint')
++ ObservationTime = current.getAttribute('observationtime')
++ Temp = current.getAttribute('temperature') + "\xc2\xb0"
++ Hum = current.getAttribute('humidity') + "%"
++ Wind = current.getAttribute('winddisplay')
++ Icon = current.getAttribute("skycode")
++ iconpath = WetterPath + Icon+'.png'
++ if os.path.isfile(iconpath):
++ pil_image = Image.open(iconpath)
++ pil_image = pil_image.resize((int(55*1.4), int(45*1.4)), Image.ANTIALIAS) #BILINEAR)
++ imW.paste(pil_image,(POSX+5, POSY+5+10), pil_image)
++ drawW.text((POSX+5, POSY), ObservationPoint+' '+ObservationTime, font=getFont(12), fill=ConfigColorCity)
++ drawW.text((POSX+15+62, POSY+5+15), Temp, font=getFont(25), fill=ConfigColorHigh)
++ drawW.text((POSX+15+62, POSY+5+40), Hum, font=getFont(22), fill=ConfigColorLow)
++ drawW.text((POSX+5, POSY+80), Wind, font=getFont(15), fill=ConfigColorSky)
++
++ elif ConfigType in ("3"):
++ POSX, POSY = 200,5
++ drawW.line((POSX, POSY, POSX, MAX_H), fill=ConfigColorLine)
++ Hum = "?"; Wind = "?"; Temp = "?"; Icon=""
++ current = weather.getElementsByTagName('current')
++ if len(current) == 0:
++ print "get current failed"
++ return
+ else:
+- font = ImageFont.truetype(FONT,(22*Wmulti), encoding='unic')
+- drawW.text((POSX+(45*Wmulti), POSY+(37*Wmulti)), Hum, font=font, fill="silver")
++ current = current[0]
++ ObservationPoint = current.getAttribute('observationpoint')
++ ObservationTime = current.getAttribute('observationtime')
++ Temp = 'Temp. : '+ current.getAttribute('temperature') + "\xc2\xb0"
++ Hum = 'Hum : '+ current.getAttribute('humidity') + "%"
++ Wind = 'Wind : '+ current.getAttribute('winddisplay')
++ Icon = current.getAttribute("skycode")
++ Skytext = 'Cond : ' + current.getAttribute('skytext')
++ Feelslike = 'Feel : '+ current.getAttribute('feelslike')
++ Date = 'Date : ' + current.getAttribute('date')
++ iconpath = WetterPath + Icon+'.png'
++ icon_w, icon_h = int(55*2.8), int(45*2.8)
++ if os.path.isfile(iconpath):
++ pil_image = Image.open(iconpath)
++ pil_image = pil_image.resize( (icon_w, icon_h), Image.ANTIALIAS) #BILINEAR
++ imW.paste(pil_image,(POSX+5, POSY+5), pil_image)
++ font = getFont(15)
++ drawW.text((POSX+20, POSY+3+icon_h), Temp, font=font, fill=ConfigColorHigh)
++ drawW.text((POSX+20+80, POSY+3+icon_h), Hum, font=font, fill=ConfigColorLow)
++ drawW.text((POSX+20, POSY+3+icon_h+20), Skytext, font=font, fill=ConfigColorSky)
++ drawW.text((POSX+20, POSY+3+icon_h+40), Wind, font=font, fill=ConfigColorLow)
++ drawW.text((POSX+20, POSY+3+icon_h+60), Date, font=font, fill=ConfigColorCity)
++ font = ImageFont.truetype(FONT,15, encoding='unic')
++ drawW.text((POSX+20, MAX_H-25), ObservationPoint+' '+ObservationTime, font=font, fill=ConfigColorCity)
++# save Image
+ imW.save(PICwetter)
+- im.paste(imW,(0,ConfigPos))
++ im.paste(imW,(ConfigPosX,ConfigPosY))
+ return
+
+ # Text File
+@@ -1977,51 +2079,6 @@