QIB-Sheffield / wezel

Prototyping quantitative medical imaging applications
Apache License 2.0
0 stars 6 forks source link

Logging to g UI widget #37

Closed Steve-Shillitoe closed 2 years ago

Steve-Shillitoe commented 2 years ago

I have created a widget that uses a plain text widget to display status updates from a long-running calculation that runs in it's own thread, separate from the GUI thread. In the test menu, there's an action that displays this widget displaying output from a test function.

plaresmedima commented 2 years ago

@IMI-TRISTAN

Haven't had a chance to run this but I wonder if there is a way to organise it so that the log can be called from inside the run function of an action - for instance this one

class Copy(wezel.Action):

    def run(self, app):

        app.status.message("Copying..")
        series_list = app.get_selected(3)        
        for j, series in enumerate(series_list):
            app.status.progress(j, len(series_list), 'Copying..')
            series.copy()               
        app.status.hide()
        app.refresh()

could be modified to something like

class Copy(wezel.Action):

    def run(self, app):

        log = app.launchLogger()
        app.status.message("Copying..")
        series_list = app.get_selected(3)        
        for j, series in enumerate(series_list):
            log.print('Copying..' + str(j))
            app.status.progress(j, len(series_list), 'Copying..')
            series.copy()               
        app.status.hide()
        app.refresh()
        log.close()
Steve-Shillitoe commented 2 years ago

I think it will need to be the opposite way around; namely, pass the function into the logging widget, so that it can run in its own thread. I've had a look at the copy functionality and it makes no sense to me. Perhaps you are better placed to implement this and I'll support you in the use of the logging widget.

On Tue, 23 Aug 2022 at 15:38, Steven Sourbron @.***> wrote:

@IMI-TRISTAN https://github.com/IMI-TRISTAN

Haven't had a chance to run this but I wonder if there is a way to organise it so that the log can be called from inside the run function of an action - for instance this one

class Copy(wezel.Action):

def run(self, app):

    app.status.message("Copying..")
    series_list = app.get_selected(3)
    for j, series in enumerate(series_list):
        app.status.progress(j, len(series_list), 'Copying..')
        series.copy()
    app.status.hide()
    app.refresh()

could be modified to something like

class Copy(wezel.Action):

def run(self, app):

    log = app.launchLogger()
    app.status.message("Copying..")
    series_list = app.get_selected(3)
    for j, series in enumerate(series_list):
        log.print('Copying..' + str(j))
        app.status.progress(j, len(series_list), 'Copying..')
        series.copy()
    app.status.hide()
    app.refresh()
    log.close()

— Reply to this email directly, view it on GitHub https://github.com/QIB-Sheffield/wezel/pull/37#issuecomment-1224169027, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUTUZDLTT7AMRL6DE7EZ4TV2TO4ZANCNFSM56VAXIEA . You are receiving this because you were mentioned.Message ID: @.***>