vielen Dank
Beiträge von digis
-
-
Mit dem Funktion Vererbung verstehe ich nicht.
Zählervariable in class BoX2 ausgeben.
Kann mir jemand helfen ??
Python
Alles anzeigenlass BoxUpDate(Screen): skin =""" <screen position="center,center" size="950,500" title="BoxUpDate" > <widget name="text" position="center,230" size="800,70" halign="center" font="Regular;64"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self["text"] = Label(_("test")) self.zahler = '' self['actions'] = ActionMap(['OkCancelActions', 'ColorActions', 'WizardActions', 'DirectionActions'], { "ok": self.test, "cancel": self.del_zahler, }, -1) self["NumberActions"] = NumberActionMap( [ "NumberActions"], { "1": self.keyNumber, "2": self.keyNumber, "3": self.keyNumber, "4": self.keyNumber, "5": self.keyNumber, "6": self.keyNumber, "7": self.keyNumber, "8": self.keyNumber, "9": self.keyNumber, "0": self.keyNumber, }) def keyNumber(self, number): number = str(int(number)) if self.zahler == '': self["text"].setText(_("test")) self.zahler += number self["text"].setText(_(self.zahler)) def del_zahler(self): if len(self.zahler) == 0: self.close() else: self.zahler = self.zahler[0:-1] if len(self.zahler) == 0: self.close() else: self["text"].setText(_(self.zahler)) def test(self): if len(self.zahler) > 0: self.session.openWithCallback(self.close, BoX2) class BoX2(BoxUpDate): skin =""" <screen position="center,50" size="950,500" title="BoX2" flags="wfNoBorder" > <widget name="text2" position="center,230" size="800,70" halign="center" font="Regular;64"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) #BoxUpDate.__init__(self, session) self['text2'] = Label() self["aboutActions"] = ActionMap(["ShortcutActions", "WizardActions", "InfobarEPGActions"], { "back": self.close, }, -1) self.test_text2() def test_text2(self): self['text2'].setText(_(self.zahler)) def exit(self): self.close()
-
vielen Dank
-
Python
Alles anzeigenclass MDscripts(Screen): skin = """ <screen position="center,center" size="950,550" title="TEST" > <widget name="progress" position="10,10" size="620,10" backgroundColor="#54242424" /> <widget name="header" position="10,25" size="620,390" font="Regular;40" backgroundColor="#54242424" valign="center" halign="center" transparent="1"/> <widget name="info" position="10,400" size="920,60" font="Regular;40" backgroundColor="#54242424" transparent="1" zPosition="5"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self['header'] = Label(_('1.header')) self['info'] = Label(_('2.info')) #self['progress'] = Label(_(' ')) self['progress'] = Label() self['progress'].show() self.progress = 0 self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): agent = 'Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0' self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.file = 'python-2.7.18.amd64.msi' self.local = '/tmp/'+self.file self['header'].setText(_('Downloading')) self['info'].setText(self.file) self.download = downloadWithProgress(self.url, self.local, agent=agent) self.download.addProgress(self.downloadProgress) self.download.start().addCallback(self.DownloadFinished).addErrback(self.DownloadFailed) def DownloadFailed(self): self.download.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self, recvbytes, totalbytes): self.progress = int(100 * recvbytes/float(totalbytes)) self['progress'].setText(_(self.progress)) def DownloadFinished(self): self.download.stop() self['header'].setText(_('erfolgreich'))
Etwas ist immer noch falsch noch kein Wert
-
Python
Alles anzeigenclass MDscripts(Screen): skin = """ <screen position="center,center" size="950,550" title="TEST" > <widget name="progress" position="10,10" size="620,10" backgroundColor="#54242424" /> <widget name="header" position="10,25" size="620,390" font="Regular;40" backgroundColor="#54242424" valign="center" halign="center" transparent="1"/> <widget name="info" position="10,400" size="920,60" font="Regular;40" backgroundColor="#54242424" transparent="1" zPosition="5"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self['header'] = Label(_('1.header')) self['info'] = Label(_('2.info')) #self['progress'] = Label(_(' ')) self['progress'] = Label() self['progress'].hide() self.progress = 0 self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): agent = 'Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0' self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.file = 'python-2.7.18.amd64.msi' self.local = '/tmp/'+self.file self['header'].setText(_('Downloading')) self['info'].setText(self.file) self.download = downloadWithProgress(self.url, self.local, agent=agent) self.download.addProgress(self.downloadProgress) self.download.start().addCallback(self.DownloadFinished).addErrback(self.DownloadFailed) def DownloadFailed(self): self.download.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self, recvbytes, totalbytes): self.progress = int(100 * recvbytes/float(totalbytes)) def DownloadFinished(self): self.download.stop() self['header'].setText(_('erfolgreich'))
Datei herunterladen funktioniert aber,
jetzt fehlt nur noch Fortschrittsbalken und DownloadFinished Mitteilung.
Kein crash.log
-
Python
Alles anzeigenclass test(Screen): skin = """ <screen position="center,center" size="640,280" backgroundColor="#54242424" title="TEST" > <widget name="header" position="5,5" size="350,60" font="Regular;40" backgroundColor="#54242424"/> <widget name="info" position="5,70" size="350,60" font="Regular;24" backgroundColor="#54242424"/> <widget name="progress" position="5,140" size="350,60" backgroundColor="#54242424"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session #self.DownloadFinished = DownloadFinished #self.DownloadFailed = DownloadFailed self['header'] = Label(_('header')) self['info'] = Label(_('info')) self['progress'] = Label() self['progress'].hide() self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.file = 'python-2.7.18.amd64.msi' self.local = '/tmp/'+self.file self['header'].setText(_('Downloading')) self['info'].setText(self.file) self.download = downloadWithProgress(self.url, self.local) self.download.addProgress(self.downloadProgress) self.download.start().addCallback(self.DownloadFinished).addErrback(self.DownloadFailed) def DownloadFailed(self): self.downloader.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self, recvbytes, totalbytes): self['progress'].setValue(int(100 * recvbytes / totalbytes)) def DownloadFinished(self): self.close() def abort(self): self.close()
Keine Fortschrittsanzeige(Fortschrittsbalken),
Datei herunterladen funktioniert nicht.
Kein crash.log
-
Code
0xb4b6268c(sp=0xbeec1bc0) <PyEval_EvalFrameEx+24024> Traceback (most recent call last): File "/usr/lib/enigma2/python/enigma.py", line 8610, in __call__ return ret(*args, **kwargs) File "/usr/lib/enigma2/python/Components/ActionMap.py", line 70, in action res = act() File "/usr/lib/enigma2/python/Plugins/Extensions/test/test.py", line 57, in startDownload self.downloader.addEnd(self.downloadEnd) ------- AttributeError: downloadWithProgress instance has no attribute 'addEnd'
-
Python
Alles anzeigenclass test(Screen): skin = """ <screen position="center,center" size="640,150" backgroundColor="#54242424" title="TEST" > <widget name="header" position="5,10" size="10,50" font="Regular;40" backgroundColor="#54242424"/> <widget name="info" position="5,60" size="10,130" font="Regular;24" backgroundColor="#54242424"/> <widget name="progress" position="5,39" size="10,24" backgroundColor="#54242424"/> </screen>""" def __init__(self, session): Screen.__init__(self, session) self.session = session self.downloader = None self['header'] = Label(_('test')) self['info'] = Label(_('test')) self['progress'] = ProgressBar() self['progress'].setRange((0, 100)) self['progress'].setValue(0) self['actions'] = ActionMap(['OkCancelActions', 'ColorActions'], {'cancel': self.abort, 'red': self.abort, 'ok': self.startDownload, 'green': self.startDownload}, -1) def startDownload(self): from Tools.Downloader import downloadWithProgress self.url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi' self.local = '/tmp/python-2.7.18.amd64.msi' self['header'].setText(_('Downloading')) self['info'].setText(self.local) self.downloader = downloadWithProgress(self.url, self.local) self.downloader.addProgress(self.downloadProgress) self.downloader.addEnd(self.downloadEnd) self.downloader.addError(self.downloadError) self.downloader.start() def downloadError(self): self.downloader.stop() self.session.openWithCallback(self.abort, MessageBox, _('Error during downloading image\n%s\n%s') % (self.local), type=MessageBox.TYPE_ERROR) def downloadProgress(self): self['progress'].setValue(int(100 * current / total)) def downloadEnd(self): self.downloader.stop() def abort(self): if self.downloader: self.downloader.stop() self.close()
Vieles habe ich gemacht aber komme ich trotzdem nicht vorwärts,
irgendwo ist kleine Fehler ??
-
Das liegt an der Funktion http_progress,
sorry für meine Fehlerbeschreibung.
Habe für alle Linien # gesetzt,
print "test"
das war mein Test
-
-
Egal was ich mache das wird einfach nicht,
ich kapiere das nicht.
Code
Alles anzeigendef test(self): file = '/tmp/python-2.7.18.amd64.msi' file_url = 'https://www.python.org/ftp/python/2.7.18/python-2.7.18.amd64.msi ' try: self["info"].setText(_('bitte warten..')) dowenload = urllib.urlretrieve(file_url, file) if os.path.exists(file): self["text"].setText(_("successful")) else: self["text"].setText('error 1') except: self["text"].setText('error 2')
-
Sehr lange Quellcode,das ist bisschen kompliziert.
Ich bin Anfänger, konnte ich ein Beispiel bekommen??
-
Beim Herunterladen der Datei möchte ich Informationen anzeigen, bitte warten.
-
-
vielen vielen Dank jetzt habe ich kapiert es funktioniert
-
Python
Alles anzeigenclass test(Screen): skin = """ <screen position="center,center" size="850,550" title="%s" > <widget name="text" position="20,20" size="810,370" valign="center" foregroundColor="#ffffff" font="Regular;30" halign="center" transparent="1" /> <widget name="info" position="50,400" size="800,50" valign="center" foregroundColor="#ffffff" font="Regular;30" halign="center" transparent="1" /> </screen>"""% _(VERSION) # def __init__(self, session, args=None): Screen.__init__(self, session) self.session = session self.urls = ['google.de', 'test.org'] self.colorGreen = parseColor("#00e100") self.colorRed = parseColor("#FF0000") self.colorBlue = parseColor("#0000FF") self.colorBlack = parseColor("#000000") self.colorWhite = parseColor("#FFFFFF") self.colorYellow = parseColor("#FFFF00") self.t = str(time.strftime("%Y%m%d%H%M")) self.file_log = '/tmp/' + self.t + '.txt' self["info"] = Label(_("info")) self["text"] = Label(_("Please wait... \ndowenload")) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], { "ok": self.url_test, "green": self.run, "back": self.close, "cancel": self.close, "red": self.close, }, -1) def url(self): for url in self.urls: try: res = urllib2.urlopen("http://"+url) code = res.getcode() if code == 200: print url return url else: self["text"].setText(_("no url")) self["text"].instance.setForegroundColor(self.colorRed) except: self["text"].setText(_("error url")) self["text"].instance.setForegroundColor(self.colorRed) return " " def url_test(self): url = self.url() self["text"].setText(url) self["text"].instance.setForegroundColor(self.colorRed)
-
self["info"] = Label(_("info") so habe ich definiert.
nach dem Start Plugin
per Fernbedienung kann ich die Farbe ändern.
automatisch bei aufrufen funktioniert es nicht
-
self["info"].instance.setForegroundColor(self.colorRed)
AttributeError: 'NoneType' object has no attribute 'setForegroundColor'
swig director exception (SWIG director method error.)
irgendwie habe ich keine Rechte,
bei aufrufen.
Erst nach dem Start darf ich ändern
-
Hallo wieder ich,
ich habe nie einen Fehler Funktion mit Farbe wechseln gebaut .
Wenn ich per Taste aufrufe geht es,
aber automatisch aufrufen geht es nicht.
if test == 0:
self.OK()
else:
self.erro()
def erro(self):
self["info"].setText(_("INFO"))
#self["info"].instance.setForegroundColor(self.colorRed)
-
Besteht eine Möglichkeit die Farbe zu ändern oder ersetzen ???
try:
self["info"].setText(_(foregroundColor="# Color1 " + ausgabe))
except:
self["info"].setText(_(foregroundColor="# Color2 " + ausgabe))