Skip to content

Commit 143bb96

Browse files
authored
Merge pull request #19 from Hains/python3
Update LCD4Linux V5.0-r32
2 parents 8b1ae5c + fd1f962 commit 143bb96

File tree

2 files changed

+39
-40
lines changed

2 files changed

+39
-40
lines changed

lcd4linux/src/myFileList.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ def canDescent(self):
208208

209209
def descent(self):
210210
if self.getSelection() != "":
211-
se = (self.current_directory if self.current_directory.endswith("/") else os_path.basename(self.current_directory)) if self.current_directory is not None else ""
211+
se = ""
212+
if self.current_directory is not None:
213+
se = self.current_directory if self.current_directory.endswith("/") else os_path.basename(self.current_directory)
212214
self.changeDir(self.getSelection()[0], select=se)
213215

214216
def getFilename(self):

lcd4linux/src/plugin.py

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
if find_library("usb-0.1") is not None or find_library("usb-1.0") is not None:
173173
print("[LCD4linux] libusb found :-)", getEnigmaVersionString())
174174
USBok = True
175-
Version = "V5.0-r29"
175+
Version = "V5.0-r32"
176176
L4LElist = L4Lelement()
177177
L4LdoThread = True
178178
LCD4enigma2config = resolveFilename(SCOPE_CONFIG) # /etc/enigma2/
@@ -3247,7 +3247,7 @@ def writeLCD1(s, im, quality, SAVE=True):
32473247
doDPF(1, im, s)
32483248
if "1" in LCD4linux.SavePicture.value and SAVE == True:
32493249
if str(LCD4linux.LCDRotate1.value) != "0":
3250-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value))
3250+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True)
32513251
try:
32523252
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
32533253
if isfile(bild):
@@ -3269,7 +3269,7 @@ def writeLCD1(s, im, quality, SAVE=True):
32693269
s.im[im].save("/tmp/usbtft-bmp", "BMP")
32703270
if "1" in LCD4linux.SavePicture.value and SAVE == True:
32713271
if str(LCD4linux.LCDRotate1.value) != "0":
3272-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value))
3272+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True)
32733273
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
32743274
if isfile(bild):
32753275
rename(bild, "%s.png" % PIC)
@@ -3280,7 +3280,7 @@ def writeLCD1(s, im, quality, SAVE=True):
32803280
try:
32813281
if "1" in LCD4linux.SavePicture.value and SAVE == True:
32823282
if str(LCD4linux.LCDRotate1.value) != "0":
3283-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value))
3283+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True)
32843284
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
32853285
if isfile(bild):
32863286
rename(bild, "%s.png" % PIC)
@@ -3331,7 +3331,7 @@ def writeLCD1(s, im, quality, SAVE=True):
33313331
try:
33323332
datei = "%s.jpg" % PICtmp
33333333
if str(LCD4linux.LCDRotate1.value) != "0":
3334-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value))
3334+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate1.value), expand=True)
33353335
s.im[im].save(datei, "JPEG")
33363336
elif pic is not None:
33373337
open(datei, "wb").write(pic)
@@ -3367,7 +3367,7 @@ def writeLCD2(s, im, quality, SAVE=True):
33673367
doDPF(2, im, s)
33683368
if "2" in LCD4linux.SavePicture.value and SAVE == True:
33693369
if str(LCD4linux.LCDRotate2.value) != "0":
3370-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value))
3370+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True)
33713371
try:
33723372
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
33733373
if isfile(bild):
@@ -3389,7 +3389,7 @@ def writeLCD2(s, im, quality, SAVE=True):
33893389
s.im[im].save("/tmp/usbtft-bmp", "BMP")
33903390
if "2" in LCD4linux.SavePicture.value and SAVE == True:
33913391
if str(LCD4linux.LCDRotate2.value) != "0":
3392-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value))
3392+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True)
33933393
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
33943394
if isfile(bild):
33953395
rename(bild, "%s.png" % PIC2)
@@ -3400,7 +3400,7 @@ def writeLCD2(s, im, quality, SAVE=True):
34003400
try:
34013401
if "2" in LCD4linux.SavePicture.value and SAVE == True:
34023402
if str(LCD4linux.LCDRotate2.value) != "0":
3403-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value))
3403+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True)
34043404
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
34053405
if isfile(bild):
34063406
rename(bild, "%s.png" % PIC2)
@@ -3451,7 +3451,7 @@ def writeLCD2(s, im, quality, SAVE=True):
34513451
try:
34523452
datei = "%s.jpg" % PIC2tmp
34533453
if str(LCD4linux.LCDRotate2.value) != "0":
3454-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value))
3454+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate2.value), expand=True)
34553455
s.im[im].save(datei, "JPEG")
34563456
elif pic is not None:
34573457
open(datei, "wb").write(pic)
@@ -3487,7 +3487,7 @@ def writeLCD3(s, im, quality, SAVE=True):
34873487
doDPF(3, im, s)
34883488
if "3" in LCD4linux.SavePicture.value and SAVE == True:
34893489
if str(LCD4linux.LCDRotate3.value) != "0":
3490-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value))
3490+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True)
34913491
try:
34923492
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
34933493
if isfile(bild):
@@ -3509,7 +3509,7 @@ def writeLCD3(s, im, quality, SAVE=True):
35093509
s.im[im].save("/tmp/usbtft-bmp", "BMP")
35103510
if "3" in LCD4linux.SavePicture.value and SAVE == True:
35113511
if str(LCD4linux.LCDRotate3.value) != "0":
3512-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value))
3512+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True)
35133513
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
35143514
if isfile(bild):
35153515
rename(bild, "%s.png" % PIC3)
@@ -3520,7 +3520,7 @@ def writeLCD3(s, im, quality, SAVE=True):
35203520
try:
35213521
if "3" in LCD4linux.SavePicture.value and SAVE == True:
35223522
if str(LCD4linux.LCDRotate3.value) != "0":
3523-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value))
3523+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True)
35243524
s.im[im].save(bild, "PNG" if LCD4linux.BilderTyp.value == "png" else "JPEG")
35253525
if isfile(bild):
35263526
rename(bild, "%s.png" % PIC3)
@@ -3571,7 +3571,7 @@ def writeLCD3(s, im, quality, SAVE=True):
35713571
try:
35723572
datei = "%s.jpg" % PIC3tmp
35733573
if str(LCD4linux.LCDRotate3.value) != "0":
3574-
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value))
3574+
s.im[im] = s.im[im].rotate(-int(LCD4linux.LCDRotate3.value), expand=True)
35753575
s.im[im].save(datei, "JPEG")
35763576
elif pic is not None:
35773577
open(datei, "wb").write(pic)
@@ -5264,12 +5264,13 @@ class LCDdisplayMenu(Screen):
52645264
skin = """
52655265
<screen position="center,center" size="600,380" title="LCD4linux - Config" >
52665266
<widget name="menu" position="10,20" size="580,350" scrollbarMode="showOnDemand" />
5267+
<eLabel name="button_red" position="10,340" size="6,36" backgroundColor="#00fe0000" zPosition="1" />
5268+
<widget source="key_red" render="Label" position="24,346" size="230,26" font="Regular;18" valign="center" halign="left" zPosition="1" />
52675269
</screen>"""
52685270

