Jump to content


Photo

view and hide an image file on a TV screen (Python, Enigma-2)


  • Please log in to reply
43 replies to this topic

Re: view and hide an image file on a TV screen (Python, Enigma-2) #21 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 28 April 2018 - 01:50

My fault :)

 

The Enigma2 is continually restarting :)

02:48:00.4139 {   } Plugins/Extensions/AutoTimer/AutoPoller.py:19 __init__ [AutoTimer] Auto Poll Enabled
02:48:00.4175 {   } mytest.py:865 <module> EXCEPTION IN PYTHON STARTUP CODE:
02:48:00.4178 {   } mytest.py:866 <module> ------------------------------------------------------------
02:48:00.4180 { D } Traceback (most recent call last):
02:48:00.4183 { D }   File "/usr/lib/enigma2/python/mytest.py", line 859, in <module>
02:48:00.4201 { D }     runScreenTest()
02:48:00.4204 { D }   File "/usr/lib/enigma2/python/mytest.py", line 537, in runScreenTest
02:48:00.4206 { D }     plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
02:48:00.4208 { D }   File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 104, in readPluginList
02:48:00.4217 { D }   File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 30, in addPlugin
02:48:00.4223 { D } TypeError: autostartProc() takes exactly 1 argument (0 given)
02:48:00.4226 {   } mytest.py:868 <module> [mytest.py] quitMainloop #4
02:48:00.4230 {   } mytest.py:870 <module> ------------------------------------------------------------
02:48:00.4260 [   ] enigma.cpp:388 main [MAIN] (exit code 5)

Please... where exactly is now the problem in my code ? :)

Thanks.

###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
from enigma import eTimer
###########################################################################

class MyTest(Screen):

	skin = '\n  <screen position="0,0" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def showHide(self):
		if self.visible:
			self["pic"].hide()
			self.visible = False
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

def autostartProc(session, **kwargs):
	if "02:35" == datetime.datetime.now().strftime("%H:%M"):
		session.open(MyTest)
	self.cycleTimer = eTimer()
	self.cycleTimer.callback.append(self.autostartProc)
	self.cycleTimer.start(60000, False)    # 60 000 milisec. waiting

def myTest(session, **kwargs):
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = myTest)
			]



Re: view and hide an image file on a TV screen (Python, Enigma-2) #22 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 28 April 2018 - 06:32

You can start plugin automatically in session start. No need to navigate to plugins.

Edit. I was reading previous post yet. You are not passing session variable in function.

Edit2. See https://github.com/O...etMMI/plugin.py

You need to use properly the session start. Function autostart first argument is reason (not session).

Edited by athoik, 28 April 2018 - 06:43.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: view and hide an image file on a TV screen (Python, Enigma-2) #23 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 28 April 2018 - 08:00

This is proper use of autostart

def autostartAthanTimes(reason, **kwargs):
    global session
    try:
        if config.plugins.AthanTimes.notification.value == 'disabled':
            return
    except:
        pass

    if reason == 0:
        if openfile() == 'none':
            StayLoop.stopTimer
        else:
            StayLoop.startTimer()
    if reason == 0 and kwargs.has_key('session'):
        session = kwargs['session']
        session.open(DoPrayerTimesScreen)

also in your  autostartProc i suspect will launch the showing picture class because the timer runs every 60 seconds,mostly the firing timer event will bypass your assigned time("02:35")



Re: view and hide an image file on a TV screen (Python, Enigma-2) #24 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 28 April 2018 - 12:29

Sorry but this did not help me.

Enigma 2 is continually restarting (BSOD).

Endless defects in definitions: in self, session, global and runtime errors.

