QtDialog API
- class autokey.scripting.dialog_qt.QtDialog[source]
Provides a simple interface for the display of some basic dialogs to collect information from the user.
This version uses KDialog to integrate well with KDE. To pass additional arguments to KDialog that are not specifically handled, use keyword arguments. For example, to pass the –geometry argument to KDialog to specify the desired size of the dialog, pass
geometry="700x400"
as one of the parameters. All keyword arguments must be given as strings.A note on exit codes: an exit code of 0 indicates that the user clicked OK.
- calendar(title='Choose a date', format_str='%Y-%m-%d', date='today', **kwargs)[source]
Show a calendar dialog
Usage:
dialog.calendar_dialog(title="Choose a date", format="%Y-%m-%d", date="YYYY-MM-DD", **kwargs)
Note: the format and date parameters are not currently used
- Parameters:
title – window title for the dialog
format_str – format of date to be returned
date – initial date as YYYY-MM-DD, otherwise today
- Returns:
a tuple containing the exit code and date
- Return type:
DialogData(int, str)
- choose_colour(title='Select Colour', **kwargs)[source]
Show a Colour Chooser dialog
Usage:
dialog.choose_colour(title="Select Colour")
- Parameters:
title – window title for the dialog
- Returns:
a tuple containing the exit code and colour
- Return type:
DialogData(int, str)
- choose_directory(title='Select Directory', initialDir='~', rememberAs=None, **kwargs)[source]
Show a Directory Chooser dialog
Usage:
dialog.choose_directory(title="Select Directory", initialDir="~", rememberAs=None, **kwargs)
- Parameters:
title – window title for the dialog
initialDir – starting directory for the directory chooser dialog
rememberAs – gives an ID to this file dialog, allowing it to open at the last used path next time
- Returns:
a tuple containing the exit code and chosen path
- Return type:
DialogData(int, str)
Show a combobox menu
Usage:
dialog.combo_menu(options, title="Choose an option", message="Choose an option", **kwargs)
- Parameters:
options – list of options (strings) for the dialog
title – window title for the dialog
message – message displayed above the combobox
- Returns:
a tuple containing the exit code and user choice
- Return type:
DialogData(int, str)
- info_dialog(title='Information', message='', **kwargs)[source]
Show an information dialog
Usage:
dialog.info_dialog(title="Information", message="", **kwargs)
- Parameters:
title – window title for the dialog
message – message displayed in the dialog
- Returns:
a tuple containing the exit code and user input
- Return type:
DialogData(int, str)
- input_dialog(title='Enter a value', message='Enter a value', default='', **kwargs)[source]
Show an input dialog
Usage:
dialog.input_dialog(title="Enter a value", message="Enter a value", default="", **kwargs)
- Parameters:
title – window title for the dialog
message – message displayed above the input box
default – default value for the input box
- Returns:
a tuple containing the exit code and user input
- Return type:
DialogData(int, str)
Show a single-selection list menu
Usage:
dialog.list_menu(options, title="Choose a value", message="Choose a value", default=None, **kwargs)
- Parameters:
options – list of options (strings) for the dialog
title – window title for the dialog
message – message displayed above the list
default – default value to be selected
- Returns:
a tuple containing the exit code and user choice
- Return type:
DialogData(int, str)
Show a multiple-selection list menu
Usage:
dialog.list_menu_multi(options, title="Choose one or more values", message="Choose one or more values", defaults=[], **kwargs)
- Parameters:
options – list of options (strings) for the dialog
title – window title for the dialog
message – message displayed above the list
defaults – list of default values to be selected
- Returns:
a tuple containing the exit code and user choice
- Return type:
DialogData(int, List[str])
- open_file(title='Open File', initialDir='~', fileTypes='*|All Files', rememberAs=None, **kwargs)[source]
Show an Open File dialog
Usage:
dialog.open_file(title="Open File", initialDir="~", fileTypes="*|All Files", rememberAs=None, **kwargs)
- Parameters:
title – window title for the dialog
initialDir – starting directory for the file dialog
fileTypes – file type filter expression
rememberAs – gives an ID to this file dialog, allowing it to open at the last used path next time
- Returns:
a tuple containing the exit code and file path
- Return type:
DialogData(int, str)
- password_dialog(title='Enter password', message='Enter password', **kwargs)[source]
Show a password input dialog
Usage:
dialog.password_dialog(title="Enter password", message="Enter password", **kwargs)
- Parameters:
title – window title for the dialog
message – message displayed above the password input box
- Returns:
a tuple containing the exit code and user input
- Return type:
DialogData(int, str)
- save_file(title='Save As', initialDir='~', fileTypes='*|All Files', rememberAs=None, **kwargs)[source]
Show a Save As dialog
Usage:
dialog.save_file(title="Save As", initialDir="~", fileTypes="*|All Files", rememberAs=None, **kwargs)
- Parameters:
title – window title for the dialog
initialDir – starting directory for the file dialog
fileTypes – file type filter expression
rememberAs – gives an ID to this file dialog, allowing it to open at the last used path next time
- Returns:
a tuple containing the exit code and file path
- Return type:
DialogData(int, str)