Example #1
0
    def completed_simulation(self, std_out, run_dir):
        # update the GUI buttons
        self.update_run_buttons(running=False)
        # create the dialog
        result_dialog = gtk.Dialog(_("Simulation Output"),
                                   self,
                                   gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
                                   (_("Open Run Directory"), gtk.RESPONSE_YES, _("Close"), gtk.RESPONSE_ACCEPT)
                                   )
        # put a description label
        label = gtk.Label(_("EnergyPlus Simulation Output:"))
        label.show()
        aligner = gtk.Alignment(xalign=1.0, yalign=0.5, xscale=1.0, yscale=1.0)
        aligner.add(label)
        aligner.show()
        result_dialog.vbox.pack_start(aligner, False, True, 0)

        # put the actual simulation results
        label = gtk.Label(std_out)
        scrolled_results = gtk.ScrolledWindow()
        scrolled_results.set_border_width(10)
        scrolled_results.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_ALWAYS)
        scrolled_results.add_with_viewport(label)
        scrolled_results.show()
        result_dialog.vbox.pack_start(scrolled_results, True, True, 0)
        label.show()
        result_dialog.set_size_request(width=500, height=600)
        resp = result_dialog.run()
        if resp == gtk.RESPONSE_YES:
            try:
                subprocess.Popen(['open', run_dir], shell=False)
            except Exception:
                self.simple_error_dialog(_("Could not open run directory"))
        result_dialog.destroy()
 def run(self):
     self.cancelled = False
     base_file_name = os.path.splitext(os.path.basename(self.input_file))[0]
     self.run_dir = os.path.join(os.path.dirname(self.input_file),
                                 'output-' + base_file_name)
     command_line_tokens = [
         self.run_script, '-r', '-x', '-m', '-p', base_file_name, '-d',
         self.run_dir, '-w', self.weather_file, self.input_file
     ]
     self.p = subprocess.Popen(command_line_tokens,
                               shell=False,
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE)
     self.msg_callback(_("Simulation started"))
     self.std_out, self.std_err = self.p.communicate()
     if self.cancelled:
         self.msg_callback(_("Simulation cancelled"))
         self.cancelled_callback()
     else:
         if self.p.returncode == 0:
             self.msg_callback(_("Simulation completed"))
             self.success_callback(self.std_out, self.run_dir)
         else:
             self.msg_callback(_("Simulation failed"))
             self.failure_callback(
                 self.std_out, self.run_dir,
                 subprocess.list2cmdline(command_line_tokens))
Example #3
0
 def failed_simulation(self, std_out, run_dir, cmd_line):
     self.update_run_buttons(running=False)
     message = gtk.MessageDialog(parent=self,
                                 flags=0,
                                 type=gtk.MESSAGE_ERROR,
                                 buttons=gtk.BUTTONS_YES_NO,
                                 message_format=_("EnergyPlus Failed!"))
     message.set_title(_("EnergyPlus Failed"))
     message.format_secondary_text(
         _("Error file is the best place to start.  Would you like to open the Run Folder?"))
     response = message.run()
     if response == gtk.RESPONSE_YES:
         subprocess.Popen(['open', run_dir], shell=False)
     message.destroy()
Example #4
0
 def check_file_paths(self, widget):
     if self.weather_file_path is None or self.input_file_path is None or self.status_bar is None:
         return  # we are probably doing early initialization of the GUI
     idf = self.input_file_path.get_text()
     epw = self.weather_file_path.get_text()
     self.settings[Keys.last_idf] = idf
     self.settings[Keys.last_epw] = epw
     if os.path.exists(idf) and os.path.exists(epw):
         self.message_handler(_("Ready for launch"))
         self.button_sim.set_sensitive(True)
         self.edit_idf_button.set_sensitive(True)
     else:
         self.message_handler(_("Input and/or Weather file paths are invalid"))
         self.button_sim.set_sensitive(False)
         self.edit_idf_button.set_sensitive(False)
