Springen naar inhoud


Foto

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


  • Please log in to reply
Er zijn 43 reacties in dit onderwerp

#1 s3n0

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 23 april 2018 - 14:20

Hello.

Please help. Help the beginner Enigma2 developer.

I've discovered a 'ihash tutorial' designed for the basic Plugins creation with code examples. One example is the one that serves to display the image file. The rendering of the image is done using the SKIN / XML function (Python module - Screens.Screen).

Unfortunately, I still do not know how to use this code outside the plugin, in a separate script. I do not know how to modify this code to work outside this plugin (located in the Python Enigma core).

Where can I find some explanation of the 'Screens.Screen' enigma / python module (except for lengthy code study from Git-Hub servers, of course)? Some examples of practical, but understandable use of the 'Screens.Screen' module for rendering an image file would help. It is sad that the explanations and comments (bounded by separator """) for all functions, objects, classes, etc. ... are not used in the source code of Enigma and its modules.

Studying the code itself is quite difficult and lengthy for a novice developer. A good enigma2 developer must know the principle of the enigma2 system. Unfortunately, I did not grow on Enigma 1.x up to the current version 2.x, but I grew up with other systems and platforms (also as a programmer). Similarly, Python code programming is not yet an expert.

Thanks.

 

 

- content of the file /usr/lib/enigma2/python/Plugins/Extensions/lesson_07/plugin.py :

# Ihad.tv enigma2-plugin tutorial 2010
# lesson 7
# by emanuel
from Screens.Screen import Screen
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from Components.ActionMap import ActionMap
from Plugins.Plugin import PluginDescriptor
from enigma import ePicLoad

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

class PictureScreen(Screen):

    skin="""
        <screen name="PictureScreen" position="0,0" size="1280,720" title="Picture Screen" flags="wfNoBorder" backgroundColor="#002C2C39">
            <widget name="myPic" position="center,center" size="1280,720" zPosition="1" alphatest="on" />
        </screen>"""

    def __init__(self, session, picPath = None):
        Screen.__init__(self, session)
        print "[PictureScreen] __init__\n"
        self.picPath = picPath
        self.Scale = AVSwitch().getFramebufferScale()
        self.PicLoad = ePicLoad()
        self["myPic"] = Pixmap()
        self["myActionMap"] = ActionMap(["SetupActions"],
        {
            "ok": self.cancel,
            "cancel": self.cancel
        }, -1)
        
        self.PicLoad.PictureData.get().append(self.DecodePicture)
        self.onLayoutFinish.append(self.ShowPicture)

    def ShowPicture(self):
        if self.picPath is not None:
            self.PicLoad.setPara([
                        self["myPic"].instance.size().width(),
                        self["myPic"].instance.size().height(),
                        self.Scale[0],
                        self.Scale[1],
                        0,
                        1,
                        "#002C2C39"])
                        
            self.PicLoad.startDecode(self.picPath)

    def DecodePicture(self, PicInfo = ""):
        if self.picPath is not None:
            ptr = self.PicLoad.getData()
            self["myPic"].instance.setPixmap(ptr)


    def cancel(self):
        print "[PictureScreen] - cancel\n"
        self.close(None)
        
###########################################################################

def main(session, **kwargs):
    session.open(PictureScreen, picPath = "/usr/share/enigma2/skin_default/testscreen.png")

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

def Plugins(**kwargs):
    return PluginDescriptor(
            name="07 View a picture",
            description="lesson 7 - Ihad.tv e2-tutorial",
            where = PluginDescriptor.WHERE_PLUGINMENU,
            icon="../lesson_01/ihad_tut.png",
            fnc=main)


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

  • PLi® Core member
  • 68544 berichten

+1737
Excellent

Geplaatst op 23 april 2018 - 14:23

Enigma1 and Enigma2 share nothing but the name, so that is not a problem.

 

Unfortunately Enigma suffers from the same problem most open source projects suffer from. They aren't run professionally, nothing is documented. Dream Multimedia probably did it for a reason as well, something bad is less likely to be "stolen"...

 

Can you explain what you mean with "outside the plugin"?


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 23 april 2018 - 14:46

Can you explain what you mean with "outside the plugin"?

 

Of course. I'm sorry, I wrote badly.

The algorithm used to draw an image from a file can remain in the same script file ('plugin.py'). I run some function by auto-launch via PluginDescriptor.WHERE_AUTOSTART. The function is repeated with the 'threading' module every 60 seconds. This function should be able to display an image from a file on the TV screen at a specific scheduled time from - to (hours:minutes). At the end of this scheduled time (display time is approximately 1 minute), the image must be hidden again.

 

Allegedly, the 'threading' module is an inappropriate solution in all directions because it risks consolidation with other processes, threatening the system crash. But to test what I need, it might be enough. Later, if necessary, expand the timer for feedback and further tests to prevent system failure.

Thanks.


Veranderd door s3n0, 23 april 2018 - 14:48


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

  • PLi® Core member
  • 68544 berichten

+1737
Excellent

Geplaatst op 23 april 2018 - 16:06

If you want to perform timed based actions, use either a timer. See Timer.py.


Currently in use: VU+ Duo 4K (2xFBC S2), VU+ Solo 4K (1xFBC S2), uClan Usytm 4K Pro (S2+T2), Octagon SF8008 (S2+T2), Zgemma H9.2H (S2+T2)

Due to my bad health, I will not be very active at times and may be slow to respond. I will not read the forum or PM on a regular basis.

Many answers to your question can be found in our new and improved wiki.


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

  • Senior Member
  • 1605 berichten

+286
Excellent

Geplaatst op 23 april 2018 - 17:30

Displaying image for 60 seconds every 60 seconds(as i understood) will consume system resources and crash and system failure are expected.

but i do not understand why you want to do that?,PicturePlayer plugin can do that and expect it has slideshow option.



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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 23 april 2018 - 18:28

My main goal is to learn how to display graphics (JPG files) :-) .

The problem is I do not know how to use a "class". I do not know the class properties. I'm not a good Python programmer (at least yet). I'm still learning. This will take a long time. I have to start with some primitive functions. When working with rendering JPG images over the SKIN layer, I was always getting some bugs in DebugLOG.

Anyway, thank you guys for help.

Grrrrr...



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

  • Senior Member
  • 1605 berichten

+286
Excellent

Geplaatst op 23 april 2018 - 19:44

Plugins are not pure python but mixed with enigma2 functions and as begining you do not have to understand everything to use it.As example you can use the functions decodepicture and showpicture in any plugin to display picture and you have to supply the functions by picture path and the container and as begining to start with autostart is wrong decision

Veranderd door mfaraj57, 23 april 2018 - 19:45


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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 24 april 2018 - 19:47

Hello. All right, then what kind of solution do you suggest ? For example, I want to display a JPG file stored on the disk (in internal flash memory), ideally via the SKIN layer (XML code), when I press the function button "F2" (the set-top box of Formuler-F3 has three function buttons). How to do it ?



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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 24 april 2018 - 22:55

Or here is a direct example of using the code:

I want to see a monoscope image /usr/share/enigma2/skin_default/testscreen.png on TV screen every evening at 22.00 hours. And then at 5:00 in the morning, the picture will be hidden again (canceled). The image can be displayed, for example, over the SKIN layer, which will be above the viewed SAT channel. During the displayed monoscope, use the Audio MUTE function.



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

  • Senior Member
  • 1605 berichten

+286
Excellent

Geplaatst op 25 april 2018 - 09:28

To facilitate your job study the screengabber plugin attached and look how take screenshot by pressing text button as example then you can modify the code instead taking screenshot to display picture by using any remote button.Later on you can add etimer functionality to launch the picture at specific time.

Bijgevoegde Bestanden



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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 25 april 2018 - 21:59

Many thanks. I will try it.



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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 27 april 2018 - 02:09

No chance. I do not know what to do about it. I still do not know how to insert an image from a JPG file on the TV screen at a specified time and then hide it after 1 minute. The ScreenGrabber plugin has an incredibly long and complicated code that the novice does not understand.

For example, I can trigger an event at a set time, but Screens.Screen does not work. Something is wrong. I have tried a few examples of using the Screen, but it has always resulted in some error.

 

I've also tried the code that showed the image file on TV via XML using Screens.Screen, but there were problems.

The biggest problem is Real Time Error Debugging (Python interpreter under Enigma 2) to allow the programmer to experience the system. I would like to test in real time lots of solutions with different modules. Well, I can not. Python interpreter in Enigma 2 can not do this (problem importing modules).

###########################################################################
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 # pre pauzu - prikazovanie:  time.sleep(pocet_sekund)
###########################################################################
from Components.Label import Label
from Components.Pixmap import Pixmap
from Components.AVSwitch import AVSwitch
from enigma import ePicLoad
###########################################################################
from enigma import eTimer
import datetime
import threading
###########################################################################

class MyMenu(Screen):
    skin = """
        <screen position="100,150" size="460,400" title="Relax" >
            <widget name="myMenu" position="10,10" size="420,380" scrollbarMode="showOnDemand" />
        </screen>"""

    def __init__(self, session, args = 0):
        self.session = session
        
        list = []
        list.append((_("1 - get current service (unstable)"), "one"))
        list.append((_("2 - get currently playing service reference"), "two"))
        list.append((_("3 - cur (BSOD error)"), "tree"))
        list.append((_("4 - jpg test"), "four"))
        list.append((_("Exit"), "exit"))
        
        Screen.__init__(self, session)
        self["myMenu"] = MenuList(list)
        self["myActionMap"] = ActionMap(["SetupActions"],
        {
            "ok": self.go,
            "cancel": self.cancel
        }, -1)

    def go(self):
        returnValue = self["myMenu"].l.getCurrentSelection()[1]
        print "\n [MyMenu] returnValue: " + returnValue + "\n"
        
        if returnValue is not None:
            
            if returnValue is "one":
                #self.myMsg("You selected number 1")
                self.myMsg(CurrentService.getCurrentService)
                
            elif returnValue is "two":
                #self.myMsg("You selected number 2")
                cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
                if cur_ref is not None:                           
                    cur_retazec = cur_ref.toString()
                    print cur_retazec
                    self.myMsg(cur_retazec)
                    
            elif returnValue is "tree":
                #self.myMsg("You selected number 3")
                cur_srv = NavigationInstance.instance.getCurrentService()
                if cur_srv is not None:                           
                    cur_retazec = cur_ref.toString()
                    print cur_retazec
                    self.myMsg(cur_retazec)
                    
            elif returnValue is "four":
                showwImg()

            else:
                print " \n [MyMenu] cancel (from if..else) \n"
                self.close(None)
    
    def myMsg(self, retazec):
            self.session.open(MessageBox,_("%s") % (retazec), MessageBox.TYPE_INFO)
            
    def cancel(self):
        print " \n [MyMenu] cancel (from def)\n"
        self.close(None)

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

class PictureScreen(Screen):
    skin="""
        <screen name="PictureScreen" position="0,0" size="1280,720" title="Picture Screen" flags="wfNoBorder" backgroundColor="#002C2C39">
            <widget name="myPic" position="center,center" size="720,405" zPosition="11" alphatest="on" />
        </screen>"""
    
    #picPath = "/usr/share/enigma2/distro-logo.png"
    print " \n[PictureScreen] starting \n"

    def __init__(self, session, picPath = None):
        Screen.__init__(self, session)
        print "[PictureScreen] __init__\n"
        self.picPath = picPath
        self.Scale = AVSwitch().getFramebufferScale()
        self.PicLoad = ePicLoad()
        self["myPic"] = Pixmap()
        self["myActionMap"] = ActionMap(["SetupActions"],
        {
            "ok": self.cancel,
            "cancel": self.cancel
        }, -1)
        
        self.PicLoad.PictureData.get().append(self.DecodePicture)
        self.onLayoutFinish.append(self.ShowPicture)

    def ShowPicture(self):
        if self.picPath is not None:
            self.PicLoad.setPara([
                        self["myPic"].instance.size().width(),
                        self["myPic"].instance.size().height(),
                        self.Scale[0],
                        self.Scale[1],
                        0,
                        1,
                        "#002C2C39"])                    
            self.PicLoad.startDecode(self.picPath)

    def DecodePicture(self, PicInfo = ""):
        if self.picPath is not None:
            ptr = self.PicLoad.getData()
            self["myPic"].instance.setPixmap(ptr)

    def cancel(self):
        print " \n [PictureScreen] - cancel (from def)\n"
        self.close(None)

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

def otvoritMenu(session, **kwargs):
    print " \n[MyMenu] start\n"    
    session.open(MyMenu)

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

def showwImg(session, **kwargs):
    print " \n[showwImg] debug line\n"
    #session.openWithCallback(PictureScreen)
    session.open(PictureScreen, picPath = "/usr/share/enigma2/distro-logo.png")
    #self.session.openWithCallback(self.repeat, athantimescreen, "")

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

def autostartProc(reason, **kwargs):
    
    global session
    
    if reason == 0: # startup
        print " plugin - startup"
        repeatProgram()
    elif reason == 1:
        print " plugin - shutdown"
        threading.Timer(1.0, repeatProgram).cancel()

def repeatProgram():
    threading.Timer(60.0, repeatProgram).start()
    if "04:40" == datetime.datetime.now().strftime("%H:%M"):
        showwImg()    
    #print "repeatProgram - timing - debug line \n"
    
###########################################################################

def Plugins(**kwargs):
    return [
        PluginDescriptor(
            where = PluginDescriptor.WHERE_AUTOSTART,
            fnc = autostartProc),
        PluginDescriptor(
            name = "Ad-Relax (Settings)",
            description = "Relaxing instead of TV Advertising",
            where = PluginDescriptor.WHERE_PLUGINMENU,
            icon = "plugin.png",
            fnc = otvoritMenu)
            ]



 



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

  • PLi® Core member
  • 56258 berichten

+691
Excellent

Geplaatst op 27 april 2018 - 06:23

It is extreme simpel... make an instantiate screen in infobarginaric. In this screen show you picture that you can show/hide...

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W


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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 27 april 2018 - 11:40

Exactly. Extremely simple it is for the 10-year-old Enigma2 programmer. For a man just started, it's incomprehensible.

InfoBar is triggered by pressing a key instead of a scheduler/timer - that is, assigning an event by pressing the Actions button rather than a timer (eTimer, Timer, or Threading). InfoBar is displayed for a short time, what is configured according to the SKIN configuration - so, the configuration modules are used too. InfoBar displays a lot of information that is invoked through various methods (functions). For me, it's an extremely complicated example when I'm just starting with programming under Enigma 2. There are too many methods and classes from many other modules. There are many links to other objects. There are a lot of configuration items - I just have chaos in them as a starting developer.

I want to learn the Enigma2 core, slowly, gradually, on small examples :). And do not create another InfoBar or another event after pressing a button - what I can not do because I can not manage 100x other important features in a particular source code.

Thank you :P.


Veranderd door s3n0, 27 april 2018 - 11:41


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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 27 april 2018 - 16:02

Please can anyone explain where the error is ? :)

 

Thanks.

16:51:39.1325 { E } /usr/lib/python2.7/threading.py:814 __bootstrap_inner Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 1073, in run
  File "/usr/lib/enigma2/python/Plugins/Extensions/AdRelax/plugin.py", line 144, in opakujProgram
    session.open(MyTest)
NameError: global name 'session' is not defined

Here is a plugin-code, scheduled to run the program at a specified time:

###########################################################################
#  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
import datetime
import threading
###########################################################################
from enigma import getDesktop
dwidth = getDesktop(0).size().width()

class MyMenu(Screen):
	skin = """
		<screen position="100,150" size="460,400" title="AdRelax" >
			<widget name="myMenu" position="10,10" size="420,380" scrollbarMode="showOnDemand" />
		</screen>"""

	def __init__(self, session, args = 0):
		self.session = session
		
		list = []
		list.append((_("1 - get current service (funguje chybne)"), "one"))
		list.append((_("2 - get currently playing service reference (treba este orezavat z lava kod)"), "two"))
		list.append((_("3 - cur_retazec (vyskoci BSOD)"), "tree"))
		list.append((_("Exit"), "exit"))
		
		Screen.__init__(self, session)
		self["myMenu"] = MenuList(list)
		self["myActionMap"] = ActionMap(["SetupActions"],
		{
			"ok": self.go,
			"cancel": self.cancel
		}, -1)

	def go(self):
		returnValue = self["myMenu"].l.getCurrentSelection()[1]
		print "\n [MyMenu] returnValue: " + returnValue + "\n"
		
		if returnValue is not None:
			
			if returnValue is "one":
				#self.myMsg("You selected number 1")
				self.myMsg(CurrentService.getCurrentService)
				
			elif returnValue is "two":
				#self.myMsg("You selected number 2")
				cur_ref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
				if cur_ref is not None:                           
					cur_retazec = cur_ref.toString()
					print cur_retazec
					self.myMsg(cur_retazec)
					
			elif returnValue is "tree":
				#self.myMsg("You selected number 3")
				cur_srv = NavigationInstance.instance.getCurrentService()
				if cur_srv is not None:                           
					cur_retazec = cur_ref.toString()
					print cur_retazec
					self.myMsg(cur_retazec)

			else:
				print " \n [MyMenu] cancel (from if..else) \n"
				self.close(None)
	
	def myMsg(self, retazec):
			self.session.open(MessageBox,_("%s") % (retazec), MessageBox.TYPE_INFO)
			
	def cancel(self):
		print " \n [MyMenu] cancel (from def)\n"
		self.close(None)

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

class MyTest(Screen):

	skin = '\n            <screen position="100,100" size="300,300" title="Mountie Plugin Menu" >\n <widget name="info" position="39,33" size="1029,85" font="Regular;26" zPosition="3" transparent="1" valign="center" halign="center" /><widget source="global.CurrentTime" render="Pixmap" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/AthanTimes/Decos/athan.png" position="1120,6" size="150,150" zPosition="4" alphatest="blend"><convert type="AthanTimesAlwaysTrue" /><convert type="AthanTimesConditionalShowHide">Blink</convert></widget><ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/AthanTimes/Decos/Screenhd.png" position="2,8" zPosition="2" size="1103,132" transparent="1" alphatest="on" />           </screen>'


	def __init__(self, session, args = 0):
		
		self.session = session
		
		#list = []
		#list.append((_("1 - get current service (funguje chybne)"), "one"))
		#list.append((_("2 - get currently playing service reference (treba este orezavat z lava kod)"), "two"))
		#list.append((_("3 - cur_retazec (vyskoci BSOD)"), "tree"))
		#list.append((_("4 - jpg obrazkovanie (test)"), "four"))
		#list.append((_("Exit"), "exit"))
		
		Screen.__init__(self, session)
		
		#self["myMenu"] = MenuList(list)
		#self["myActionMap"] = ActionMap(["SetupActions"],
		#{
		#	"ok": self.go,
		#	"cancel": self.cancel
		#}, -1)
			
	def cancel(self):
		print " \n [MyTest] cancel\n"
		self.close(None)

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

def otvoritMenu(session, **kwargs):
	print " \n[MyMenu] start\n"	
	session.open(MyMenu)

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

def autostartProc(reason, **kwargs):
	#global session
	if reason == 0: # startup
		print " AdRelax plugin - startup"
		opakujProgram()
	elif reason == 1:
		print " AdRelax plugin - shutdown"
		threading.Timer(1.0, opakujProgram).cancel()

#def opakujProgram(session, **kwargs):
def opakujProgram():
	threading.Timer(60.0, opakujProgram).start()       # o dalsich XX.X sekund zopakujem program resp. kazdych XX.X ho vykonavam
	#if "01:13:00" == datetime.datetime.now().strftime("%H:%M:%S"):
	if "16:51" == datetime.datetime.now().strftime("%H:%M"):
		session.open(MyTest)
	#print "AdRelax plugin - opakujProgram - timing - debug line \n"
	
###########################################################################

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			where = PluginDescriptor.WHERE_AUTOSTART,
			fnc = autostartProc),
		PluginDescriptor(
			name = "Ad-Relax (Settings)",
			description = "Relaxing instead of TV Advertising",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = otvoritMenu)
			]




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

  • PLi® Core member
  • 56258 berichten

+691
Excellent

Geplaatst op 27 april 2018 - 16:04

Why don't you use eTimer from the enigma2 binary? Enough examples overal in E2... 

I'm afraid this can't work at all...


Veranderd door littlesat, 27 april 2018 - 16:05

WaveFrontier 28.2E | 23.5E | 19.2E | 16E | 13E | 10/9E | 7E | 5E | 1W | 4/5W | 15W


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

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 27 april 2018 - 17:00

Please... read my previous post. There you will find answers to all of your questions, which you just repeated again.

I know very well that there is a GitHub server with a freely available code for most enigma2 distributions. But that does not help me. Unfortunately, knowledge of the whole enigma2 system and rich practice is needed.

Without insult, please ... but I'd rather try another forum for programmers. In this forum I always get another philosophical question instead of a practical answer. The fact that the use of "threading" module is ineffective when I finally remember the question itself! So what is it that someone has to repeat?

I need to learn about mistakes. It's like writing to a 5-year-old child that as children are born (a sex act) - this does not need to know yet! Likewise, I do not need to control the eTimer module until I know how to use Screens.Screen or in general when I have no practice in using methods, classes, parameters, etc. .

I wanted to know where the bug was - I would learn this new thing.

I know very well (even I mentioned it above) that using the 'threading' module is not a good choice or that the open code is freely available for study. However, I will not repeat the linking of all objects, classes, methods, because it does not matter in this forum.

I also asked for a smaller example of a code for eTimer, as I found nothing on the Internet. Everyone knows everything, but no one understands or explains it. Nobody seems to be able to deal with my problem here. No one directed me the right way.

No explanations, just wisdom.

I'm really tired. Sorry and thank you for your free time.


Veranderd door s3n0, 27 april 2018 - 17:01


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

  • PLi® Core member
  • 7185 berichten

+323
Excellent

Geplaatst op 27 april 2018 - 17:17

Because in opakujProgram you don't have a session variable. You need to set it globally or give the session as parameter to the procedure. 


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) #19 betacentauri

  • PLi® Core member
  • 7185 berichten

+323
Excellent

Geplaatst op 27 april 2018 - 17:56

###########################################################################
#  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="100,100" size="300,300" >\n <widget name="pic" position="0,0" size="180,160" 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/lib/enigma2/python/Plugins/Extensions/abc/pictureplayer.png', 100, 100)
		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(2000, False)
			self.visible = True

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

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

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

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

def Plugins(**kwargs):
	return [
		PluginDescriptor(
			name = "Ad-Relax (Settings)",
			description = "Relaxing instead of TV Advertising",
			where = PluginDescriptor.WHERE_PLUGINMENU,
			icon = "plugin.png",
			fnc = myTest)
			]

Just adapted your code in 20 minutes by looking at the pictureplayer plugin. https://github.com/O...urePlayer/ui.py

Really no perfect code. Should only show you how to use eTimer and show a picture.


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) #20 s3n0

  • Senior Member
  • 641 berichten

+62
Good

Geplaatst op 28 april 2018 - 00:37

Thank you very much.

Unfortunately this code I already know :-) . It's very similar to the code from the "ihad tutorial" code example. This is a direct view of the image after opening PLUGIN-MENU and then clicking on a particular plugin. I've tested it before, and it works.

However, my priority is to schedule a JPG-picture view using the "eTimer" module (or at least using the "threading" module). When I try to run the code to display the JPG-image outside the Plugin, I always have a lot of problems with the code :-/ . After 1 minute I need to hide the picture again. I have this problem for about 4 days. I'm tired of it.




1 gebruiker(s) lezen dit onderwerp

0 leden, 1 bezoekers, 0 anonieme gebruikers