Jump to content


JasonM8

Member Since 7 Jan 2017
Offline Last Active 27 Jul 2018 09:38
-----

Posts I've Made

In Topic: Changing the size and position of the Screen/Widget after creation

7 July 2018 - 12:11

Why am I getting this exception if I pass lambda instead of a method name to self.onLayoutFinish.append? For testing purposes I just called method in lambda.

self.onLayoutFinish.append(self.randomPosition)             # works
self.onLayoutFinish.append(lambda: self.randomPosition())   # does not work

Trace:
  File "/usr/lib/enigma2/python/mytest.py", line 327, in open
    dlg = self.current_dialog = self.instantiateDialog(screen, *arguments, **kwargs)
  File "/usr/lib/enigma2/python/mytest.py", line 265, in instantiateDialog
    return self.doInstantiateDialog(screen, arguments, kwargs, self.desktop)
  File "/usr/lib/enigma2/python/mytest.py", line 294, in doInstantiateDialog
    dlg.applySkin()
  File "/usr/lib/enigma2/python/Components/GUISkin.py", line 114, in applySkin
  File "/usr/lib/enigma2/python/Components/GUISkin.py", line 45, in createGUIScreen
TypeError: exec: arg 1 must be a string, file, or code object



In Topic: How to programatically check if recording is active or almost active?

7 July 2018 - 09:38

Thanks all! The webinterface solution is perfect in this case as I was trying to write a standalone shutdown script (and such a script can't access current session object, AFAIK).
 
x=$(wget -O- -q http://127.0.0.1/web/timerlist |grep "e2state" | grep -c ">2<")
if [ "$x" == "0" ]; then
  echo "No timers running, restarting"
  shutdown -r 0
else
  echo "Can't restart, there are active timers:" $x
 

In Topic: Changing the size and position of the Screen/Widget after creation

5 July 2018 - 13:50

Hi Jason M8, please tell me where is this file located. Thanks

 

I don't have code online yet, but here is a working minimal class definition that randomly sets position of the window:

class ScreenExample(Screen):
    skin = """
    <screen position="0,0" size="400,300" title="Screen example" >
    </screen>"""

    def __init__(self, session):
        self["actions"] = ActionMap(["OkCancelActions"],
                                    {
                                        "cancel": self.close,
                                    }, -1)
        Screen.__init__(self, session)
        self.onLayoutFinish.append(self.layoutFinished)

    def layoutFinished(self):
        x = randrange(0, 1000)
        y = randrange(100, 500)
        self.move(x, y)

    def move(self, x, y):
        self.instance.move(ePoint(x, y))

    def resize(self, width, height):
        self.instance.resize(eSize(width, height))

In Topic: Changing the size and position of the Screen/Widget after creation

5 July 2018 - 13:24

 

size::

wsize = (x , y)
self.instance.resize(eSize(*wsize))

position:

wx = ...
wy = ...
self.instance.move(ePoint(wx,wy))

both use f.eg. in resize and call it as:

self.onLayoutFinish.append(self.resize)

 

That worked, thanks.


In Topic: How to programatically check if recording is active or almost active?

4 July 2018 - 17:10

What methods can I use to check if recording is currently active, or if they are pending N minutes from now? Basically I want to do same check that enigma2 does when starting, to avoid restarting if recordings are active or pending.

 

restarting.