13:27:09.2663 {   } mytest.py:865 <module> EXCEPTION IN PYTHON STARTUP CODE:
13:27:09.2665 {   } mytest.py:866 <module> ------------------------------------------------------------
13:27:09.2669 { D } Traceback (most recent call last):
13:27:09.2672 { D }   File "/usr/lib/enigma2/python/mytest.py", line 859, in <module>
13:27:09.2692 { D }     runScreenTest()
13:27:09.2694 { D }   File "/usr/lib/enigma2/python/mytest.py", line 537, in runScreenTest
13:27:09.2697 { D }     plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
13:27:09.2699 { D }   File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 104, in readPluginList
13:27:09.2702 { D }   File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 30, in addPlugin
13:27:09.2707 { D }   File "/usr/lib/enigma2/python/Plugins/Extensions/AdRelax/plugin.py", line 67, in autostartProc
13:27:09.2713 { D }     self.cycleTimer = eTimer()
13:27:09.2717 { D } NameError: global name 'self' is not defined

"NameError: global name 'self' is not defined"

...global ?! name ?! :) global into the function is meanning as global ? wtf Python ?!

...even there is a prefix "self" but still, Python meant that it was a global term :)

...why such an error ?

 

Thanks.

###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
import datetime
from enigma import eTimer
###########################################################################

class MyTest(Screen):

	skin = '\n  <screen position="0,0" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def showHide(self):
		if self.visible:
			self["pic"].hide()
			self.visible = False
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

#def sessionstartProc(reason, **kwargs)
#	pass

def autostartProc(reason, **kwargs):
	global session
	#session = kwargs['session']
	if "12:37" == datetime.datetime.now().strftime("%H:%M"):
		session.open(MyTest)
	self.cycleTimer = eTimer()
	self.cycleTimer.callback.append(self.autostartProc)
	self.cycleTimer.start(60000, False)    # 60 000 milisec. waiting

def main(session, **kwargs):
	#global session
	#session = kwargs['session']
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
#		PluginDescriptor(
#			where = PluginDescriptor.WHERE_SESSIONSTART,
#			fnc = sessionstartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = main)
			]



Re: view and hide an image file on a TV screen (Python, Enigma-2) #25 betacentauri

  • PLi® Core member
  • 7,185 posts

+323
Excellent

Posted 28 April 2018 - 12:42

self is not defined (in the class it's a parameter in every method). So delete the "self."

	cycleTimer = eTimer()
	cycleTimer.callback.append(autostartProc)
	cycleTimer.start(60000, False)    # 60 000 milisec. waiting

But nevertheless I don't think this will work:

cycleTimer.callback.append(autostartProc)

 

autostartProc has parameters session and kwargs. autostartProc called by the timer will call it like this: autostartProc() and this will fail.

Better add new procedure which will be called.


Xtrend ET-9200, ET-8000, ET-10000, OpenPliPC on Ubuntu 12.04

Re: view and hide an image file on a TV screen (Python, Enigma-2) #26 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 28 April 2018 - 16:34

Hello again.

 

In my code is the checkingProc executed only once (1x only) :-/ and then stops.

###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
import datetime
from enigma import eTimer
###########################################################################

class MyTest(Screen):

	skin = '\n  <screen position="0,0" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False
		print('MYDEBUGLINE - picture opened - picture was shown')

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def showHide(self):
		if self.visible:
			self["pic"].hide()
			self.visible = False
			print('MYDEBUGLINE - picture will closed - hidden')
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

#def sessionstartProc(reason, **kwargs)
#	pass

def checkingProc():
	print('MYDEBUGLINE - checkingProc executed')
	if "17:30" == datetime.datetime.now().strftime("%H:%M"):
		print('MYDEBUGLINE - equal clock detected')
		session.open(MyTest)
	cycleTimer = eTimer()
	cycleTimer.callback.append(checkingProc)
	cycleTimer.start(60000, False)    # start with the 60 000 msec. idle time of cycle

def autostartProc(reason, **kwargs):
	global session
	#session = kwargs['session']
	checkingProc()

def main(session, **kwargs):
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		#PluginDescriptor(
		#	where = PluginDescriptor.WHERE_SESSIONSTART,
		#	fnc = sessionstartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = main)
			]


