maybe this helps someone who developes libraries

KANUSO

New member
If you develope a library or many libraries, than you notice that the import / reload mechanism can slow down the developement. This is because the libraries gets reloaded every time you load your testapp.

My way is to not give every library the reload command for itself and do not give the testapp the reload statement.

I have coded an app to do this. Here you have an example (I am shure that someone who codes a library does know how to use this)

Code:
#! /usr/bin/env python
# -*- Mode: Python -*-
# -*- coding: ascii -*-

"""
nuReload
"""

import lwsdk


import example1
import example2


# TODO: Edit the following block to your needs
__author__         = 'Karl Schuster'
__date__           = '06 / 08 / 2018'
__copyright__      = 'Karl Schuster'
__version__        = 'V 1.1'
__maintainer__     = 'Karl Schuster'
__email__          = '[email protected]'
__status__         = 'Production Stage I'
__lwver__          = '11'

class nuReload(lwsdk.ICommandSequence):
    def __init__(self, context):
        super(nuReload, self).__init__()

    def b1btn(self,ctl,udat):
        txt=ctl.label()
        if txt=="ALL":
            reload(example1)
            reload(example2)
            self.panel.close()
        else:
            if txt=="example1":     reload(example1)
            if txt=="example2":     reload(example2)

    def process(self, mod_command):
        self.pyco=lwsdk.LWPCoreConsole()
        self.pyco.show()			# open the console
        self.pyco.clear()			# clear it
        self.ui=lwsdk.LWPanels()
        self.panel=self.ui.create("Library Reloader")
        b1=self.panel.button_ctl("example1");     b1.set_w(95); b1.set_h(22); b1.move( 10, 10); b1.set_event(self.b1btn)
        b1=self.panel.button_ctl("example2");     b1.set_w(95); b1.set_h(22); b1.move(110, 10); b1.set_event(self.b1btn)
        b1=self.panel.button_ctl("ALL");          b1.set_w(95); b1.set_h(22); b1.move( 10, 85); b1.set_event(self.b1btn)
        self.panel.setw(520)
        self.panel.seth(160)
        if self.panel.open(lwsdk.PANF_BLOCKING | lwsdk.PANF_MOUSETRAP | lwsdk.PANF_MOUSETRACK | lwsdk.PANF_FRAME) == 0:
            self.ui.destroy(self.panel)
        return lwsdk.AFUNC_OK

ServerTagInfo = [
                    ( "PynuReload", lwsdk.SRVTAG_USERNAME | lwsdk.LANGID_USENGLISH ),
                    ( "nuReload", lwsdk.SRVTAG_BUTTONNAME | lwsdk.LANGID_USENGLISH ),
                    ( "Utilities/Python", lwsdk.SRVTAG_MENU | lwsdk.LANGID_USENGLISH )
                    ]

ServerRecord = { lwsdk.CommandSequenceFactory("PythnuReload", nuReload) : ServerTagInfo }

This will open a Dialog with a button for the libs (here the libs "example1" and "example2". By clicking a button, the lib for this button gets reloaded.
To shortly reload all libs, a button "ALL" is included. This button Closes the Dialog after the reloads are done.

I hope this will help someone,
Kanuso
 
Back
Top