def read_data(self): mods.clear_temp() self.available = mods.read_mods() self.installed = mods.get_installed_mods_from_log() self.available = [m for m in self.available if m not in self.installed] self.update_lists()
def __init__(self): """ Constructor for TkGui. Args: lnp: A PyLNP instance to perform actual work. """ self.root = root = Tk() self.updateDays = IntVar() self.downloadBaselines = BooleanVar() self.show_scrollbars = BooleanVar() self.autoclose = BooleanVar() self.do_reload = False controls.init(self) binding.init(lnp, self) if not self.ensure_df(): return if sys.version_info[0] == 3: Style().map('Treeview', foreground=fixed_map('foreground'), background=fixed_map('background')) if lnp.os == 'linux' and not terminal.terminal_configured(): self.root.withdraw() messagebox.showinfo( 'PyLNP', 'You need to configure a terminal to allow things like DFHack ' 'to work correctly. Press OK to do this now.') self.configure_terminal(True) self.root.deiconify() root.option_add('*tearOff', FALSE) windowing = root.tk.call('tk', 'windowingsystem') if windowing == "win32": root.tk.call('wm', 'iconbitmap', root, "-default", get_resource('LNP.ico')) elif windowing == "x11": root.tk.call('wm', 'iconphoto', root, "-default", get_image(get_resource('LNP'))) elif windowing == "aqua": # OS X has no window icons pass root.title("PyLNP") self.vcmd = (root.register(validate_number), '%P') main = Frame(root) self.logo = logo = get_image(get_resource('LNPSMALL')) Label(root, image=logo, anchor=CENTER).pack(fill=X) main.pack(side=TOP, fill=BOTH, expand=Y) self.download_panel = controls.create_control_group( main, 'Download status') self.download_text = StringVar() self.download_status = Label(self.download_panel, textvariable=self.download_text) self.download_panel.pack(fill=X, expand=N, side=BOTTOM) self.download_status.pack(side=BOTTOM) self.n = n = Notebook(main) self.create_tab(OptionsTab, 'Options') self.create_tab(GraphicsTab, 'Graphics') self.create_tab(UtilitiesTab, 'Utilities') self.create_tab(AdvancedTab, 'Advanced') if 'dfhack' in lnp.df_info.variations: self.create_tab(DFHackTab, 'DFHack') if mods.read_mods(): self.create_tab(ModsTab, 'Mods') n.enable_traversal() n.pack(fill=BOTH, expand=Y, padx=2, pady=3) play_font = tkFont.Font(font='TkDefaultFont') play_font.config(weight=tkFont.BOLD, size=int(play_font['size'] * 1.5)) Style().configure('Big.TButton', font=play_font) play_button = controls.create_trigger_button(main, 'Play Dwarf Fortress!', 'Play the game!', self.run_df) if sys.platform != 'darwin': play_button.configure(style='Big.TButton') play_button.pack(side=BOTTOM, fill=X, padx=(1, 3), pady=(0, 3)) else: play_button.pack(side=BOTTOM, fill=X, padx=(30, 30), pady=(0, 3)) self.menubar = self.create_menu(root) self.save_size = None root.update() height = root.winfo_height() if windowing == "x11": # On Linux, the menu bar height isn't being calculated correctly # for minsize height += self.menubar.winfo_reqheight() root.minsize(width=root.winfo_width(), height=height) self.download_panel.pack_forget() root.geometry('{}x{}'.format( lnp.userconfig.get_number('tkgui_width'), lnp.userconfig.get_number('tkgui_height'))) root.bind("<Configure>", lambda e: self.on_resize()) root.update() queue = download.get_queue('baselines') queue.register_start_queue(self.start_download_queue) queue.register_begin_download(self.start_download) queue.register_progress(self.download_progress) queue.register_end_download(self.end_download) queue.register_end_queue(self.end_download_queue) binding.update() root.bind('<<UpdateAvailable>>', lambda e: UpdateWindow(self.root)) # Used for cross-thread signaling and communication during downloads self.update_pending = Semaphore(1) self.queue = Queue.Queue() self.cross_thread_data = None self.reply_semaphore = Semaphore(0) self.download_text_string = '' root.bind('<<ConfirmDownloads>>', lambda e: self.confirm_downloading()) root.bind('<<ForceUpdate>>', lambda e: self.update_download_text()) root.bind( '<<ShowDLPanel>>', lambda e: self.download_panel.pack(fill=X, expand=N, side=BOTTOM)) root.bind('<<HideDLPanel>>', lambda e: self.download_panel.pack_forget()) self.cross_thread_timer = self.root.after(100, self.check_cross_thread)
def __init__(self): """ Constructor for TkGui. Params: lnp A PyLNP instance to perform actual work. """ self.root = root = Tk() self.updateDays = IntVar() self.downloadBaselines = BooleanVar() self.show_scrollbars = BooleanVar() self.autoclose = BooleanVar() self.do_reload = False controls.init(self) binding.init(lnp) if not self.ensure_df(): return root.option_add('*tearOff', FALSE) windowing = root.tk.call('tk', 'windowingsystem') if windowing == "win32": root.tk.call( 'wm', 'iconbitmap', root, "-default", get_resource('LNP.ico')) elif windowing == "x11": root.tk.call( 'wm', 'iconphoto', root, "-default", get_image(get_resource('LNP'))) elif windowing == "aqua": # OS X has no window icons pass root.title("PyLNP") self.vcmd = (root.register(validate_number), '%P') main = Frame(root) self.logo = logo = get_image(get_resource('LNPSMALL')) Label(root, image=logo, anchor=CENTER).pack(fill=X) main.pack(side=TOP, fill=BOTH, expand=Y) self.download_panel = controls.create_control_group( main, 'Download status') self.download_text = StringVar() self.download_status = Label( self.download_panel, textvariable=self.download_text) self.download_panel.pack(fill=X, expand=N, side=BOTTOM) self.download_status.pack(side=BOTTOM) self.n = n = Notebook(main) self.create_tab(OptionsTab, 'Options') self.create_tab(GraphicsTab, 'Graphics') self.create_tab(UtilitiesTab, 'Utilities') self.create_tab(AdvancedTab, 'Advanced') if 'dfhack' in lnp.df_info.variations: self.create_tab(DFHackTab, 'DFHack') if mods.read_mods(): self.create_tab(ModsTab, 'Mods') n.enable_traversal() n.pack(fill=BOTH, expand=Y, padx=2, pady=3) play_font = tkFont.Font(font='TkDefaultFont') play_font.config(weight=tkFont.BOLD, size=int(play_font['size'] * 1.5)) Style().configure('Big.TButton', font=play_font) play_button = controls.create_trigger_button( main, 'Play Dwarf Fortress!', 'Play the game!', launcher.run_df) play_button.configure(style='Big.TButton') play_button.pack(side=BOTTOM, fill=X, padx=(1, 3), pady=(0, 3)) self.menubar = self.create_menu(root) self.save_size = None root.update() height = root.winfo_height() if windowing == "x11": # On Linux, the menu bar height isn't being calculated correctly # for minsize height += self.menubar.winfo_reqheight() root.minsize(width=root.winfo_width(), height=height) self.download_panel.pack_forget() root.geometry('{}x{}'.format( lnp.userconfig.get_number('tkgui_width'), lnp.userconfig.get_number('tkgui_height'))) root.bind("<Configure>", lambda e: self.on_resize()) root.update() queue = download.get_queue('baselines') queue.register_start_queue(self.start_download_queue) queue.register_begin_download(self.start_download) queue.register_progress(self.download_progress) queue.register_end_download(self.end_download) queue.register_end_queue(self.end_download_queue) binding.update() root.bind('<<UpdateAvailable>>', lambda e: UpdateWindow(self.root)) # Used for cross-thread signaling and communication during downloads self.update_pending = Semaphore(1) self.queue = Queue.Queue() self.cross_thread_data = None self.reply_semaphore = Semaphore(0) self.download_text_string = '' root.bind('<<ConfirmDownloads>>', lambda e: self.confirm_downloading()) root.bind('<<ForceUpdate>>', lambda e: self.update_download_text()) root.bind('<<ShowDLPanel>>', lambda e: self.download_panel.pack( fill=X, expand=N, side=BOTTOM)) root.bind( '<<HideDLPanel>>', lambda e: self.download_panel.pack_forget()) self.cross_thread_timer = self.root.after(100, self.check_cross_thread)