Edited by s3n0, 28 April 2018 - 16:35.


Re: view and hide an image file on a TV screen (Python, Enigma-2) #27 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 29 April 2018 - 02:02

Here is the second code where I dropped the specified eTimer from "checkingProc" to "autostartProc". However, the timer is not activated - not even once ("checkingProc").

In both cases (even in the previous code), no picture was displayed, but in the previous code at least one "checkingProc" was performed.

###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
import datetime
from enigma import eTimer
###########################################################################

class MyTest(Screen):

	skin = '\n  <screen position="0,0" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False
		print('MYDEBUGLINE - picture opened - picture was shown')

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def showHide(self):
		if self.visible:
			self["pic"].hide()
			self.visible = False
			print('MYDEBUGLINE - picture will closed - hidden')
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

#def sessionstartProc(reason, **kwargs)
#	pass

def checkingProc():
	print('MYDEBUGLINE - checkingProc executed')
	if "17:30" == datetime.datetime.now().strftime("%H:%M"):
		print('MYDEBUGLINE - equal clock detected')
		session.open(MyTest)

def autostartProc(reason, **kwargs):
	global session
	#session = kwargs['session']
	#checkingProc()
	cycleTimer = eTimer()
	cycleTimer.callback.append(checkingProc)
	cycleTimer.start(60000, True)    # start with the 60 000 msec. idle time of cycle

def main(session, **kwargs):
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		#PluginDescriptor(
		#	where = PluginDescriptor.WHERE_SESSIONSTART,
		#	fnc = sessionstartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = main)
			]



Re: view and hide an image file on a TV screen (Python, Enigma-2) #28 betacentauri

  • PLi® Core member
  • 7,185 posts

+323
Excellent

Posted 29 April 2018 - 07:51

Try to use a global variable cycleTimer.
A local variable will be destroyed when the procedure ends. So I guess the timer will be destroyed when autostartProc ends.
Xtrend ET-9200, ET-8000, ET-10000, OpenPliPC on Ubuntu 12.04

Re: view and hide an image file on a TV screen (Python, Enigma-2) #29 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 29 April 2018 - 13:48

Thank you, the global declaration helped. Procedure cycleProc is repeatedly started, every 60 seconds.

Another issue is now with session. What does session really work for ? :-/ I've read somewhere that the Screen must always run through session - like session.open(.......). But how do I then run the Screen to view the image if it is not possible to use the session ?

I tried to declare the seesion as global, but it causes problems as I already suspected.

See this error and this code:

14:39:36.6928 {   } mytest.py:865 <module> EXCEPTION IN PYTHON STARTUP CODE:
14:39:36.6930 {   } mytest.py:866 <module> ------------------------------------------------------------
14:39:36.6933 { D } Traceback (most recent call last):
14:39:36.6936 { D }   File "/usr/lib/enigma2/python/mytest.py", line 859, in <module>
14:39:36.6954 { D }     runScreenTest()
14:39:36.6956 { D }   File "/usr/lib/enigma2/python/mytest.py", line 537, in runScreenTest
14:39:36.6959 { D }     plugins.readPluginList(resolveFilename(SCOPE_PLUGINS))
14:39:36.6960 { D }   File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 104, in readPluginList
14:39:36.6965 { D }   File "/usr/lib/enigma2/python/Components/PluginComponent.py", line 30, in addPlugin
14:39:36.6968 { D }   File "/usr/lib/enigma2/python/Plugins/Extensions/AdRelax/plugin.py", line 77, in autostartProc
14:39:36.6976 { D }     checkingProc()
14:39:36.6977 { D }   File "/usr/lib/enigma2/python/Plugins/Extensions/AdRelax/plugin.py", line 70, in checkingProc
14:39:36.6980 { D }     session.open(MyTest)
14:39:36.6983 { D } NameError: global name 'session' is not defined
###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
import datetime
from enigma import eTimer
###########################################################################

