def yes(self):
     """Called when the Yes button is clicked."""
     if self.is_df:
         launcher.run_df()
     else:
         launcher.run_program(self.path)
     self.close()
示例#2
0
 def yes(self):
     """Called when the Yes button is clicked."""
     if self.is_df:
         launcher.run_df()
     else:
         launcher.run_program(self.path)
     self.close()
示例#3
0
 def run_df():
     """Launches Dwarf Fortress, reporting any errors when launching."""
     try:
         launcher.run_df()
     except:  #pylint: disable=bare-except
         exc_info = sys.exc_info()
         messagebox.showerror(title='Error launching Dwarf Fortress',
                              message=exc_info[1].message)
示例#4
0
    def create_menu(self, root):
        """
        Creates and returns the menu bar.

        Params:
            root
                Root window for the menu bar.
        """
        menubar = Menu(root, type='menubar')
        root['menu'] = menubar

        menu_file = Menu(menubar)
        menu_options = Menu(menubar)
        menu_run = Menu(menubar)
        menu_folders = Menu(menubar)
        menu_links = Menu(menubar)
        menu_help = Menu(menubar)
        #menu_beta = Menu(menubar)
        menubar.add_cascade(menu=menu_file, label='File')
        menubar.add_cascade(menu=menu_options, label='Options')
        menubar.add_cascade(menu=menu_run, label='Run')
        menubar.add_cascade(menu=menu_folders, label='Folders')
        menubar.add_cascade(menu=menu_links, label='Links')
        menubar.add_cascade(menu=menu_help, label='Help')
        #menubar.add_cascade(menu=menu_beta, label='Testing')

        menu_file.add_command(
            label='Re-load param set', command=self.load_params,
            accelerator='Ctrl+L')
        menu_file.add_command(
            label='Re-save param set', command=self.save_params,
            accelerator='Ctrl+S')
        menu_file.add_command(
            label='Output log', command=lambda: LogWindow(self.root))

        menu_file.add_command(
            label='Restore default settings', command=self.restore_defaults)

        if sys.platform.startswith('linux'):
            menu_file.add_command(
                label="Configure terminal...", command=self.configure_terminal)

        if len(lnp.folders) > 1:
            menu_file.add_command(
                label="Reload/Choose DF folder", command=self.reload_program)

        if sys.platform != 'darwin':
            menu_file.add_command(
                label='Exit', command=self.exit_program, accelerator='Alt+F4')
        root.bind_all('<Control-l>', lambda e: self.load_params())
        root.bind_all('<Control-s>', lambda e: self.save_params())

        self.autoclose.set(lnp.userconfig.get_bool('autoClose'))
        menu_options.add_checkbutton(
            label='Close GUI on launch', onvalue=True, offvalue=False,
            variable=self.autoclose, command=self.set_autoclose)

        if update.updates_configured():
            menu_updates = menu_updates = Menu(menubar)
            menu_options.add_cascade(
                menu=menu_updates, label='Check for updates')
            options = [
                "every launch", "every day", "every 3 days", "every 7 days",
                "every 14 days", "every 30 days", "Never"]
            daylist = [0, 1, 3, 7, 14, 30, -1]
            self.updateDays.set(lnp.userconfig.get_number('updateDays'))
            for i, o in enumerate(options):
                menu_updates.add_radiobutton(
                    label=o, value=daylist[i], variable=self.updateDays,
                    command=lambda i=i: self.configure_updates(daylist[i]))
        self.downloadBaselines.set(lnp.userconfig.get_bool('downloadBaselines'))
        menu_options.add_checkbutton(
            label='Allow auto-download of baselines', onvalue=True,
            offvalue=False, variable=self.downloadBaselines,
            command=self.set_downloads)

        self.show_scrollbars.set(lnp.userconfig.get_bool('tkgui_show_scroll'))
        menu_options.add_checkbutton(
            label='Always show scrollbars (reloads program)', onvalue=True,
            offvalue=False, variable=self.show_scrollbars,
            command=self.set_show_scroll)

        menu_run.add_command(
            label='Dwarf Fortress', command=launcher.run_df,
            accelerator='Ctrl+R')
        menu_run.add_command(
            label='Init Editor', command=self.run_init, accelerator='Ctrl+I')
        root.bind_all('<Control-r>', lambda e: launcher.run_df())
        root.bind_all('<Control-i>', lambda e: self.run_init())

        self.populate_menu(
            lnp.config.get_list('folders'), menu_folders,
            launcher.open_folder_idx)
        self.populate_menu(
            lnp.config.get_list('links'), menu_links,
            launcher.open_link_idx)

        menu_help.add_command(
            label="Help", command=self.show_help, accelerator='F1')
        menu_help.add_command(
            label="About", command=self.show_about, accelerator='Alt+F1')
        menu_help.add_command(label="About DF...", command=self.show_df_info)
        root.bind_all('<F1>', lambda e: self.show_help())
        root.bind_all('<Alt-F1>', lambda e: self.show_about())
        root.createcommand('tkAboutDialog', self.show_about)
        return menubar
