Jump to content


Photo

Changing a Text Label


  • Please log in to reply
4 replies to this topic

#1 jpuigs

  • Senior Member
  • 1,143 posts

+32
Good

Posted 26 April 2015 - 21:32

I'm doing tests  on a plugin , but I can't find a way of changing text twice on a function.

 

When pressing blue button, I want to get a specific text, and after 3 seconds, another one.

 

I only get the last one.

I press blue button, and after 3 secons I get "Finished!". I don't get the first one.

 

What I'm doing wrong ???

# -*- coding: iso-8859-1 -*-
from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Components.ActionMap import ActionMap
from Components.Label import Label
import time

class AAAA(Screen):
skin = """
<screen name="MyTests" position="240,240" size="300,300" flags="wfNoBorder" backgroundColor="#40000000">
  <eLabel position="20,25" size="200,30" text="MyTests" foregroundColor="#00ffffff" font="Regular; 24" valign="center" backgroundColor="#40000000" transparent="1" halign="center" />
  <eLabel position="20,100" size="5,40" backgroundColor="#00ff0000" />
  <eLabel position="120,100" size="5,40" backgroundColor="#000000ff" />
  <eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" halign="left" position="35,100" size="250,33" text="Cancel" transparent="1" />
  <eLabel font="Regular; 20" foregroundColor="#00ffffff" backgroundColor="#40000000" halign="left" position="135,100" size="250,33" text="Start" transparent="1" />
  <widget name="results" position="20,200" size="200,100" zPosition="2" font="Regular;25" halign="left" valign="center" backgroundColor="#40000000" />
</screen>
"""

def __init__(self, session):
  Screen.__init__(self, session)
  self.session = session
                self["results"] = Label()
  self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
                {
                        "red": self.exit,
                        "blue": self.mainfunc,
                        "cancel": self.exit
                        }, -1)
def exit(self):
  self.close()

def ChangeText(self, text):
  self["results"].setText(text)

def mainfunc(self):
  self.ChangeText("waiting 3 seconds")
  time.sleep(3)
  self.ChangeText("Finished!")

def main(session, **kwargs):
session.open(AAAA)

def Plugins(**kwargs):
return PluginDescriptor(name="AAAA", description=_("Silly Tests"), where = PluginDescriptor.WHERE_PLUGINMENU, icon="icon.png", fnc=main)

Edited by jpuigs, 26 April 2015 - 21:36.

Enigma is getting old....

 

Spoiler

Re: Changing a Text Label #2 littlesat

  • PLi® Core member
  • 56,262 posts

+691
Excellent

Posted 26 April 2015 - 23:24

Time.sleep is not the way hou do it in enigma2.... See the other places in enigme2 where eTimer is used....

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


Re: Changing a Text Label #3 jpuigs

  • Senior Member
  • 1,143 posts

+32
Good

Posted 27 April 2015 - 13:26

OK. I'll investigate.

I'm trying to do a plguin to modify Yweather.py behaviour, and I need to wait some time to get downloaded xml file from yahoo.

I get it right with time.sleep , but I want to place a text before and after downloading and that's exactly what's not working.

 

Thanks,


Enigma is getting old....

 

Spoiler

Re: Changing a Text Label #4 Erik Slagter

  • PLi® Core member
  • 46,951 posts

+541
Excellent

Posted 27 April 2015 - 16:18

The problem is that anything you change on the screen (via-via) won't get display until you RETURN to the "main loop". So as long as you keep waiting in your own piece of code, nothing will happen. It's a common concept in GUI-toolkits (like e.g. qt and gtk). It works with everything being called back into your code.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: Changing a Text Label #5 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 27 April 2015 - 16:22

you do not need time.sleep or etimer

import urllib
#change button text
urllib.urlretrieve(xmllink,"/tmp/local.xml")
#change text button again


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users