class MyTest(Screen):

	skin = '\n  <screen position="0,0" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False
		print('MYDEBUGLINE - picture opened - picture was shown')

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def showHide(self):
		if self.visible:
			self["pic"].hide()
			self.visible = False
			print('MYDEBUGLINE - picture will closed - hidden')
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

#def sessionstartProc(reason, **kwargs)
#	pass

def checkingProc():
	print('MYDEBUGLINE - checkingProc executed')
	if "14:39" == datetime.datetime.now().strftime("%H:%M"):
		global session
		#session = kwargs['session']
		print('MYDEBUGLINE - equal clock detected')
		session.open(MyTest)

def autostartProc(reason, **kwargs):
	global cycleTimer
	cycleTimer = eTimer()
	cycleTimer.callback.append(checkingProc)
	cycleTimer.start(60000, False)    # start with the 60 000 msec. idle time of cycle
	checkingProc()

def main(session, **kwargs):
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		#PluginDescriptor(
		#	where = PluginDescriptor.WHERE_SESSIONSTART,
		#	fnc = sessionstartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = main)
			]



Re: view and hide an image file on a TV screen (Python, Enigma-2) #30 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 29 April 2018 - 14:46

EDIT:

 

I mean checkingProc , not cycleProc

 

My mistake. Sorry for that.



Re: view and hide an image file on a TV screen (Python, Enigma-2) #31 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 April 2018 - 16:41

No way to run screen without session

This code show your picture every minute,you can adjust for your need

###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
import datetime
from enigma import eTimer
###########################################################################
session=None
class MyTest(Screen):

	skin = '\n  <screen position="0,0" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False
		print('MYDEBUGLINE - picture opened - picture was shown')

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def showHide(self):
		if self.visible:
			self["pic"].hide()
			self.visible = False
			print('MYDEBUGLINE - picture will closed - hidden')
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

#def sessionstartProc(reason, **kwargs)
#	pass

def checkingProc():
	print('MYDEBUGLINE - checkingProc executed')
	if True:#"14:39" == datetime.datetime.now().strftime("%H:%M"):

		print('MYDEBUGLINE - equal clock detected')
		session.open(MyTest)

 
def autostartProc(reason, **kwargs):
       
        global session
        global cycleTimer
        
    
	if reason == 0 and kwargs.has_key('session'):
            session = kwargs['session']
            print "session started"
            cycleTimer = eTimer()
            cycleTimer.callback.append(checkingProc)
            cycleTimer.start(60000, False)    # start with the 60 000 msec. idle time of cycle
            checkingProc()

def main(session, **kwargs):
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		PluginDescriptor(
			where = PluginDescriptor.WHERE_SESSIONSTART,
			fnc = autostartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = main)
			]



Re: view and hide an image file on a TV screen (Python, Enigma-2) #32 mrvica

  • Senior Member
  • 1,227 posts

+81
Good

Posted 29 April 2018 - 17:18

amazing, I checked it out, if the picture is not the full screen you can see the part of the live picture, add backgroundColor
skin = '\n <screen position="0,0" backgroundColor="#ff000000" size="1280,720" >\n

Re: view and hide an image file on a TV screen (Python, Enigma-2) #33 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 29 April 2018 - 18:13

Thanks mfaraj57 !

 

Your code works. How is it possible ? Solving the problem was writing session = None at the beginning of your code ? Or where exactly is the solution in the code ?

 

As far as I know, the reason argument under Plugins represents the first Plugins call (0 - the first run ; 1 - another starting/opening of the plugin). So checking the argument reason is not necessary. Or must it be there ?

 

Thank you so far for all.



Re: view and hide an image file on a TV screen (Python, Enigma-2) #34 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 April 2018 - 18:41

As i understand you will not get declaration of session from autostart alone,so you should use sessionstart to get it and this is what i have done,just activated the sessionstart in plugin descriptor.Autostart runs before any enigma session started so will fail to get session while sessionstart should do this.

declaration of session as None i usually use with global declaration of any variable but not sure it is necessory.

