Baby Language Lab Scripts
A collection of data processing tools.
 All Classes Namespaces Files Functions Variables Pages
utils.ui_utils.UIUtils Class Reference

A collection of static methods and constants for common UI-related tasks. More...

Inheritance diagram for utils.ui_utils.UIUtils:

Static Public Member Functions

def setup_gtk
 Sets some common GTK properties that all of the apps use. More...
 
def set_font_size
 Sets the font size for a given widget. More...
 
def get_icon_path
 Constructs the full path to an icon, given a value from the BUTTON_ICONS enum, and a value from the BUTTON_ICON_SIZES enum. More...
 
def create_button
 Creates a gtk.Button with an icon on it. More...
 
def show_confirm_dialog
 Displays a popup confirmation dialog with yes/no buttons. More...
 
def show_no_sel_dialog
 Displays a popup dialog (with an ok button) that tells the user to select a row (presumably in some type of UI list). More...
 
def show_empty_form_dialog
 Displays a popup dialog (with an ok button) that tells the user to make sure all options in a form have been filled out. More...
 
def show_message_dialog
 Displays a popup dialog (with an ok button) that presents a textual message. More...
 
def get_time_spinners
 Creates a set of gtk.SpinButton inputs to allow the user to input a time in the format hh:mm:ss. More...
 
def get_cur_timestamp_str
 Returns a string containing the current date and time. More...
 
def get_db_timestamp_str
 Accepts a string representing a datetime that was retrieved from the database, and converts it into a format suitable for display in the UI. More...
 
def utc_to_local_str
 
def build_file_filter
 Constructs a gtk.FileFilter object for a set of file extensions. More...
 
def build_simple_combo
 Builds a simple combo box. More...
 
def build_simple_liststore
 Builds a simple gtk.ListStore. More...
 
def build_multiselect_treeview
 Builds a treeview (a grid with selectable rows) with a single column. More...
 
def build_options_liststore
 Builds a gtk.ListStore that contains a group of common combo options stored in the DBConstants.COMBO_OPTIONS enum (these ultimately come from the database). More...
 
def calc_treeview_col_min_width
 Computes the minimum number of pixels (width) needed to show a treeview column with the specified title text. More...
 
def build_options_combo
 Builds a gtk.ComboBox widget that contains a group of common combo options stored in the DBConstants.COMBO_OPTIONS enum (these ultimately come from the database). More...
 
def build_regex_helper_combo
 Builds a gtk.ComboBox containing options for "common regexs" (COMBO_GROUPS.COMMON_REGEXS). More...
 
def browse_file
 This method opens an "open file" dialog, and populates a text entry widget with the resulting path. More...
 
def browse_folder
 This method opens an "open folder" dialog, and populates a text entry widget with the resulting path. More...
 
def open_file
 Shows an "open file" dialog, returning a user-selected filename (if any). More...
 
def open_folder
 Shows an "open folder" dialog, returning a user-selected foldername (if any). More...
 
def save_file
 Shows a "Save file" dialog, returning the path to a user-selected location. More...
 
