remi icon indicating copy to clipboard operation
remi copied to clipboard

change label text

Open trex78 opened this issue 7 years ago • 1 comments

Hi, i've made a little control box that runs a few scripts. My knowledge is very limited so i'm glad i've made it this far :-). What i try to do is whenever a image is clicked the label above the group needs to change. For example if button 1 or 2 are selected, top label should say button1-2, the same for the bottom ones. No matter what i try i can't seem to get it to work. Here's the code i got so far:

# -*- coding: utf8 -*-

import remi.gui as gui
import subprocess
from remi.gui import *
from remi import start, App


class CLASSmyapp( Widget ):
    def __init__(self, *args):
        super( CLASSmyapp, self ).__init__(*args)
        Licht_Schakelaar = Label('Licht Schakelaar')
        Licht_Schakelaar.attributes.update({"editor_newclass":"False","editor_baseclass":"Label","editor_constructor":"('Licht Schakelaar')","class":"Label","editor_tag_type":"widget","editor_varname":"Licht_Schakelaar"})
        Licht_Schakelaar.style.update({"top":"294px","height":"30px","width":"129px","position":"absolute","overflow":"auto","margin":"0px","left":"25px"})
        self.append(Licht_Schakelaar,'Licht_Schakelaar')
        aan_licht = Image('/res/aan.png')
        aan_licht.attributes.update({"src":"/res/aan.png","editor_newclass":"False","editor_baseclass":"Image","editor_constructor":"('/res/aan.png')","class":"Image","editor_tag_type":"widget","editor_varname":"aan_licht"})
        aan_licht.style.update({"top":"340px","height":"100px","width":"100px","position":"absolute","overflow":"auto","margin":"0px","left":"30px"})
        self.append(aan_licht,'aan_licht')
        uitalarm = Image('/res/uit.png')
        uitalarm.attributes.update({"src":"/res/uit.png","editor_newclass":"False","editor_baseclass":"Image","editor_constructor":"('/res/uit.png')","class":"Image","editor_tag_type":"widget","editor_varname":"uitalarm"})
        uitalarm.style.update({"top":"173px","height":"100px","width":"100px","position":"absolute","overflow":"auto","margin":"0px","left":"30px"})
        self.append(uitalarm,'uitalarm')
        aanalarm = Image('/res/aan.png')
        aanalarm.attributes.update({"src":"/res/aan.png","editor_newclass":"False","editor_baseclass":"Image","editor_constructor":"('/res/aan.png')","class":"Image","editor_tag_type":"widget","editor_varname":"aanalarm"})
        aanalarm.style.update({"top":"53px","height":"100px","width":"100px","position":"absolute","overflow":"auto","margin":"0px","left":"30px"})
        self.append(aanalarm,'aanalarm')
        AlarmSchakelaar = Label('Alarm Schakelaar')
        AlarmSchakelaar.attributes.update({"editor_newclass":"False","editor_baseclass":"Label","editor_constructor":"('Alarm Schakelaar')","class":"Label","editor_tag_type":"widget","editor_varname":"AlarmSchakelaar"})
        AlarmSchakelaar.style.update({"top":"13px","height":"25px","width":"175px","position":"absolute","overflow":"auto","margin":"0px","left":"25px"})
        self.append(AlarmSchakelaar,'AlarmSchakelaar')
        licht_uit = Image('/res/uit.png')
        licht_uit.attributes.update({"src":"/res/uit.png","editor_newclass":"False","editor_baseclass":"Image","editor_constructor":"('/res/uit.png')","class":"Image","editor_tag_type":"widget","editor_varname":"licht_uit"})
        licht_uit.style.update({"top":"462px","height":"100px","width":"100px","position":"absolute","overflow":"auto","margin":"0px","left":"30px"})
        self.append(licht_uit,'licht_uit')
        

class untitled(App):
    def __init__(self, *args, **kwargs):
        if not 'editing_mode' in kwargs.keys():
            super(untitled, self).__init__(*args, static_file_path='./res/')

    def idle(self):
        #idle function called every update cycle
        pass
    
    def main(self):
        return untitled.construct_ui(self)
        
    @staticmethod
    def construct_ui(self):
        myapp = CLASSmyapp()
        myapp.attributes.update({"editor_newclass":"True","editor_baseclass":"Widget","editor_constructor":"()","class":"Widget","editor_tag_type":"widget","editor_varname":"myapp"})
        myapp.style.update({"background-image":"url('/res/background.png')","top":"14px","height":"823px","width":"240px","position":"absolute","overflow":"auto","margin":"0px","left":"5px"})
        myapp.children['aan_licht'].onclick.connect(self.onclick_aan_licht)
        myapp.children['uitalarm'].onclick.connect(self.onclick_uitalarm)
        myapp.children['aanalarm'].onclick.connect(self.onclick_aanalarm)
        myapp.children['licht_uit'].onclick.connect(self.onclick_licht_uit)
        

        self.myapp = myapp
        return self.myapp
    
    def onclick_aan_licht(self, emitter):
	subprocess.call(['python', 'script1.py'])
        pass

    def onclick_uitalarm(self, emitter):
        subprocess.call(['python', 'script2.py'])
        pass

    def onclick_aanalarm(self, emitter):
        AlarmSchakelaar = Label('Alarm Aan')
        subprocess.call(['python', 'script3.py'])
        pass

    def onclick_licht_uit(self, emitter):
	subprocess.call(['python', 'script4.py'])
        pass



#Configuration
configuration = {'config_multiple_instance': True, 'config_address': '0.0.0.0', 'config_start_browser': True, 'config_enable_file_cache': True, 'config_project_name': 'untitled', 'config_resourcepath': './res/', 'config_port': 8081}

if __name__ == "__main__":
    # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True)
    start(untitled, address=configuration['config_address'], port=configuration['config_port'], 
                        multiple_instance=configuration['config_multiple_instance'], 
                        enable_file_cache=configuration['config_enable_file_cache'],
                        start_browser=configuration['config_start_browser'])

trex78 avatar Oct 18 '18 14:10 trex78

you can use label.set_text(string_you_want_to_display)

Brianzhengca avatar Jan 10 '19 18:01 Brianzhengca