About reasons ,value of reason 0  used for autostart while reason 1 used for shutdown.


Edited by mfaraj57, 29 April 2018 - 18:42.


Re: view and hide an image file on a TV screen (Python, Enigma-2) #35 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 29 April 2018 - 19:15

Yup, but what about the session ? What is this session ? Is it a method directly from the core of the enigma ? What exactly is it for ? I still have not understood it and I have already tried to search for Google.

 

I think I want a lot from you, but would anyone help me with ActionMaps ? Which ActionMaps do I use if I want to close the image by pressing any button on the remote ? I only know some simple ActionMaps for specific buttons, such as this code:

        self["myActionMap"] = ActionMap(["SetupActions"],
        {
            "ok": self.cancel,
            "cancel": self.cancel
        }, -1)

However, I would like something on this principle:

        self["myActionMap"] = ActionMap(["SetupActions"],
             {   "all": self.cancel   }, -1)

Thanks.



Re: view and hide an image file on a TV screen (Python, Enigma-2) #36 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 April 2018 - 21:18

Session is object and not specific for enigma,i know you will not satisfy by this answer but as i have said in my first post in this thread that somethings you have to use them first before fully understand.also i am not the proper person to explain it because i am not true coder or programmer.
A lot of documentation for python but nearly none for enigma.
About actionmaps there are many kind of actionmap and you have to look for different actionmaps in usr.share.enigma.keymap.xml and you cannot use any word like "all" and you should stick to what remote buttons mapped to in keymap.xml
You can use coloractions for using color remote buttons and you can assign any function to specific color like
"green",self.cancel as example


Edited by mfaraj57, 29 April 2018 - 21:21.


Re: view and hide an image file on a TV screen (Python, Enigma-2) #37 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 29 April 2018 - 21:44

OK, thanks, I understand.

It is very bad that there is no official documentation for Enigma 2, which is even Open Source. This means that there will always be very few developers for Enigma. Studying the Enigma-2 system will take many years (according to that complexity).

I have another problem right now:

 

If I add the above code with "ActionMap" to cancel the displayed image (OK, Cancel), then the image does not want to appear at all. In the DebugLOG file, I see the "MYDEBUGLINE - picture will closed - hidden" records and no errors. I will simply stop showing the PNG image when I add "ActionMap" to the code. I want there to be a possibility to interrupt the closing of the displayed image even via the RC button.



Re: view and hide an image file on a TV screen (Python, Enigma-2) #38 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 30 April 2018 - 07:05

Adding ActionMaps should not prevent the re-appearance of the picture again.the following code with actionmaps showing the image every minute for 15 seconds and if you want to prevent closing just use stay method by rc blue button

###########################################################################
#  Enigma2 plugin
###########################################################################

###########################################################################
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Components.ActionMap import ActionMap
from Screens.MessageBox import MessageBox
from Plugins.Plugin import PluginDescriptor
###########################################################################
from Components.Sources.CurrentService import CurrentService
import NavigationInstance
from time import sleep
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
import datetime
from enigma import eTimer
###########################################################################
session=None
class MyTest(Screen):

	skin = '\n  <screen position="center,center" size="1280,720" >\n <widget name="pic" position="0,0" size="1280,720" alphatest="on" />           </screen>'

	def __init__(self, session, args = 0):
		self.session = session
		Screen.__init__(self, session)
                self['actions'] = ActionMap(['ColorActions',
                 'SetupActions',
                 'DirectionActions',
                 'PiPSetupActions',
                 'WizardActions',
                 'NumberActions',
                 'NumberActions',
                 'EPGSelectActions',
                 'MenuActions'], {'red': self.close,                 
                 'ok': self.showHide,
                 'blue': self.stay,                
                 'cancel': self.showHide}, -1)

		
		self["pic"] = Pixmap()
		self.picload = ePicLoad()
		self.picload.PictureData.get().append(self.showPic)
		self.picload.getThumbnail('/usr/share/enigma2/skin_default/testscreen.png', 1280, 720)
		self.hideShowTimer = eTimer()
		self.hideShowTimer.callback.append(self.showHide)
		self.visible = False
		print('MYDEBUGLINE - picture opened - picture was shown')

	def showPic(self, picInfo=""):
		ptr = self.picload.getData()
		if ptr is not None:
			self["pic"].instance.setPixmap(ptr.__deref__())
			self["pic"].show()
			self.hideShowTimer.start(15000, False)    # 15 000 milisec. waiting
			self.visible = True

	def stay(self):
		
                        self.hideShowTimer.stop()
                        
                        self.visible=True
			
			
			
		


	def showHide(self):
		if self.visible:
                        self.hideShowTimer.stop()
                        self.hideShowTimer.callback.remove(self.showHide)
			self["pic"].hide()
			self.visible = False
			print('MYDEBUGLINE - picture will closed - hidden')
			self.close(None)
		else:		
			self["pic"].show()
			self.visible = True	

