Once the user clicks on the button in the input frame, the convert() method is called. This method is responsible for validating the input, calling the converters, and writing the results to the labels built in the previous section. This method, if you will, replaces what would usually be our main() method. After the initial definition and docstring, we log the timestamp and format (raw or formatted) provided by the user. This helps keep track of any activity and troubleshoot any errors that may occur:
151 def convert(self):
152 """
153 The convert method handles the event when the button is
154 pushed. It calls to the converters and updates the
155 labels with new output.
156 """
157 logger.info('Processing Timestamp: {}'.format(
158 self.input_time.get()))
159 logger.info('Input Time Format: {}'.format(
160 self.time_type.get()))
First, on lines 163 through 165, we reset the values of the three timestamp variables to N/A to clear any residual values when the application is run again. We then call the three methods that handle the timestamp conversion on lines 168 through 170. These methods are independent and will update the values for the three timestamp parameters without us needing to return any values or pass arguments.
As you can see, the self keyword really helps to make classes simple by providing access to shared class variables. On line 173, we call the output() method to write the newly converted formats to the GUI:
162 # Init values every instance
163 self.processed_unix_seconds = 'N/A'
164 self.processed_windows_filetime_64 = 'N/A'
165 self.processed_chrome_time = 'N/A'
166
167 # Use this to call converters
168 self.convert_unix_seconds()
169 self.convert_win_filetime_64()
170 self.convert_chrome_time()
171
172 # Update labels
173 self.output()