Example #5
0
 def select_input_file(self, widget, flag):
     message, file_filters = FileTypes.get_materials(flag)
     if flag == FileTypes.IDF:
         key = Keys.last_idf_folder
     else:
         key = Keys.last_epw_folder
     dialog = gtk.FileChooserDialog(
         title=message,
         action=gtk.FILE_CHOOSER_ACTION_OPEN,
         buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)
     )
     dialog.set_select_multiple(False)
     for file_filter in file_filters:
         dialog.add_filter(file_filter)
     if self.settings[key] is not None:
         dialog.set_current_folder(self.settings[key])
     response = dialog.run()
     if response == gtk.RESPONSE_OK:
         self.settings[key] = dialog.get_current_folder()
         if flag == FileTypes.IDF:
             self.input_file_path.set_text(dialog.get_filename())
         elif flag == FileTypes.EPW:
             self.weather_file_path.set_text(dialog.get_filename())
         dialog.destroy()
     else:
         print(_("Cancelled!"))
         dialog.destroy()
Example #6
0
 def open_input_file(self, widget):
     try:
         subprocess.check_call(['open', self.input_file_path.get_text()], shell=False)
     except Exception:
         self.simple_error_dialog(
             _("Could not open input file, set default application by opening the file separately first.")
         )
Example #7
0
 def switch_language(self, widget, language):
     self.settings[Keys.language] = language
     dialog = gtk.MessageDialog(
         parent=self,
         flags=0,
         type=gtk.MESSAGE_ERROR,
         buttons=gtk.BUTTONS_YES_NO,
         message_format=__program_name__)
     dialog.set_title(_("Message"))
     dialog.format_secondary_text(
         _("You must restart the app to make the language change take effect.  Would you like to restart now?"))
     resp = dialog.run()
     if resp == gtk.RESPONSE_YES:
         self.doing_restart = True
     dialog.destroy()
     if self.doing_restart:
         self.quit(None)
 def on_update_for_new_file(self, event):
     """
     This function handles the request to update for a new file, including updating program settings,
     gui button state, and updating the file version label if the file exists
     :param event: The event information generated by the caller, which is typically a text ctrl text change event
     """
     if self.lbl_path is None or self.btn_update_file is None:
         return
     idf = self.lbl_path.GetValue()
     self.settings[Keys.last_idf] = idf
     if os.path.exists(idf):
         self.on_msg(_("IDF File exists, ready to go"))
         self.idf_version = self.get_idf_version(idf)
         self.lbl_old_version.SetLabel("%s: %s" % (_('Old Version'), self.idf_version))
         self.btn_update_file.Enable()
     else:
         self.on_msg(_("IDF File doesn't exist at path given; cannot transition"))
         self.btn_update_file.Disable()
Example #9
0
 def stop(self):
     """
     This function allows attempting to stop the thread if it is running.
     This function polls the existing subprocess to see if it is running and attempts to kill the process
     """
     if self.p.poll() is None:
         self.msg_callback(_("Attempting to cancel simulation ..."))
         self.cancelled = True
         self.p.kill()
Example #10
0
 def about_dialog(self, widget):
     message = gtk.MessageDialog(parent=self,
                                 flags=0,
                                 type=gtk.MESSAGE_INFO,
                                 buttons=gtk.BUTTONS_OK,
                                 message_format=__program_name__)
     message.set_title(__program_name__)
     message.format_secondary_text(_("ABOUT_DIALOG"))
     message.run()
     message.destroy()
Example #11
0
 def simple_error_dialog(self, message_text):
     message = gtk.MessageDialog(parent=self,
                                 flags=0,
                                 type=gtk.MESSAGE_ERROR,
                                 buttons=gtk.BUTTONS_OK,
                                 message_format=_("Error performing prior action:"))
     message.set_title(__program_name__)
     message.format_secondary_text(message_text)
     message.run()
     message.destroy()
 def on_about(self, event):
     """
     This function handles the request to show the "About..." modal dialog window
     :param event: The event information generated by the caller, which in this case is a wx Button
     """
     message = wx.MessageDialog(parent=self,
                                message=_("ABOUT_DIALOG"),
                                caption=__program_name__,
                                style=wx.OK | wx.CENTRE | wx.ICON_INFORMATION)
     message.ShowModal()
     message.Destroy()