###########################################################################

#def sessionstartProc(reason, **kwargs)
#	pass

def checkingProc():
	print('MYDEBUGLINE - checkingProc executed')
	if True:#"14:39" == datetime.datetime.now().strftime("%H:%M"):

		print('MYDEBUGLINE - equal clock detected')
		session.open(MyTest)

 
def autostartProc(reason, **kwargs):
       
        global session
        global cycleTimer
        
    
	if reason == 0 and kwargs.has_key('session'):
            session = kwargs['session']
            print "session started"
            cycleTimer = eTimer()
            cycleTimer.callback.append(checkingProc)
            cycleTimer.start(60000, False)    # start with the 60 000 msec. idle time of cycle
            checkingProc()

def main(session, **kwargs):
	session.open(MyTest)
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		PluginDescriptor(
			where = PluginDescriptor.WHERE_SESSIONSTART,
			fnc = autostartProc),
		PluginDescriptor(
			name = "TesT plugin name",
			description = "TesT plugin descriptions",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = main)
			]


Edited by mfaraj57, 30 April 2018 - 07:06.


Re: view and hide an image file on a TV screen (Python, Enigma-2) #39 s3n0

  • Senior Member
  • 641 posts

+62
Good

Posted 30 April 2018 - 13:47

Hello again and thanks for helping.

 

I meant the opposite case. I just wanted to press any button to stop viewing the image and return processor control back to Enigma core (global actions...).
 

Maybe I've done something wrong before, because your ActionMap modification works. It's strange.

 

I do not know where my mistake was before:
- a syntax error ?
- wrong name in quotes - self['actions'] where I used self['myActionMap']
- lack of defined maps, because I have only defined one map - "SetupActions"
- different type of quotes (other quotes => other formatting of syntax inside quotes) - this last cause is unlikely :-)


Edited by s3n0, 30 April 2018 - 13:48.


Re: view and hide an image file on a TV screen (Python, Enigma-2) #40 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 30 April 2018 - 14:59

Do not know what,s the wrong with your code not showing image when adding ActionMaps 

syntax error should give crash because you did not  use  try...except to prevent crash.

quotes,single or double does not make difference.

lack of defined map,in your example SetupActions is enough for Ok and Cancel,in my exmaple also needs CororActions because i used red and blue buttons,other ActionMaps included in my exampleare  not required and can be omitted,I put them just to see some of ActionMaps used commonly.

 

Now to stop showing image you have to make settings screen and add option for enabling and disabling the viewing image process and add to check the value before execution of the checkingProc()

like this

def autostartProc(reason, **kwargs):
       
        global session
        global cycleTimer
        
        if config.TestPlugin.running.value==False:
            return
	if reason == 0 and kwargs.has_key('session'):
            session = kwargs['session']
            print "session started"
            cycleTimer = eTimer()
            cycleTimer.callback.append(checkingProc)
            cycleTimer.start(60000, False)    # start with the 60 000 msec. idle time of cycle
            checkingProc()



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users