-
Couldn't load subscription status.
- Fork 6
Simple dialog boxes
Provides a simple dialog boxes for interaction with a user:
- make choices (SelectBox, OptionBox)
- enter new data (TextBox, NumberBox, DateBox)
- get paths (FolderPathBox, FilePathBox)
- show information (MessageBox)
- make a decision (ActionBox)
In script interactions are invoked by simple function calls.
- Prepare
- create project directory in
LIBREOFFICE_PATH/4/user/Scripts/python/ - copy
config.iniin project directory and edit section to customize behavior (optional)
- create project directory in
- Write code
-
run
unoditwith parameterdialogs_createpython3 ./unodit.py -m 'dialogs_create' -d 'LIBREOFFICE_PATH/4/user/Scripts/python/TestLib' -a 'Test_dialogs' -
write your code in generated file
Test_dialogs.py
-
- Prepare extension files
-
run
unoditwith parameterdialogs_filespython3 ./unodit.py -m 'dialogs_files' -d 'LIBREOFFICE_PATH/4/user/Scripts/python/TestLib' -a 'Test_dialogs' -
change
description.txt,title.txtandlicense.txt(optional)
-
- Create extension
-
run
unoditwith parameterdialogs_oxtpython3 ./unodit.py -m 'dialogs_oxt' -d 'LIBREOFFICE_PATH/4/user/Scripts/python/TestLib' -a 'Test_dialogs' -
install extension
Test_dialogs_Devel.oxt
-
Available options for parameter -m: 'dialogs_create', 'dialogs_files', 'dialogs_oxt', 'dialogs_all'
'dialogs_all' = all in one, use for testing
TestLib/
src/
Test_dialogs.py dialogs_create
pythonpath/
simple_dialogs.py ---------------
META-INF/
manifest.xml
description/
description.txt dialogs_files
title.txt
registration/
license.txt
Addons.xcu
description.xml --------------
Test_dialogs_Devel.oxt dialogs_oxt
All dialogs are defined in simple_dialogs.py. In order to use dialog eg. SelectBox in your script Test_dialogs.py import it:
from simple_dialogs import SelectBox
GUI operations are a simple a matter of invoking SelectBox functions with a few parameters
s = SelectBox(message="Select your favorite city", title="My choice", choices=["New York","London", "Paris", "Berlin"])
print(s)
Generate files with option 'dialogs_create' and read Test_dialogs.py for more information.
Usage: SelectBox(message="Select one item", title="SelectBox", choices=['a','b','c'])
Return: a string, or None

Usage: OptionBox(message="Select multiple items", title="OptionBox", choices=['a','b','c'])
Return: a tuple of selected items, or empty tuple

Usage: TextBox(message="Enter your input", title="TextBox", text="")
Return: a string, or None

Usage: NumberBox(message="Enter a number", title="NumberBox", default_value=0, min_=-10000, max_=10000, decimals=0)
Return: an integer/float or None

Usage: DateBox(message="Date of birth", title="BirthDay")
Return: the selected date in format YYYYMMDD

Usage: FolderPathBox(title='Get directory path')
Return: the path of a directory or an empty string

Usage: FilePathBox(title='Get file path')
Return: the path of a file or an empty string

Usage: MessageBox(message="Message", title="MessageBox")

Usage: ActionBox(message="Message", title="ActionBox")
Return: OK or NO or Cancel