52695271
def __init__(self, session, args=None):
52705272
Screen.__init__(self, session)
52715273
self.session = session
5272-
self.list = []
52735274
self.SetList()
52745275
self["menu"] = MenuList(self.list)
52755276
self["key_red"] = StaticText(_("Delete"))
@@ -5286,10 +5287,11 @@ def SetList(self):
52865287
self.list.append((_("Load Defaults / Empty Config"), "LoadDefault", ""))
52875288
self.list.append((_("Save Config to File... (%s)") % LCD4linux.ConfigPath.value, "SaveToConfig", ""))
52885289
Cdir = sorted(glob(join(LCD4linux.ConfigPath.value, "*.lcd")))
5289-
xx = 3
5290+
self.xx = 3
52905291
for ii in Cdir:
5291-
self.list.append((_("Load File : %s") % basename(ii), "LoadFile %d" % xx, ii))
5292-
xx += 1
5292+
self.list.append((_("Load File : %s") % basename(ii), "LoadFile %d" % self.xx, ii))
5293+
self.xx += 1
5294+
self.LastSavedConfig = 0
52935295

52945296
def entfernen(self):
52955297
current = self["menu"].getCurrent()
@@ -5310,28 +5312,36 @@ def keyOK(self):
53105312
LCD4linux.loadFromFile(LCD4default)
53115313
LCD4linux.loadFromFile(LCD4config)
53125314
LCD4linux.load()
5315+
self.cancel()
53135316
elif currentEntry == "SaveToConfig":
5314-
self.session.openWithCallback(self.askForConfigName, InputBox, title="Save Filename", text="LCD4linux-%s" % (strftime("%Y%m%d_%H%M")), type=Input.TEXT)
5317+
if self.LastSavedConfig == 0:
5318+
self.session.openWithCallback(self.askForConfigName, InputBox, title="Save Filename", text="LCD4linux-%s" % (strftime("%Y%m%d_%H%M")), type=Input.TEXT)
53155319
elif currentEntry.startswith("LoadFile"):
53165320
if isfile(current[2]):
53175321
L4LoadNewConfig(current[2])
5322+
self.cancel()
53185323
elif currentEntry == "LoadDefault" and isfile(LCD4default):
53195324
L4log("Config-Load", LCD4default)
53205325
LCD4linux.loadFromFile(LCD4default)
53215326
LCD4linux.load()
5327+
self.cancel()
53225328

53235329
def askForConfigName(self, name):
53245330
if name is not None and isdir(LCD4linux.ConfigPath.value):
53255331
LCD4linux.save()
53265332
LCD4linux.saveToFile(join(LCD4linux.ConfigPath.value, "%s.lcd" % name))
5327-
self.list.append((_("Load File : %s") % ("%s.lcd" % name), "LoadFile", join(LCD4linux.ConfigPath.value, "%s.lcd" % name)))
5333+
self.list.append((_("Load File : %s") % ("%s.lcd" % name), "LoadFile %d" % self.xx, join(LCD4linux.ConfigPath.value, "%s.lcd" % name)))
5334+
self.LastSavedConfig = self.xx
5335+
self.xx += 1
53285336

53295337
def askForDelete(self, retval):
53305338
if (retval):
53315339
current = self["menu"].getCurrent()
53325340
if current and isfile(current[2]):
53335341
currentEntry = current[1]
53345342
i = int(currentEntry.split()[1])
5343+
if i == self.LastSavedConfig:
5344+
self.LastSavedConfig = 0
53355345
self.list[i] = (_("deleted"),) + self.list[i][1:]
53365346
rmFile(current[2])
53375347

@@ -5545,8 +5555,6 @@ def __init__(self, session, args=0):
55455555
self.mode = _("Global")
55465556
self.LastSelect = "4"
55475557
self.SetList()
5548-
if self.selectionChanged not in self["config"].onSelectionChanged:
5549-
self["config"].onSelectionChanged.append(self.selectionChanged)
55505558
if LCD4linux.LCDType3.value == "00":
55515559
self["LCD3"].hide()
55525560
if getDesktop(0).size().width() < 1000:
@@ -7920,7 +7928,7 @@ def keyOK(self):
79207928
elif sel in [LCD4linux.MPBildFile, LCD4linux.MPBild2File, LCD4linux.StandbyBildFile, LCD4linux.StandbyBild2File, LCD4linux.StandbyBild3File, LCD4linux.StandbyBild4File, LCD4linux.StandbyBild5File, LCD4linux.StandbyBild6File, LCD4linux.StandbyTextFile, LCD4linux.StandbyText2File, LCD4linux.StandbyText3File]:
79217929
L4log("select File 4")
79227930
self.session.openWithCallback(self.fileSelected, LCDdisplayFile, text=_("Choose file"), FileName=self["config"].getCurrent()[1].value, showFiles=True)
7923-
elif sel in [LCD4linux.Background1Bild, LCD4linux.LCD4linux.MPBackground1Bild, LCD4linux.StandbyBackground1Bild]:
7931+
elif sel in [LCD4linux.Background1Bild, LCD4linux.MPBackground1Bild, LCD4linux.StandbyBackground1Bild]:
79247932
L4log("select File 5")
79257933
self.session.openWithCallback(self.fileSelected, LCDdisplayFile, text=_("Choose file"), FileName=self["config"].getCurrent()[1].value, showFiles=True)
79267934
except Exception as err:
@@ -8167,6 +8175,7 @@ def selectionChanged(self):
81678175
L4log("removed old Skindata")
81688176
xmlWrite()
81698177
xmlClear()
8178+
self.SetList()
81708179

81718180
def getCurrentValue(self):
81728181
return str(self["config"].getCurrent()[1].getText())
@@ -8262,18 +8271,6 @@ def cancel(self):
82628271
isMediaPlayer = self.SaveisMediaPlayer
82638272
TFTCheck(False)
82648273