Example #13
0
 def get_materials(file_type):
     filters = []
     if file_type == FileTypes.IDF:
         message = _("Select input file")
         idf_filter = gtk.FileFilter()
         idf_filter.set_name(_("IDF files"))
         idf_filter.add_pattern("*.idf")
         filters.append(idf_filter)
         imf_filter = gtk.FileFilter()
         imf_filter.set_name("IMF files")
         imf_filter.add_pattern("*.imf")
         filters.append(imf_filter)
     elif file_type == FileTypes.EPW:
         message = _("Select weather file")
         epw_filter = gtk.FileFilter()
         epw_filter.set_name(_("EPW files"))
         epw_filter.add_pattern("*.epw")
         filters.append(epw_filter)
     else:
         return None, None
     return message, filters
Example #14
0
 def run(self):
     """
     This function runs the instantiated thread based on the parameters passed into the constructor.
     The function intermittently calls the msg_callback class instance function variable to alert the calling thread of status updates.
     When the function is complete it calls the done_callback class instance function variable to alert the calling thread.
     """
     self.cancelled = False
     shutil.copy(self.input_file, self.run_dir)
     base_file_name = os.path.basename(self.input_file)
     failed = False
     cancelled = False
     for tr in self.transitions:
         if self.keep_old:
             backup_success = self.backup_file_before_transition(tr)
             if not backup_success:
                 failed = True
                 break
         command_line_tokens = [
             tr.full_path_to_binary,
             base_file_name,
         ]
         self.p = subprocess.Popen(command_line_tokens,
                                   shell=False,
                                   cwd=self.run_dir,
                                   stdout=subprocess.PIPE,
                                   stderr=subprocess.PIPE)
         self.msg_callback(
             _("Running Transition") + " " + str(tr.source_version) +
             " -> " + str(tr.target_version))
         self.std_out, self.std_err = self.p.communicate()
         if self.cancelled:
             self.msg_callback(_("Transition Cancelled"))
             break
         else:
             if self.p.returncode == 0:
                 self.msg_callback(
                     _("Completed Transition") + " " +
                     str(tr.source_version) + " -> " +
                     str(tr.target_version))
             else:
                 self.msg_callback(
                     _("Failed Transition") + " " + str(tr.source_version) +
                     " -> " + str(tr.target_version))
                 failed = True
                 break
     if self.cancelled:
         self.done_callback(_("Transition cancelled"))
     elif failed:
         self.done_callback(
             _("Transition Failed! - Open run directory to read latest audit/error/etc"
               ))
     else:
         self.done_callback(
             _("All transitions completed successfully - Open run directory for transitioned file"
               ))
    def __init__(self):

        # initialize base class
        wx.Frame.__init__(self, None, title=__program_name__, size=(600, 183))
        self.SetMinSize((400, 175))

        # load the settings here very early; the tilde is cross platform thanks to Python
        self.settings_file_name = os.path.join(os.path.expanduser("~"), ".idfversionupdater.json")
        self.settings = load_settings(self.settings_file_name)

        # initialize some class-level "constants"
        self.box_spacing = 4

        # reset the restart flag
        global _doing_restart
        _doing_restart = False

        # initialize instance variables to be set later
        self.btn_select_idf = None
        self.btn_about = None
        self.lbl_path = None
        self.lbl_old_version = None
        self.chk_create_inter_versions = None
        self.btn_update_file = None
        self.btn_open_run_dir = None
        self.btn_cancel = None
        self.btn_exit = None
        self.status_bar = None
        self.idf_version = None
        self.running_transition_thread = None

        # try to load the settings very early since it includes initialization
        set_language(self.settings[Keys.language])

        # connect signals for the GUI
        self.Bind(wx.EVT_CLOSE, self.on_closing_form)

        # build up the GUI itself
        self.build_gui()

        # update the list of E+ versions
        self.ep_run_folder = EnergyPlusPath()
        title = TransitionRunThread.get_ep_version(os.path.join(self.ep_run_folder.installation_path, 'EnergyPlus'))
        self.SetTitle(__program_name__ + " -- " + title)
        self.status_bar.SetStatusText(_("Program Initialized"))

        # check the validity of the idf versions once at load time to initialize the action availability
        self.on_update_for_new_file(None)
 def on_choose_idf(self, event):
     """
     This function handles the request to choose a new idf, opening a dialog, and updating settings if applicable
     :param event: The event information generated by the caller, which in this case is a wx Button
     """
     cur_folder = ""
     if self.settings[Keys.last_idf_folder] is not None:
         cur_folder = self.settings[Keys.last_idf_folder]
     cur_idf = ""
     if self.settings[Keys.last_idf] is not None:
         cur_idf = self.settings[Keys.last_idf]
     open_file_dialog = wx.FileDialog(self, _("Open File for Transition"), cur_folder, cur_idf,
                                      "EnergyPlus Input Files (*.idf;*.imf)|*.idf;*.imf",
                                      wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
     result = open_file_dialog.ShowModal()
     if result == wx.ID_OK:
         cur_idf = open_file_dialog.GetPath()
         self.settings[Keys.last_idf] = cur_idf
         self.settings[Keys.last_idf_folder] = os.path.dirname(cur_idf)
         self.lbl_path.SetValue(cur_idf)
     open_file_dialog.Destroy()
 def on_switch_language(self, event):
     """
     This function handles the request to change languages, where the language identifier is passed in with the event
     :param event: The event information generated by the caller, for this function, the event ID should be set to
     an item in the :py:class:`Languages <International.Languages>` enumeration class
     """
     global _doing_restart
     this_id = event.GetId()
     language = this_id
     self.settings[Keys.language] = language
     message = wx.MessageDialog(
         parent=self,
         message=_(
             "You must restart the app to make the language change take effect.  Would you like to restart now?"),
         caption=__program_name__,
         style=wx.YES_NO | wx.CENTRE | wx.ICON_QUESTION)
     resp = message.ShowModal()
     if resp == wx.ID_YES:
         _doing_restart = True
     message.Destroy()
     if doing_restart():
         self.Close(False)
 def on_open_run_dir(self, event):
     """
     This function handles the request to open the current run directory in the default application (Finder...)
     :param event: The event information generated by the caller, which in this case is a wx Button
     """
     try:
         cur_platform = EnergyPlusPath.get_platform()
         open_cmd = ""
         if cur_platform == "linux":
             open_cmd = "xdg-open"
         elif cur_platform == "mac":
             open_cmd = "open"
         elif cur_platform == "windows":
             open_cmd = "explorer"
         subprocess.Popen([open_cmd, self.ep_run_folder.transition_directory], shell=False)
     except Exception:
         message = wx.MessageDialog(
             parent=self,
             message=_("Could not open run directory"),
             caption=__program_name__,
             style=wx.OK | wx.CENTRE | wx.ICON_WARNING)
         message.ShowModal()
         message.Destroy()
 def on_update_idf(self, event):
     """
     This function handles the request to run Transition itself, building up the list of transitions,
     creating a new thread instance, prepping the gui, and running it
     :param event: The event information generated by the caller, which in this case is a wx Button
     """
     if self.idf_version not in [tr.source_version for tr in self.ep_run_folder.transitions_available]:
         self.on_msg(_("Cannot find a matching transition tool for this idf version"))
     # we need to build up the list of transition steps to perform
     transitions_to_run = []
     for tr in self.ep_run_folder.transitions_available:
         if tr.source_version < self.idf_version:
             continue  # skip this older version
         transitions_to_run.append(tr)
     self.running_transition_thread = TransitionRunThread(
         transitions_to_run,
         self.ep_run_folder.transition_directory,
         self.settings[Keys.last_idf],
         self.chk_create_inter_versions.GetValue(),
         self.callback_on_msg,
         self.callback_on_done
     )
     self.running_transition_thread.start()
     self.set_buttons_for_running(enabled=False)
Example #20
0
    def gui_build_body(self):
        """
        This function builds out the specific widgets on the GUI

        * Returns: A gtk.VBox suitable for adding directly onto the main gtk.Window
        """

        # create a vbox here first
        vbox = gtk.VBox(False, self.box_spacing)

        # create the menu bar itself to hold the menus
        mb = gtk.MenuBar()

        # create the actual actionable items under the file menu
        menu_item_file_about = gtk.MenuItem(_("About..."))
        menu_item_file_about.connect("activate", self.about_dialog)
        menu_item_file_about.show()
        menu_item_file_exit = gtk.MenuItem(_("Exit"))
        menu_item_file_exit.connect("activate", self.quit)
        menu_item_file_exit.show()

        # create the actual actionable items under the language menu
        menu_item_english = gtk.MenuItem("Language: English")
        menu_item_english.connect("activate", self.switch_language, Languages.English)
        menu_item_english.show()
        if self.settings[Keys.language] == Languages.English:
            menu_item_english.set_sensitive(False)
        menu_item_spanish = gtk.MenuItem("Idioma: Espanol")
        menu_item_spanish.connect("activate", self.switch_language, Languages.Spanish)
        menu_item_spanish.show()
        if self.settings[Keys.language] == Languages.Spanish:
            menu_item_spanish.set_sensitive(False)
        menu_item_french = gtk.MenuItem("Langue: Francais")
        menu_item_french.connect("activate", self.switch_language, Languages.French)
        menu_item_french.show()
        if self.settings[Keys.language] == Languages.French:
            menu_item_french.set_sensitive(False)

        # create the list of items that will eventually be dropped down, and append items in the right order
        filemenu = gtk.Menu()
        filemenu.append(menu_item_file_about)
        filemenu.append(gtk.SeparatorMenuItem())
        filemenu.append(menu_item_file_exit)
        langmenu = gtk.Menu()
        langmenu.append(menu_item_english)
        langmenu.append(menu_item_spanish)
        langmenu.append(menu_item_french)

        # create the root drop-down-able menu items, and assign their submenus to the lists above
        menu_item_file = gtk.MenuItem(_("File"))
        menu_item_file.set_submenu(filemenu)
        menu_item_lang = gtk.MenuItem("Language/Idioma/Langue")
        menu_item_lang.set_submenu(langmenu)

        # attach the root menus to the main menu bar
        mb.append(menu_item_file)
        mb.append(menu_item_lang)

        # and finally attach the main menu bar to the window
        vbox.pack_start(mb, False)

        # create the input file button and textbox section
        hbox1 = gtk.HBox(False, self.box_spacing)
        button1 = gtk.Button(_("Choose Input File.."))
        button1.connect("clicked", self.select_input_file, FileTypes.IDF)
        alignment = gtk.Alignment(xalign=1.0, yalign=0.5, xscale=1.0, yscale=0.5)
        alignment.add(button1)
        hbox1.pack_start(alignment, True, True, self.box_spacing)
        self.input_file_path = gtk.Entry()
        self.input_file_path.connect("changed", self.check_file_paths)
        self.input_file_path.set_text(self.settings['last_idf'])  # "/tmp/RefBldgHospitalNew2004_Chicago.idf")
        self.input_file_path.set_size_request(width=500, height=-1)
        alignment = gtk.Alignment(xalign=1.0, yalign=0.5, xscale=1.0, yscale=0.5)
        alignment.add(self.input_file_path)
        hbox1.pack_start(alignment, True, True, self.box_spacing)
        self.edit_idf_button = gtk.Button(_("Edit Input File.."))
        self.edit_idf_button.connect("clicked", self.open_input_file)
        alignment = gtk.Alignment(xalign=1.0, yalign=0.5, xscale=1.0, yscale=0.5)
        alignment.add(self.edit_idf_button)
        hbox1.pack_start(alignment, True, True, self.box_spacing)
        vbox.pack_start(self.framed(hbox1), True, True, 0)

        # create the weather file button and textbox section
        hbox2 = gtk.HBox(False, self.box_spacing)
        button1 = gtk.Button(_("Choose Weather File.."))
        button1.connect("clicked", self.select_input_file, FileTypes.EPW)
        alignment = gtk.Alignment(xalign=1.0, yalign=0.5, xscale=1.0, yscale=0.5)
        alignment.add(button1)
        hbox2.pack_start(alignment, True, True, self.box_spacing)
        self.weather_file_path = gtk.Entry()
        self.weather_file_path.connect("changed", self.check_file_paths)
        self.weather_file_path.set_text(
            self.settings['last_epw'])  # '"/Users/elee/EnergyPlus/repos/2eplus/weather/CZ06RV2.epw")
        self.weather_file_path.set_size_request(width=500, height=-1)
        alignment = gtk.Alignment(xalign=1.0, yalign=0.5, xscale=1.0, yscale=0.5)
        alignment.add(self.weather_file_path)
        hbox2.pack_start(alignment, True, True, self.box_spacing)
        vbox.pack_start(self.framed(hbox2), True, True, 0)

        # separator
        vbox.pack_start(self.framed(gtk.HSeparator()), False)

        # create the simulate/cancel button section
        hbox3 = gtk.HBox(False, self.box_spacing)
        self.button_sim = gtk.Button(_("Simulate"))
        self.button_sim.connect("clicked", self.run_simulation)
        alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.5, yscale=0.5)
        alignment.add(self.button_sim)
        hbox3.pack_start(alignment, True, True, self.box_spacing)
        self.button_cancel = gtk.Button(_("Cancel"))
        self.button_cancel.connect("clicked", self.cancel_simulation)
        alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.5, yscale=0.5)
        alignment.add(self.button_cancel)
        self.update_run_buttons(running=False)
        hbox3.pack_start(alignment, True, True, self.box_spacing)
        # self.button_language = gtk.Button(_("Switch language"))
        # self.button_language.connect("clicked", self.switch_language)
        # alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.5, yscale=0.5)
        # alignment.add(self.button_language)
        # hbox3.pack_start(alignment, True, True, self.box_spacing)
        vbox.pack_start(self.framed(hbox3), True, True, 0)

        # separator
        vbox.pack_start(self.framed(gtk.HSeparator()), False)

        # create the status bar
        hbox = gtk.HBox(False, self.box_spacing)
        self.ep_version_label = gtk.Label()
        self.ep_version_label.set_text(_("E+ Version"))
        aligner = gtk.Alignment(1, 0.5, 1, 1)
        aligner.add(self.ep_version_label)
        hbox.pack_start(self.framed(gtk.VSeparator()), False)
        hbox.pack_start(aligner, False, True, 0)
        self.status_bar = gtk.Statusbar()
        self.status_bar.set_has_resize_grip(False)
        self.status_bar_context_id = self.status_bar.get_context_id("Statusbar example")
        self.status_bar.push(self.status_bar_context_id, _("Ready for launch"))
        aligner = gtk.Alignment(1, 1, 1, 0)
        aligner.add(self.status_bar)
        hbox.pack_start(self.framed(gtk.VSeparator()), False)
        hbox.pack_start(aligner)
        vbox.pack_end(self.framed(hbox), False, True, 0)
        hbox.pack_start(self.framed(gtk.VSeparator()), False)

        # return the vbox
        return vbox
    def build_gui(self):
        """
        This function manages the window construction, including position, title, and presentation
        """
        self.status_bar = self.CreateStatusBar()  # A StatusBar in the bottom of the window

        # highest level layout control is the main panel
        panel = wx.Panel(self, wx.ID_ANY)

        # this is then broken into rows with one vertical sizer
        top_sizer = wx.BoxSizer(wx.VERTICAL)

        # each row then has their own horizontal sizers on which controls are placed
        choose_about_sizer = wx.BoxSizer(wx.HORIZONTAL)
        path_version_sizer = wx.BoxSizer(wx.HORIZONTAL)
        checkbox_sizer = wx.BoxSizer(wx.HORIZONTAL)
        update_audit_close_sizer = wx.BoxSizer(wx.HORIZONTAL)

        # let's create a bunch of controls
        self.btn_select_idf = wx.Button(panel, wx.ID_ANY, _('Choose File to Update...'))
        self.btn_select_idf.Bind(wx.EVT_BUTTON, self.on_choose_idf)
        self.btn_about = wx.Button(panel, wx.ID_ANY, _('About...'))
        self.btn_about.Bind(wx.EVT_BUTTON, self.on_about)
        self.lbl_path = wx.TextCtrl(panel, wx.ID_ANY, _('File Path'), style=wx.BORDER_NONE)
        self.lbl_path.Bind(wx.EVT_TEXT, self.on_update_for_new_file)
        if self.settings[Keys.last_idf] is not None:
            self.lbl_path.SetValue(self.settings[Keys.last_idf])
        self.lbl_old_version = wx.StaticText(panel, wx.ID_ANY, _('Old Version'))
        self.chk_create_inter_versions = wx.CheckBox(panel, wx.ID_ANY, _('Keep Intermediate Versions of Files?'))
        self.chk_create_inter_versions.SetValue(True)
        self.btn_update_file = wx.Button(panel, wx.ID_ANY, _('Update File'))
        self.btn_update_file.Bind(wx.EVT_BUTTON, self.on_update_idf)
        self.btn_cancel = wx.Button(panel, wx.ID_ANY, _('Cancel Run'))
        self.btn_cancel.Bind(wx.EVT_BUTTON, self.on_cancel)
        self.btn_cancel.Disable()
        self.btn_open_run_dir = wx.Button(panel, wx.ID_ANY, _('Open Run Directory'))
        self.btn_open_run_dir.Bind(wx.EVT_BUTTON, self.on_open_run_dir)
        self.btn_exit = wx.Button(panel, wx.ID_ANY, _('Close'))
        self.btn_exit.Bind(wx.EVT_BUTTON, self.on_close)

        # now let's add the controls to each sizer
        choose_about_sizer.Add(self.btn_select_idf, 1, flag=wx.ALIGN_LEFT | wx.LEFT, border=self.box_spacing)
        choose_about_sizer.Add(wx.StaticText(panel, -1, ''), 100, wx.EXPAND, border=self.box_spacing)
        choose_about_sizer.Add(self.btn_about, 1, flag=wx.ALIGN_RIGHT | wx.RIGHT, border=self.box_spacing)
        path_version_sizer.Add(self.lbl_path, 4, flag=wx.ALIGN_LEFT | wx.LEFT, border=self.box_spacing)
        path_version_sizer.Add(wx.StaticText(panel, -1, ''), 1, wx.EXPAND, border=self.box_spacing)
        path_version_sizer.Add(self.lbl_old_version, 1, flag=wx.ALIGN_RIGHT | wx.RIGHT, border=self.box_spacing)
        checkbox_sizer.Add(self.chk_create_inter_versions, 1, flag=wx.ALIGN_LEFT | wx.LEFT, border=self.box_spacing)
        update_audit_close_sizer.Add(self.btn_update_file, 1, flag=wx.ALIGN_LEFT | wx.LEFT, border=self.box_spacing)
        update_audit_close_sizer.Add(self.btn_cancel, 1, flag=wx.ALIGN_LEFT | wx.LEFT, border=self.box_spacing)
        update_audit_close_sizer.Add(wx.StaticText(panel, -1, ''), 7, wx.EXPAND, border=self.box_spacing)
        update_audit_close_sizer.Add(self.btn_open_run_dir, 1, flag=wx.ALIGN_RIGHT | wx.RIGHT, border=self.box_spacing)
        update_audit_close_sizer.Add(self.btn_exit, 1, flag=wx.ALIGN_RIGHT | wx.RIGHT, border=self.box_spacing)

        # then we'll add all the horizontal sizers into the main vertical sizer
        top_sizer.Add(choose_about_sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)
        top_sizer.Add(wx.StaticLine(panel, ), proportion=0, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)
        top_sizer.Add(path_version_sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)
        top_sizer.Add(wx.StaticLine(panel, ), proportion=0, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)
        top_sizer.Add(checkbox_sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)
        top_sizer.Add(wx.StaticLine(panel, ), proportion=0, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)
        top_sizer.Add(update_audit_close_sizer, proportion=1, flag=wx.EXPAND | wx.ALL, border=self.box_spacing)

        # and now tell the panel we are using this topSizer
        panel.SetSizer(top_sizer)

        # also build out the menu bar
        menu_bar = wx.MenuBar()
        menu1 = wx.Menu()
        # create the actual actionable items under the language menu
        menu1.Append(Languages.English, "English", "Change language to English")
        self.Bind(wx.EVT_MENU, self.on_switch_language, id=Languages.English)
        menu1.Append(Languages.Spanish, "Spanish", "Change language to Spanish")
        self.Bind(wx.EVT_MENU, self.on_switch_language, id=Languages.Spanish)
        menu1.Append(Languages.French, "French", "Change language to French")
        self.Bind(wx.EVT_MENU, self.on_switch_language, id=Languages.French)
        menu1.AppendSeparator()
        menu1.Append(106, "&Close\tCtrl+W", "Closes the window")
        self.Bind(wx.EVT_MENU, self.on_close, id=106)
        menu_bar.Append(menu1, "&File")
        self.SetMenuBar(menu_bar)  # Adding the MenuBar to the Frame content.

        # finally show the window in the center of the (primary? current?) screen
        self.Show(True)
        self.CenterOnScreen()
 def stop(self):
     if self.p.poll() is None:
         self.msg_callback(_("Attempting to cancel simulation ..."))
         self.cancelled = True
         self.p.kill()