示例#5
0
    def create_menu(self, root):
        """
        Creates and returns the menu bar.

        Args:
            root: Root window for the menu bar.
        """
        menubar = Menu(root, type='menubar')
        root['menu'] = menubar

        menu_file = Menu(menubar)
        menu_options = Menu(menubar)
        menu_run = Menu(menubar)
        menu_folders = Menu(menubar)
        menu_links = Menu(menubar)
        menu_help = Menu(menubar)
        #menu_beta = Menu(menubar)
        menubar.add_cascade(menu=menu_file, label='File')
        menubar.add_cascade(menu=menu_options, label='Options')
        menubar.add_cascade(menu=menu_run, label='Run')
        menubar.add_cascade(menu=menu_folders, label='Folders')
        menubar.add_cascade(menu=menu_links, label='Links')
        menubar.add_cascade(menu=menu_help, label='Help')
        #menubar.add_cascade(menu=menu_beta, label='Testing')

        menu_file.add_command(label='Re-load param set',
                              command=self.load_params,
                              accelerator='Ctrl+L')
        menu_file.add_command(label='Re-save param set',
                              command=self.save_params,
                              accelerator='Ctrl+S')
        menu_file.add_command(label='Output log',
                              command=lambda: LogWindow(self.root))

        menu_file.add_command(label='Restore default settings',
                              command=self.restore_defaults)

        if sys.platform.startswith('linux'):
            menu_file.add_command(label="Configure terminal...",
                                  command=self.configure_terminal)

        if len(lnp.folders) > 1:
            menu_file.add_command(label="Reload/Choose DF folder",
                                  command=self.reload_program)

        menu_file.add_command(label='Import from previous install...',
                              command=self.migrate_settings)

        if sys.platform != 'darwin':
            menu_file.add_command(label='Exit',
                                  command=self.exit_program,
                                  accelerator='Alt+F4')
        root.bind_all('<Control-l>', lambda e: self.load_params())
        root.bind_all('<Control-s>', lambda e: self.save_params())

        self.autoclose.set(lnp.userconfig.get_bool('autoClose'))
        menu_options.add_checkbutton(label='Close GUI on launch',
                                     onvalue=True,
                                     offvalue=False,
                                     variable=self.autoclose,
                                     command=self.set_autoclose)

        if update.updates_configured():
            menu_updates = menu_updates = Menu(menubar)
            menu_options.add_cascade(menu=menu_updates,
                                     label='Check for updates')
            options = [
                "Every launch", "Every day", "Every 3 days", "Every 7 days",
                "Every 14 days", "Every 30 days", "Never"
            ]
            daylist = [0, 1, 3, 7, 14, 30, -1]
            self.updateDays.set(lnp.userconfig.get_number('updateDays'))
            for i, o in enumerate(options):
                menu_updates.add_radiobutton(
                    label=o,
                    value=daylist[i],
                    variable=self.updateDays,
                    command=lambda i=i: self.configure_updates(daylist[i]))
        self.downloadBaselines.set(
            lnp.userconfig.get_bool('downloadBaselines'))
        menu_options.add_checkbutton(label='Allow auto-download of baselines',
                                     onvalue=True,
                                     offvalue=False,
                                     variable=self.downloadBaselines,
                                     command=self.set_downloads)

        self.show_scrollbars.set(lnp.userconfig.get_bool('tkgui_show_scroll'))
        menu_options.add_checkbutton(
            label='Always show scrollbars (reloads program)',
            onvalue=True,
            offvalue=False,
            variable=self.show_scrollbars,
            command=self.set_show_scroll)

        menu_run.add_command(label='Dwarf Fortress',
                             command=launcher.run_df,
                             accelerator='Ctrl+R')
        menu_run.add_command(label='Init Editor',
                             command=self.run_init,
                             accelerator='Ctrl+I')
        root.bind_all('<Control-r>', lambda e: launcher.run_df())
        root.bind_all('<Control-i>', lambda e: self.run_init())

        self.populate_menu(lnp.config.get_list('folders'), menu_folders,
                           launcher.open_folder_idx)
        self.populate_menu(lnp.config.get_list('links'), menu_links,
                           launcher.open_link_idx)

        menu_help.add_command(label="Help",
                              command=self.show_help,
                              accelerator='F1')
        menu_help.add_command(label="About",
                              command=self.show_about,
                              accelerator='Alt+F1')
        menu_help.add_command(label="About DF...", command=self.show_df_info)
        root.bind_all('<F1>', lambda e: self.show_help())
        root.bind_all('<Alt-F1>', lambda e: self.show_about())
        root.createcommand('tkAboutDialog', self.show_about)
        return menubar