8265-
def keyLeft(self):
8266-
L4logE("key L")
8267-
self.LastSelect = str(self["config"].getCurrentIndex()) + self.getCurrentValue()[:3]
8268-
ConfigListScreen.keyLeft(self)
8269-
self.SetList()
8270-
8271-
def keyRight(self):
8272-
L4logE("key R")
8273-
self.LastSelect = str(self["config"].getCurrentIndex()) + self.getCurrentValue()[:3]
8274-
ConfigListScreen.keyRight(self)
8275-
self.SetList()
8276-
82778274
def restartGUI(self, answer):
82788275
if answer:
82798276
L4log("GUI Restart")
@@ -11712,7 +11709,7 @@ def putClock(workaround, draw, im):
1171211709
else:
1171311710
pil_image = pil_image.resize((x1, y1), Image.LANCZOS if PY3 else Image.ANTIALIAS)
1171411711
S = int(strftime("%H")) % 12
11715-
pil_image = pil_image.rotate(360 - int(30 * S + int(int(strftime("%M")) / 2))).convert("RGBA") # 360/12
11712+
pil_image = pil_image.rotate(360 - int(30 * S + int(int(strftime("%M")) / 2)), expand=False).convert("RGBA") # 360/12
1171611713
self.im[im].paste(pil_image, (POSX + int((x - x1) / 2), ConfigPos + int((y - y1) / 2)), pil_image)
1171711714
# Minute
1171811715
pil_image = Image.open(Clock + str(ConfigAnalog) + "/Minute.png")
@@ -11723,7 +11720,7 @@ def putClock(workaround, draw, im):
1172311720
pil_image = pil_image.resize((x1, y1))
1172411721
else:
1172511722
pil_image = pil_image.resize((x1, y1), Image.LANCZOS if PY3 else Image.ANTIALIAS)
11726-
pil_image = pil_image.rotate(360 - int(6 * int(strftime("%M")))).convert("RGBA") # 360/60
11723+
pil_image = pil_image.rotate(360 - int(6 * int(strftime("%M"))), expand=False).convert("RGBA") # 360/60
1172711724
self.im[im].paste(pil_image, (POSX + int((x - x1) / 2), ConfigPos + int((y - y1) / 2)), pil_image)
1172811725
# Seconds: Due to the bad refresh rates, the second hand was deliberately not programmed!
1172911726
# Date underneath clockface
@@ -15421,21 +15418,21 @@ def Lput4(LCD, SCR, FUNC, PARA):
1542115418
self.draw[1].rectangle((0, 0, MAX_W, MAX_H), fill="black")
1542215419
QuickList = [[], [], []]
1542315420
if str(LCD4linux.LCDRotate1.value) != "0":
15424-
self.im[1] = self.im[1].rotate(int(LCD4linux.LCDRotate1.value))
15421+
self.im[1] = self.im[1].rotate(int(LCD4linux.LCDRotate1.value), expand=True)
1542515422
Brief1.put([writeLCD1, self, 1, LCD4linux.BilderJPEG.value])
1542615423
if LCD4linux.LCDType2.value != "00" and self.Refresh >= LCD4linux.LCDRefresh2.value and not (getSA(2) in LCD4linux.TV.value and "2" in LCD4linux.TVLCD.value and not Standby.inStandby):
1542715424
if Dunkel and "2" in Dunkel:
1542815425
MAX_W, MAX_H = self.im[2].size
1542915426
self.draw[2].rectangle((0, 0, MAX_W, MAX_H), fill="black")
1543015427
if str(LCD4linux.LCDRotate2.value) != "0":
15431-
self.im[2] = self.im[2].rotate(int(LCD4linux.LCDRotate2.value))
15428+
self.im[2] = self.im[2].rotate(int(LCD4linux.LCDRotate2.value), expand=True)
1543215429
Brief2.put([writeLCD2, self, 2, LCD4linux.BilderJPEG.value])
1543315430
if LCD4linux.LCDType3.value != "00" and self.Refresh >= LCD4linux.LCDRefresh3.value and not (getSA(3) in LCD4linux.TV.value and "3" in LCD4linux.TVLCD.value and not Standby.inStandby):
1543415431
if Dunkel and "3" in Dunkel:
1543515432
MAX_W, MAX_H = self.im[3].size
1543615433
self.draw[3].rectangle((0, 0, MAX_W, MAX_H), fill="black")
1543715434
if str(LCD4linux.LCDRotate3.value) != "0":
15438-
self.im[3] = self.im[3].rotate(int(LCD4linux.LCDRotate3.value))
15435+
self.im[3] = self.im[3].rotate(int(LCD4linux.LCDRotate3.value), expand=True)
1543915436
Brief3.put([writeLCD3, self, 3, LCD4linux.BilderJPEG.value])
1544015437
Brief1.join()
1544115438
Brief2.join()

0 commit comments

Comments
 (0)