10.7. Module gui

The cerebro.gui module provides access to simple graphic interfaces, such as input dialogs, file selection, progress indicator, etc.

Functions

Classes

cerebro.gui.critical_box(title, text)[source]
Parameters:
  • title (string) – window title.
  • text (string) – message text.

Displays an error message.

_images/capi_gui_error.png
cerebro.gui.get_existing_directory(title)[source]
Parameters:title (string) – selection dialog title.
Returns:path to the selected directory.
Return type:string

Displays a directory selection dialog and returns the selected one. If the user cancels selection, None returns.

dir = cerebro.gui.get_existing_directory('Select directory')
if dir != None:
        print('Selected directory', dir)        
cerebro.gui.get_open_file_name(title, filter='')[source]
Parameters:
  • title (string) – selection dialog title.
  • filter (string) –

    file filter by type, e.g., '*.txt'.

    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 != None:
        print('Selected file:', file)   
cerebro.gui.get_open_file_names(title, filter='')[source]
Parameters:
  • title (string) – selection dialog title.
  • filter (string) –

    file filter by type, e.g., '*.txt'

    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 != None:
        print('Selected files:', files)
cerebro.gui.get_save_file_name(title, suffix, filename='')[source]
Parameters:
  • title (string) – selection dialog title.
  • suffix (string) – file suffix (extension).
  • filename (string) – file default name.
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 != None:
        print('File to be saved:', file)
cerebro.gui.information_box(title, text)[source]
Parameters:
  • title (string) – window title.
  • text (string) – message text.

Displays a window with the message.

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)[source]
Parameters:
  • type (int) – message type.
  • task_id (int) – the ID of the task the message will added to.
  • parent_message_id (int) – the ID of the parent message, i.e. the message to which this message is a response.
  • html_text (string) – the text of the message in html format. The text can also be unformatted.
  • attachments (list(string,)) – a list of files that will be attached to the message.
  • attachment_as_links (list(string,)) – a list of files that will be attached to the message as links.
  • work_time (float) – time in minutes.
  • status_id (int) – the task status ID to which the task will be switched once the message has been sent.
  • client_visible (bool) – If equal to True, the message is visible to clients.

Opens the standard unblocking message-editor window the next time a new message is sent to the task.

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 "Отчет" or "Отчет за ресурс", it indicates the time signed off (declared by the current message author). If the message type is "Рецензия", 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)[source]
Parameters:
  • title (string) – window title.
  • text (string) – question text.
Returns:

True, if the user pressed “Yes” button.

Return type:

bool

Displays a dialog with the question.

_images/capi_gui_question.png
cerebro.gui.warning_box(title, text)[source]
Parameters:
  • title (string) – window title.
  • text (string) – message text.

Displays a warning window.