The cerebro.gui module provides access to simple graphic interfaces, such as input dialogs, file selection, progress indicator, etc.
cerebro.gui.critical_box(title, text)
Parameters: | |
cerebro.gui.get_existing_directory(title)
Parameters: | title (string) – selection dialog title. |
Returns: | path to the selected directory. |
Return type: | string |
dir = cerebro.gui.get_existing_directory('Select directory')
if dir:
print('Selected directory', dir)
cerebro.gui.get_open_file_name(title, filter='')
Parameters: | If you are going to use several filters at once, separate them by ‘;;’, e.g.: 'Images (*.png .xpm .jpg);;Text files (.txt);;XML files (.xml)' |
Returns: | path to the selected file. |
Return type: | string |
Displays a file selection dialog and returns the selected file. If the user cancels selection, None returns.
file = cerebro.gui.get_open_file_name('Select file', '*.txt')
if file:
print('Selected file:', file)
See also
cerebro.gui.get_open_file_names(title, filter='')
Parameters: | If you are going to use several filters at once, separate them by ‘;;’, e.g.: 'Images (*.png .xpm .jpg);;Text files (.txt);;XML files (.xml)' |
Returns: | a list of paths to the selected files. |
Return type: | list(string,) |
Displays a file selection dialog - with an option to select more than one file - and returns the selected file(s). If the user cancels selection, None returns.
files = cerebro.gui.get_open_file_names('Select files', '*.txt')
if files:
print('Selected files:', files)
See also
cerebro.gui.get_save_file_name(title, suffix, filename='')
Parameters: | |
Returns: | path to the file. |
Return type: | string |
Displays a dialog to select a file for saving and returns the selected file. If the user cancels selection, None returns.
file = cerebro.gui.get_save_file_name('Save file', 'txt')
if file:
print('File to be saved:', file)
cerebro.gui.information_box(title, text)
Parameters: | |
cerebro.gui.message_editor(type, task_id, parent_message_id=None, html_text=None, attachments=None, attachment_as_links=None, work_time=None, status_id=None, client_visible=None)
Parameters: | |
All arguments other than message type and task ID are optional. If it is not necessary to use certain message parameters, use the hex None instead.
Files or links to files in the lists ‘attachments’ and ‘attachment_as_links’ must have a full path.
To give a a task the ‘No Status’ status, set the argument ‘status_id’ to 0.
The ‘work_time’ argument should only be set for reports or reviews. If the message type is "Report" or "Resourse report", it indicates the time signed off (declared by the current message author). If the message type is "Review", it indicates the time signed off and approved for the previous Report.
current_task = cerebro.core.current_task()
cerebro.gui.message_editor(cerebro.aclasses.AbstractMessage.TYPE_NOTE, current_task.id(), None, 'Test')
cerebro.gui.question_box(title, text)
Parameters: | |
Returns: | True, if the user pressed “Yes” button. |
Return type: | bool |
Displays a dialog with the question.
cerebro.gui.warning_box(title, text)
Parameters: | |
classcerebro.gui.AccountDialog(title, label='', store_key='')
Parameters: | |
daccount = cerebro.gui.account_dialog('Example', 'Enter your login and password', 'store_key')
res = daccount.execute()
if res == True:
print('Login and password entered by user:', daccount.login(), daccount.password())
daccount.store('store_key') # saving the password for future calls
execute()
Returns: | True, if the user entered login and password and pressed “OK” button or if the login and password were saved earlier. |
Return type: | bool |
If the login and password were saved during a previous call, the dialog window is not displayed, “True” returns, and then you can resolve the login and password by using the following methods: login() and password().
login()
Returns: | login entered by user. |
Return type: | string |
See also
password()
Returns: | password entered by user. |
Return type: | string |
set_login(login)
Parameters: | login (string) – login. |
See also
store(store_key, expires=7)
Parameters: | |
Note
All passwords are stored in encrypted form.
classcerebro.gui.InputDialog(type, title, label='', storeKey='')
Parameters: | |
Input dialog class.
dinput = cerebro.gui.input_dialog(cerebro.gui.InputDialog.TYPE_INT, 'Sample input', 'Enter')
dinput.set_range(-100, 100)
dinput.set_value(10)
res = dinput.execute()
if res == True:
print('Entered value:', dinput.value())
display_format()
Returns: | The format used to display the time/date of the date time edit. |
Applicable for the cerebro.gui.InputDialog.TYPE_DATETIME type only.
See also
execute()
Returns: | True, if user entered a value and pressed “Ok” button. |
Return type: | bool |
items()
Returns: | list of items to select from. |
Return type: | list(string,) |
Applicable for the cerebro.gui.InputDialog.TYPE_COMBOBOX type only.
See also
max()
Returns: | maximal input value. |
Applicable for the cerebro.gui.InputDialog.TYPE_FLOAT and cerebro.gui.InputDialog.TYPE_INT types only.
See also
min()
Returns: | minimal input value. |
Applicable for the cerebro.gui.InputDialog.TYPE_FLOAT and cerebro.gui.InputDialog.TYPE_INT types only.
See also
set_display_format(format)
Parameters: | format (string) – The format used to display the time/date of the date time edit. |
For example:
dinput.set_display_format('yyyy.MM.dd hh:mm") # for example: 2014.01.01 13:09
Applicable for the cerebro.gui.InputDialog.TYPE_DATETIME type only.
See also
set_items(items)
Parameters: | items (list(string,)) – list of items to select from. |
Applicable for the cerebro.gui.InputDialog.TYPE_COMBOBOX type only.
See also
set_range(min, max)
Parameters: | |
Applicable for the cerebro.gui.InputDialog.TYPE_FLOAT and cerebro.gui.InputDialog.TYPE_INT types only.
See also
set_value(val)
Parameters: | val – default value. |
Type of input argument is defined by type of input dialog.
See also
type()
Returns: | type of input value. |
Return type: | int |
value()
Returns: | value entered by user. |
See also
classcerebro.gui.ProgressBox(title, min=0, max=100)
Parameters: | |
prgbar = cerebro.gui.ProgressBox('Progress Window', 0, 100)
prgbar.set_label('Progress...')
prgbar.show()
for i in range(0,100):
if prgbar.was_canceled() == True: # checking if the operation hasn't been canceled by user
break
prgbar.set_value(i)
prgbar.close()
close()
Closes a progress window.
See also
hide_cancel_button()
Hides “Cancel” button.
Use this method if you want to prevent users from canceling the operation. If you leave the option to cancel available, you should use the was_canceled() method in order to know if the “Cancel” button was pressed or not.
label()
Returns: | text label. |
Return type: | string |
See also
max()
Returns: | maximal progress value. |
Return type: | int |
See also
min()
Returns: | minimal progress value. |
Return type: | int |
See also
reset()
Resets progress value the minimum.
set_label(label)
Parameters: | label (string) – text label. |
See also
set_range(min, max)
Parameters: | |
See also
set_title(title)
Parameters: | |
See also
set_value(value)
Parameters: | value (int) – progress value. |
Sets progress value.
See also
show()
Displays a progress window.
See also
title()
Returns: | progress window title. |
Return type: | string |
See also
value()
Returns: | progress value. |
Return type: | int |
See also
was_canceled()
Returns: | True, if the user pressed the “Cancel” button. |
Return type: | bool |