def show_entry_dialog
 Shows a dialog box with a message, a single text entry, and a set of buttons (e.g. More...
 
def show_file_dialog_with_checks
 This method shows a a file dialog box (for "open" or "save") that (in addition to its regular buttons and controls) contains one or more checkboxes that the user can toggle. More...
 
def show_file_dialog
 This method shows a a file dialog box (for "open" or "save") with controls that allow the user to select a file. More...
 

Static Public Attributes

 last_filechooser_location = None
 
 WAV_FILE_FILTER = None
 
 TRS_FILE_FILTER = None
 
 ALL_FILE_FILTER = None
 
 CSV_FILE_FILTER = None
 
 TRS_CSV_FILE_FILTER = None
 
string DB_DT_OUTPUT_FMT = '%Y-%m-%d %H:%M:%S'
 
string DT_DISPLAY_FMT = '%b %d, %Y %I:%M %p'
 
tuple BUTTON_ICONS
 
tuple BUTTON_ICON_SIZES
 

Static Private Member Functions

def _fill_entry
 This is an internal helper method for build_regex_helper_combo(). More...
 

Detailed Description

A collection of static methods and constants for common UI-related tasks.

This class should never be instantiated.

Definition at line 18 of file ui_utils.py.

Member Function Documentation

def utils.ui_utils.UIUtils._fill_entry (   combo,
  entry 
)
staticprivate

This is an internal helper method for build_regex_helper_combo().

It populates a text entry with a regex string corresponding to the selected option in the combobox. It is called every time the combobox selection changes.

Parameters
combo(gtk.ComboBox) this is a combobox created with the options for the DBConstants.COMBO_GROUPS.COMMON_REGEXS group
entry(gtk.Entry) a text entry to populate with the regex string for the selected combobox option

Definition at line 387 of file ui_utils.py.

def utils.ui_utils.UIUtils.browse_file (   title,
  entry,
  filters = [],
  auto_fill_entry = None,
  auto_fill_file_extension = 'wav' 
)
static

This method opens an "open file" dialog, and populates a text entry widget with the resulting path.

It's useful to hook up to a "browse" button in the UI. This method blocks until the user clicks ok.

Parameters
title(string) text to display in the titlebar of the "open file" dialog
entry(gtk.Entry) an entry widget to populate with the path name after the user clicks ok in the "open file" dialog
filters(list=[]) list of gtk.FileFilter objects. A dropdown list of file types displaying these is shown in the "open file" dialog. You can use the constants in this class to build a list (UIUtils.ALL_FILE_FILTER, UIUtils.WAV_FILE_FILTER, UIUtils.TRS_FILE_FILTER, etc.)
auto_fill_entry(gtk.Entry=None) an optional gtk entry. It is possible to automatically locate another file with the same name as the one the user selects, but a different file extension. This is useful, for example, when the user is locating a trs file, and you want to automatically locate the corresponding wav file. If this param is not None, an automatic search will be done for the corresponding wav file and, if it is found, the entry will be populated with the path. The search encompasses the current directory (the one the user's selected file is in) and the parent directory.
auto_fill_file_extension(string='wav') an optional file extension string, used together with auto_fill_entry. This dictates the type of file extension that the search described in the auto_fill_entry parameter documentation.

Definition at line 420 of file ui_utils.py.

def utils.ui_utils.UIUtils.browse_folder (   title,
  entry,
  filters = [] 
)
static

This method opens an "open folder" dialog, and populates a text entry widget with the resulting path.

It's useful to hook up to a "browse" button in the UI. This method blocks until the user clicks ok.

Parameters
title(string) text to display in the titlebar of the "open folder" dialog
entry(gtk.Entry) an entry widget to populate with the path name after the user clicks ok in the "open folder" dialog
filters(list=[]) list of gtk.FileFilter objects. This specifies the types of files (via their extensions) that will be visible in the "open folder" dialog. Since the dialog doesn't let you select files (only folders), any visible files will appear "greyed out", and this param really just affects with the user can see, not what they can do. In general, it is probably most useful to either leave this empty or set it to UIUtils.ALL_FILE_FILTER.

Definition at line 447 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_file_filter (   title,
  patterns 
)
static

Constructs a gtk.FileFilter object for a set of file extensions.

Parameters
title(string) the title for this filer. This title is displayed in the dropdown combobox of file types in filechooser dialogs
patterns(list) a list of strings, where each is a shell-expandible file extension (like '*.wav' or '*.trs')
Returns
(gtk.FileFilter) a gtk.FileFilter object that can be passed to a filechooser dialog

Definition at line 241 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_multiselect_treeview (   labels,
  vals,
  val_type,
  header_text 
)
static

Builds a treeview (a grid with selectable rows) with a single column.

The user may select multiple rows at once. The treeview has a hidden 'ID' column appended to it - you can use this to track the indices of the selected rows (or you can use the vals parameter). See the gtk docs for more info on treeviews. Here is what the treeview looks like:

Parameters
labels(list) list of strings. These are the values to display in the rows (one element per row).
vals(list) list of anything. These values will be assigned to the rows in the same order as the labels list (therefore it must be of the same length). You can retrieve the values of selected rows when querying the treeview widget's selection state.
val_type(function pointer) this is function pointer corresponding to a type (like str, int, float, etc.) or it is a type constant from the gobject module (eg. gobject.TYPE_STRING, gobject.TYPE_FLOAT, etc.). It indicates the type of the elements in the vals array.
header_text(string) text to display at the top of the single column.
Returns
(gtk.TreeView) a gtk.TreeView object that's set up and ready to embed in the UI

Definition at line 303 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_options_combo (   group_id,
  active_index = 0,
  include_empty_option = True 
)
static

Builds a gtk.ComboBox widget that contains a group of common combo options stored in the DBConstants.COMBO_OPTIONS enum (these ultimately come from the database).

For example, you could create a combobox that allows you to select one of the LENA speaker codes.

Parameters
group_id(int) a value from the DBConstants.COMBO_GROUPS enum, indicating which group of options to insert into the liststore.
active_index(int=0) the row index of the entry to auto-select. If include_empty_option is True, and this is zero, then the empty entry will be selected.
include_empty_option(boolean=True) if True, an option with an empty string label will be pre-pended to the list of options. This can be used as a "nothing-selected" option.
Returns
(gtk.ComboBox) a combobox widget containing all of the options for the specified group.

Definition at line 357 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_options_liststore (   group_id,
  include_empty_option = True 
)
static

Builds a gtk.ListStore that contains a group of common combo options stored in the DBConstants.COMBO_OPTIONS enum (these ultimately come from the database).

For example, you could create a liststore of all LENA speaker codes, then display them in a treeview - this is what was done to create the screenshot below:

You could just as easily use this liststore to create a combobox, or something else.

Parameters
group_id(int) a value from the DBConstants.COMBO_GROUPS enum, indicating which group of options to insert into the liststore. Combo options are grouped according to their type. For example, passing a group_id of DBConstants.COMBO_GROUPS.SPEAKER_CODES would create a liststore like the one used in the screenshot shown above.
include_empty_option(boolean=True) if True, an option with an empty string label will be pre-pended to the liststore. This can be used as a "nothing-selected" option.
Returns
(gtk.ListStore) a liststore object that contains all of the options from the specified group. This object can be used as a data-store backing for other widgets.

Definition at line 328 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_regex_helper_combo (   entry)
static

Builds a gtk.ComboBox containing options for "common regexs" (COMBO_GROUPS.COMMON_REGEXS).

When the selected option changes, a text entry box is populated with the regex string. (This is just a wrapper around the build_options_combo() method for common regexs, to add the ability to connect the 'changed' signal.)

Parameters
entry(gtk.Entry) a text entry box that will be populated with a regular expression string when the selection changes
Returns
(gtk.ComboBox) a combobox with the 'changed' signal set up

Definition at line 376 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_simple_combo (   types,
  labels,
  vals 
)
static

Builds a simple combo box.

Each entry has a title and a value. The title is displayed, the value is hidden to the user. Here's what it looks like:

By default, the first option is selected. Note: You can make this a row with a label that is an empty string (and value None) if you want it to appear as though nothing is selected by default (as in the above image).

Parameters
types(tuple) a 2-tuple of type functions (e.g. int, float, str). The first element is the type of the label, and the second is the type of the value. In most cases, the type of the label should be string, so you should pass the the str function as the first element. Alternatively, you can also use the type constants from the gobject module (gobject.TYPE_STRING, gobject.TYPE_FLOAT, etc.).
labels(list) a list of strings - these will be the options made available for the user to select.
vals(list) a list of anything - the length must be equal to the length of the labels param. These are the values that the labels will be given in the combobox model (assigned in the same order as the elements in the labels list appear). These values can be retrieved when you query the combobox selection state.
Returns
(gtk.ComboBox) a gtk.ComboBox object that can be used in the UI

Definition at line 262 of file ui_utils.py.

def utils.ui_utils.UIUtils.build_simple_liststore (   labels,
  vals,
  val_type 
)
static

Builds a simple gtk.ListStore.

This is the data store backing for a combobox or treeview.

Parameters
labels(list) list of strings that will be displayed in the list of treeview
vals(list) list of objects, must be same length as labels list. These values are assigned to the rows/options in the widget, and can be retrieved when the widget's selection state is queried.
val_type(function pointer) this is function pointer corresponding to a type (like str, int, float, etc.) or it is a type constant from the gobject module (eg. gobject.TYPE_STRING, gobject.TYPE_FLOAT, etc.). It indicates the type of the elements in the vals array.
Returns
(gtk.ListStore) a liststore object for use in the creation of a combobox or treeview (or potentially other types of widgets).

Definition at line 282 of file ui_utils.py.

def utils.ui_utils.UIUtils.calc_treeview_col_min_width (   col_name)
static

Computes the minimum number of pixels (width) needed to show a treeview column with the specified title text.

This is an approximation that was emperically determined, and uses magic numbers. It is not guarenteed to work, and should probably be removed. But you can try it if you feel frustrated.

Parameters
col_name(string) the text that will be displayed in the column header
Returns
(int) an approximation of the number of pixel you will need to applocate for the width of the treeview column, in order for the whole col_name header string to be displayed.

Definition at line 347 of file ui_utils.py.

def utils.ui_utils.UIUtils.create_button (   label,
  img_path,
  icon_size_dir = BUTTON_ICON_SIZES.PX32 
)
static

Creates a gtk.Button with an icon on it.

You can create predefined types of buttons (corresponding to common actions) of any given size by passing in parameters from this class' button enums. Note: in order for this to work, you must first tell gtk to allow images on button - this is done in the setup_gtk() method, so you should call that first.

Parameters
label(string) the text to display on the button.
img_path(string) a value from the BUTTON_ICONS enum (indicates the button action)
icon_size_dir(string=BUTTON_ICON_SIZES.PX32) a value from the BUTTON_ICON_SIZES enum, indicating the size of the icon that will be placed on the button. Default is 32x32 pixels.
Returns
(gtk.Button) a gtk.Button object with the specified text and image.

Definition at line 112 of file ui_utils.py.

def utils.ui_utils.UIUtils.get_cur_timestamp_str ( )
static

Returns a string containing the current date and time.

Returns
(string) the current timestamp, formatted according to the UIUtils.DT_DISPLAY_FMT pattern.

Definition at line 209 of file ui_utils.py.

def utils.ui_utils.UIUtils.get_db_timestamp_str (   timestamp)
static

Accepts a string representing a datetime that was retrieved from the database, and converts it into a format suitable for display in the UI.

Parameters
timestamp(string) a timestamp string (retrieved from the DB) in the format UIUtils.DB_DT_OUTPUT_FMT
Returns
(string) a timestamp string in the format UIUtils.DT_DISPLAY_FMT

Definition at line 216 of file ui_utils.py.

def utils.ui_utils.UIUtils.get_icon_path (   img_path,
  icon_size_dir = BUTTON_ICON_SIZES.PX32 
)
static

Constructs the full path to an icon, given a value from the BUTTON_ICONS enum, and a value from the BUTTON_ICON_SIZES enum.

Parameters
img_path(string) this must be a value from the BUTTON_ICONS enum
icon_size_dir(string=BUTTON_ICON_SIZES.PX32) this must be a value from the BUTTON_ICON_SIZES enum. Size defaults to 32x32 pixels.
Returns
(string) the full path to the icon file

Definition at line 102 of file ui_utils.py.

def utils.ui_utils.UIUtils.get_time_spinners (   label = None,
  hours = 0,
  mins = 0,
  secs = 0 
)
static

Creates a set of gtk.SpinButton inputs to allow the user to input a time in the format hh:mm:ss.

These entries are packing into a horizontal gtk.HBox container, which is fitted with a label. Here's what the container looks like when it's displayed in the UI:

Parameters
label(string=None) an optional label to pack at the left side of the container
hours(int=0) value to default the hours spinbutton to
mins(int=0) value to default the minutes spinbutton to
secs(int=0) value to default the seconds spinbutton to
Returns
(tuple) returns a tuple of 4 items: (hbox_container, hours_spinbutton, mins_spinbutton, secs_spinbutton). The spinbuttons are already packed into the hbox container. They are returned individually as well just for convenience (so the caller can easily hook up signals without having to extract them from the container first).

Definition at line 176 of file ui_utils.py.

def utils.ui_utils.UIUtils.open_file (   title = 'Open File',
  filters = [],
  save_last_location = False,
  cur_location = None 
)
static

Shows an "open file" dialog, returning a user-selected filename (if any).

This method blocks until the user clicks ok.

Parameters
title(string='Open File') string to display in the dialog box titlebar
filters(list=[]) list of gtk.FileFilter objects for the dialog to use. A combobox is displayed listing these filters (generally file extensions). Only files matching the pattern will be viewable in the browse pane. If no filters are specified, all files will be visible.
save_last_location(boolean=False) if True, the directory containing the selected file will be saved (to UIUtils.last_filechoose_location), and the next "open" or "save" dialog will use it as the current directory
cur_location(string=None) if this is non-None, it specifies the path to the folder to use as the current directory - this is the directory initially displayed when the dialog pops up
Returns
(string) the path to the user-selected file. If the user did not select a file, and instead clicked the cancel button or closed the dialog, this method will return None.

Definition at line 460 of file ui_utils.py.

def utils.ui_utils.UIUtils.open_folder (   title = 'Select Folder',
  filters = [],
  save_last_location = False,
  cur_location = None 
)
static

Shows an "open folder" dialog, returning a user-selected foldername (if any).

This method blocks until the user clicks ok.

Parameters
title(string='Open Folder') string to display in the dialog box titlebar
filters(list=[]) list of gtk.FileFilter objects. This specifies the types of files (via their extensions) that will be visible in the "open folder" dialog. Since the dialog doesn't let you select files (only folders), any visible files will appear "greyed out", and this param really just affects with the user can see, not what they can do. In general, it is probably most useful to either leave this empty or set it to UIUtils.ALL_FILE_FILTER.
save_last_location(boolean=False) if True, the directory containing the selected file will be saved (to UIUtils.last_filechoose_location), and the next "open" dialog will use it as the current directory
cur_location(string=None) if this is non-None, it specifies the path to the folder to use as the current directory - this is the directory initially displayed when the dialog pops up
Returns
(string) the path to the user-selected folder. If the user did not select a folder, and instead clicked the cancel button or closed the dialog, this method will return None.

Definition at line 476 of file ui_utils.py.

def utils.ui_utils.UIUtils.save_file (   title = 'Save File',
  filters = [],
  open_now_opt = False,
  save_last_location = False,
  cur_location = None 
)
static

Shows a "Save file" dialog, returning the path to a user-selected location.

This method blocks until the user clicks ok.

Parameters
title(string="Save File") text to display in the dialog box titlebar
filters(list=[]) list of gtk.FileFilter objects. This specifies the types of files (via their extensions) that will be visible in the "save" dialog.
open_now_opt(boolean=False) if True, a checkbox will be displayed along the bottom of the save dialog box that allows the use to open the saved file as soon as it is finished being written to disk (opened in Excel).
save_last_location(boolean=False) if True, the directory containing the selected file will be saved (to UIUtils.last_filechoose_location), and the next "open" or "save" dialog will use it as the current directory
cur_location(string=None) a path to a folder to set the dialog to show when it opens. If None, this will display whatever directory GTK feels like.
Returns
(string) the save path. If the user did not enter one, and instead clicked the cancel button or closed the dialog, this method will return None.

Definition at line 491 of file ui_utils.py.

def utils.ui_utils.UIUtils.set_font_size (   widget,
  pt_size,
  bold = False 
)
static

Sets the font size for a given widget.

Parameters
widget(Gtk Container) the widget whose font size you'd like to set
pt_size(int, possibly float too?) the font size (pt)
bold(boolean=False) Set to True to make font bold

Definition at line 90 of file ui_utils.py.

def utils.ui_utils.UIUtils.setup_gtk (   app_icon_filename)
static

Sets some common GTK properties that all of the apps use.

This only needs to be called once at appliation startup.

Parameters
app_icon_filename(string) path to an image file. This icons will be used as the default application icon (appears in the top left-hand corner of all windows)

Definition at line 79 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_confirm_dialog (   msg)
static

Displays a popup confirmation dialog with yes/no buttons.

This method will block until one of the buttons is clicked, at which point it will return a boolean value (indicating which button was clicked) and the dialog will auto-destruct.

Parameters
msg(string) the confirmation message to display (should be a yes/no question so the buttons make sense)
Returns
(boolean) True if "yes" was clicked, False otherwise.

Definition at line 125 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_empty_form_dialog (   alt_msg = None)
static

Displays a popup dialog (with an ok button) that tells the user to make sure all options in a form have been filled out.

This method blocks until the user clicks ok.

Parameters
alt_msg(string=None) alternate text to display in place of the default. The default is 'Please make sure that all options have been filled out.'

Definition at line 146 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_entry_dialog (   msg,
  entry_title,
  default_text = '',
  validate_regex = r'^.+$',
  invalid_msg = 'Please enter a value.' 
)
static

Shows a dialog box with a message, a single text entry, and a set of buttons (e.g.

ok/cancel). This allows the user to enter a string value. This method blocks until the user clicks ok. Here is what the dialog looks like, (the red message at the bottom is shown only if the user clicks ok after entering invalid text/no text).

Parameters
msg(string) message to display above the entry. This is generally some instructions about what to type in the entry.
entry_title(string) This text will be displayed directly to the left of the entry. Usually it is some text with a colon that acts as a title for the entry.
default_text(string='') The entry will be prepopulated with this text when the dialog box opens.
validate_regex(string=r'^.+$') a regular expression that will be used to validate the text in the entry when the user clicks ok. If the regex does not match the text, invalid_msg will be displayed and the dialog will remain open. The default value for this parameter is a regex that matches any text except the empty string (this just makes sure the user enters something).
invalid_msg(string='Please enter a value') this text will be shown below the dialog, in red, if the user clicks ok and the text they entered does not match validate_regex. In this case, the dialog will not close.
Returns
(string) The string that the user typed into the entry, or None if they clicked the cancel button or closed the dialog.

Definition at line 507 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_file_dialog (   title,
  filters,
  action,
  confirm_button_stock,
  open_now_opt = False,
  save_last_location = False,
  cur_location = None 
)
static

This method shows a a file dialog box (for "open" or "save") with controls that allow the user to select a file.

This method blocks until the user clicks ok.

Parameters
title(string) text to display in the dialog box titlebar
filters(list=[]) list of gtk.FileFilter objects. This specifies the types of files (via their extensions) that will be visible in the dialog.
action(int) This is a gtk filechooser action constant (one of gtk.FILE_CHOOSER_ACTION_OPEN, gtk.FILE_CHOOSER_ACTION_SAVE, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER or gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER), indicating the type of dialog to display.
confirm_button_stock(int) a gtk stock icon constant (e.g. gtk.STOCK_OK, gtk.STOCK_OPEN), indicating what type of text and icon to display on the "ok" button. For a complete list of stock constants, see the PyGTK docs here.
open_now_opt(boolean=False) if True, a checkbox will be displayed in the dialog with the title "Open Immediately". Its value (True=checked, False=unchecked) is returned along with the path when this method returns. Typically this is used in save dialogs to allow the user to indicate that they would like to open a file immediately after it is saved to disk.
save_last_location(boolean=False) if True, the directory containing the selected file will be saved (to UIUtils.last_filechoose_location), and the next "open" or "save" dialog will use it as the current directory
cur_location(string=None) a path to a folder to set the dialog to show when it opens. If None, this will display whatever directory GTK feels like.
Returns
(string, list) a 2-tuple. The first element is the path the user has selected using the dialog controls (for example, the path to the file to open). The second element is a boolean value indicating the status of the "open now" checkbox (if present). A value of True indicates that the checkbox was checked when the user clicked ok - False indicates it was unchecked (or that the checkbox is not being shown).

Definition at line 608 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_file_dialog_with_checks (   title,
  filters,
  action,
  confirm_button_stock,
  checkbuttons,
  save_last_location = False 
)
static

This method shows a a file dialog box (for "open" or "save") that (in addition to its regular buttons and controls) contains one or more checkboxes that the user can toggle.

The checkboxes' states are returned, along with the user-specified path string (corresponding to the filesystem location they chose). This method blocks until the user clicks ok.

Parameters
title(string) text to display in the dialog box titlebar
filters(list=[]) list of gtk.FileFilter objects. This specifies the types of files (via their extensions) that will be visible in the dialog.
action(int) This is a gtk filechooser action constant (one of gtk.FILE_CHOOSER_ACTION_OPEN, gtk.FILE_CHOOSER_ACTION_SAVE, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER or gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER), indicating the type of dialog to display.
confirm_button_stock(int) a gtk stock icon constant (e.g. gtk.STOCK_OK, gtk.STOCK_OPEN), indicating what type of text and icon to display on the "ok" button. For a complete list of stock constants, see the PyGTK docs here.
checkbuttons(list) a list of gtk.CheckButton objects (i.e. checkboxes) to display in the dialog. See return value description for how to obtain their state when the ok button is pressed.
save_last_location(boolean=False) if True, the directory containing the selected file will be saved (to UIUtils.last_filechoose_location), and the next "open" or "save" dialog will use it as the current directory
Returns
(string, list) a 2-tuple. The first element is the path the user has selected using the dialog controls (for example, the path to the file to open). The second element is a list of boolean values. Each value corresponds to one checkbutton. A value of True indicates that the checkbox was checked when the user clicked ok - False indicates it was unchecked.

Definition at line 556 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_message_dialog (   message,
  dialog_type = gtk.MessageType.INFO 
)
static

Displays a popup dialog (with an ok button) that presents a textual message.

This method blocks until the user clicks ok.

Parameters
message(string) the text to display in the dialog box.
dialog_type(int) one of the gtk message type constants (see gtk docs for the MessageDialog class), indicating the type of icon to display in the dialog. This icon indicates whether the dialog is an info/question/warning/error message. Possible values are gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING, gtk.MESSAGE_QUESTION, or gtk.MESSAGE_ERROR.

Definition at line 156 of file ui_utils.py.

def utils.ui_utils.UIUtils.show_no_sel_dialog (   alt_msg = None)
static

Displays a popup dialog (with an ok button) that tells the user to select a row (presumably in some type of UI list).

This method blocks until the user clicks ok.

Parameters
alt_msg(string=None) alternate text to display in place of the default. The default is 'Please select a row.'

Definition at line 138 of file ui_utils.py.

def utils.ui_utils.UIUtils.utc_to_local_str (   utc_timestamp)
static

Definition at line 220 of file ui_utils.py.

Member Data Documentation

utils.ui_utils.UIUtils.ALL_FILE_FILTER = None
static

Definition at line 25 of file ui_utils.py.

tuple utils.ui_utils.UIUtils.BUTTON_ICON_SIZES
static
Initial value:
1 = Enum.from_dict({
2  'PX8': '8x8',
3  'PX16': '16x16',
4  'PX22': '22x22',
5  'PX24': '24x24',
6  'PX32': '32x32',
7  'PX48': '48x48',
8  'PX64': '64x64',
9  'PX128': '128x128',
10  })

Definition at line 65 of file ui_utils.py.

tuple utils.ui_utils.UIUtils.BUTTON_ICONS
static
Initial value:
1 = Enum.from_dict({
2  'CREATE': 'icons/open_icon_library-standard/icons/png/%s/actions/document-new-8.png',
3  'OPEN': 'icons/open_icon_library-standard/icons/png/%s/actions/document-open-8.png',
4  'ADD': 'icons/open_icon_library-standard/icons/png/%s/actions/list-add-5.png',
5  'EDIT': 'icons/open_icon_library-standard/icons/png/%s/actions/edit.png',
6  'REMOVE': 'icons/open_icon_library-standard/icons/png/%s/actions/list-remove-5.png',
7  'DELETE': 'icons/open_icon_library-standard/icons/png/%s/actions/edit-delete-3.png',
8  'RUN': 'icons/open_icon_library-standard/icons/png/%s/actions/system-run-2.png',
9  'CLOSE': 'icons/open_icon_library-standard/icons/png/%s/actions/application-exit-4.png',
10  'EXIT': 'icons/open_icon_library-standard/icons/png/%s/actions/application-exit.png',
11  'EXPAND': 'icons/open_icon_library-standard/icons/png/%s/actions/edit-add-3.png',
12  'COLLAPSE': 'icons/open_icon_library-standard/icons/png/%s/actions/edit-remove-2.png',
13  'REFRESH': 'icons/open_icon_library-standard/icons/png/%s/actions/view-refresh-6.png',
14  'PLAY': 'icons/open_icon_library-standard/icons/png/%s/apps/exaile-2.png',
15  'FLAG': 'icons/open_icon_library-standard/icons/png/%s/actions/flag.png',
16  'EXPORT': 'icons/open_icon_library-standard/icons/png/%s/actions/document-export.png',
17  'SPLIT': 'icons/open_icon_library-standard/icons/png/%s/actions/edit-copy-9.png',
18  'MERGE': 'icons/open_icon_library-standard/icons/png/%s/actions/edit-text-frame-update.png',
19  'CLEAR': 'icons/open_icon_library-standard/icons/png/%s/actions/edit-clear-2.png',
20  'FILTER': 'icons/open_icon_library-standard/icons/png/%s/actions/filter.png',
21  'PRAAT': 'icons/open_icon_library-standard/icons/png/%s/apps/praat.png',
22  'SAVE': 'icons/open_icon_library-standard/icons/png/%s/actions/document-save-as-6.png',
23  'UPDATE': 'icons/open_icon_library-standard/icons/png/%s/apps/system-software-update-4.png',
24  'VOLUME_OFF': 'icons/open_icon_library-standard/icons/png/%s/status/volume-0.png',
25  'VOLUME_ON': 'icons/open_icon_library-standard/icons/png/%s/status/audio-volume-high-5.png',
26  })

Definition at line 36 of file ui_utils.py.

utils.ui_utils.UIUtils.CSV_FILE_FILTER = None
static

Definition at line 26 of file ui_utils.py.

string utils.ui_utils.UIUtils.DB_DT_OUTPUT_FMT = '%Y-%m-%d %H:%M:%S'
static

Definition at line 30 of file ui_utils.py.

string utils.ui_utils.UIUtils.DT_DISPLAY_FMT = '%b %d, %Y %I:%M %p'
static

Definition at line 32 of file ui_utils.py.

utils.ui_utils.UIUtils.last_filechooser_location = None
static

Definition at line 20 of file ui_utils.py.

utils.ui_utils.UIUtils.TRS_CSV_FILE_FILTER = None
static

Definition at line 27 of file ui_utils.py.

utils.ui_utils.UIUtils.TRS_FILE_FILTER = None
static

Definition at line 24 of file ui_utils.py.

utils.ui_utils.UIUtils.WAV_FILE_FILTER = None
static

Definition at line 23 of file ui_utils.py.


The documentation for this class was generated from the following file: