tkgui.tkgui module

TKinter-based GUI for PyLNP.

class tkgui.tkgui.TkGui[source]

Bases: object

Main GUI window.

static change_entry(key, var)[source]

Commits a change for the control specified by key.

Parameters
  • key – The key for the control that changed.

  • var – The variable bound to the control.

check_cross_thread()[source]

Used to raise cross-thread events in the UI thread.

configure_terminal(first_run=False)[source]

Configures the command used to launch a terminal on Linux. If first_run is set, a terminal will be selected automatically.

configure_updates(days)[source]

Sets the number of days until next update check.

confirm_downloading()[source]

Ask the user if downloading may proceed.

create_menu(root)[source]

Creates and returns the menu bar.

Parameters

root – Root window for the menu bar.

create_tab(class_, caption)[source]

Creates a new tab and adds it to the main Notebook.

Parameters
  • class_ – Reference to the class representing the tab.

  • caption – Caption for the newly created tab.

static cycle_option(field)[source]

Cycles through possible values for an option.

Parameters

field – The option to cycle.

download_progress(queue, url, progress, total)[source]

Event handler for download progress.

end_download(queue, url, target, success)[source]

Event handler for the end of a download.

end_download_queue(queue)[source]

Event handler for the end of a download queue.

ensure_df()[source]

Ensures a DF installation is active before proceeding.

exit_program()[source]

Quits the program.

load_params()[source]

Reads configuration data.

migrate_settings()[source]

Migrates settings from a previous DF install.

static on_invalid_config(errors)[source]

Notifies a user about an invalid configuration.

on_program_running(path, is_df)[source]

Called by the main LNP class if a program is already running.

on_query_migration()[source]

If no saves are detected, offer to import from an older pack.

on_request_update_permission(interval)[source]

Asks the user if update checking should be performed.

on_resize()[source]

Called when the window is resized.

on_update_available()[source]

Called by the main LNP class if an update is available.

static populate_menu(collection, menu, method)[source]

Populates a menu with items from a collection.

Parameters
  • collection – A collection of menu item data.

  • menu – The menu to create the items under.

  • method – The method to be called when the menu item is selected.

reload_program()[source]

Reloads the program to allow the user to change DF folders.

restore_defaults()[source]

Restores default configuration data.

static run_df()[source]

Launches Dwarf Fortress, reporting any errors when launching.

run_init()[source]

Opens the init editor.

static run_program(path)[source]

Launches another program.

Parameters

path – Path to the program to launch.

static save_params()[source]

Writes configuration data.

send_update_event(force=False)[source]

Schedules an update for the download text, if not already pending.

static set_autoclose()[source]

Toggles automatic closing of the launcher.

set_downloads()[source]

Sets the option for auto-download of baselines.

static set_option(field)[source]

Sets an option directly.

Parameters

field – The field name to change. The corresponding value is automatically read.

set_show_scroll()[source]

Toggles if scroll bars should always be shown. Used to work around a bug with some themes that modify Windows system files.

static show_about()[source]

Shows about dialog for the program.

static show_df_info()[source]

Shows basic information about the current DF install.

static show_help()[source]

Shows help for the program.

start()[source]

Starts the UI.

start_download(queue, url, target)[source]

Event handler for the start of a download.

start_download_queue(queue)[source]

Event handler for starting a download queue.

update_download_text()[source]

Updates the text in the download information.

tkgui.tkgui.fixed_map(option)[source]
tkgui.tkgui.get_image(filename)[source]

Open the image with the appropriate extension.

Parameters

filename – The base name of the image file.

Returns

A PhotoImage object ready to use with Tkinter.

tkgui.tkgui.validate_number(value_if_allowed)[source]

Validation method used by Tkinter. Accepts empty and float-coercable strings.

Parameters

value_if_allowed – Value to validate.

Returns

True if value_if_allowed is empty, or can be interpreted as a float.