0

OK. So I have been running into this roadblock where I cant get the GUI to update based on what I am doing. I've searched extensively and tried to read but I am at my wits end almost. The closest Ive gotten is to remove the item from the "myclass.uncorrex_thing" and then run "edit_traits", but that just creates a new GUI over the old one...

Summary: I am getting a list of filenames from a .csv that has alot of items that change daily. I just want to be able to select the filename from a list on the GUI, press a button that does something to the file and checks that filename off the .csv list, then have the dropdown list on the GUI updated with the updated .csv

Here is my code so far

class My_List(HasTraits):
    tracker = RecordKeeping()
    uncorrex_items = tracker.get_uncorrected_list() #this creates a list of filenames based on a .csv file
    uncorrex_items.insert(0,'Select file')


class DataFrameEditorDemo(HasTraits): 

    err_correct = PostProcessAutoErrorCorrection() #a separate module for correcting the files

    myclass = Instance(My_List)
    highlighted_thing = Str    
    Calc = Button('Run Corrections')


    traits_view = View( 
                    Item('Calc', label='correct file'),                       
                    Item("highlighted_thing", editor= EnumEditor(name = 'object.myclass.uncorrex_items')),                      
                    title="MyEditor"                                               
                    )

    def _Calc_fired(self):
        if len(self.highlighted_thing) == 8:
            self.err_correct.correct_form(self.highlighted_thing) #this corrects the file selected from the dropdown list 
                   #AND it updates the .csv file so the file should be checked as complete and will not show up when "tracker.get_uncorrected_list()" is run again

1 Answers1

0

OK, for anyone looking at this and wondering, I finally solved my issue. Basically had to create a property class which depends on an event (button press). When the button is pressed the highlighted_thing updates and the function which corrects the form and updates the .csv is run

class DataFrameEditorDemo(HasTraits): 

    err_correct = PostProcessAutoErrorCorrection() #a separate module for correcting the files
    tracker = RecordKeeping() #a separate module for managing the .csv


    highlighted_thing = Property(List, depends_on = 'Calc')
    test = Str
    Calc = Button('Run Corrections')


    traits_view = View( 
                    Item('Calc', label='correct file'),                       
                    Item("test", editor= EnumEditor(name = 'highlighted_thing')),                         
                    title="MyEditor"                                               
                    )

    def _get_highlighted_thing(self):
        return tracker.get_uncorrected_list()


    def _Calc_fired(self):
        if len(self.test) == 8:
            self.err_correct.correct_form(self.test)