misc — scikit-sound 0.2.11 documentation

# misc

General utility routines, especially simple GUI dialogs for different applications

## Functions

- `misc.askquestion()` … GUI-dialog for y/n selection

- `misc.get_file()` … GUI-dialog for file-selection

- `misc.get_dir()` … GUI-dialog for directory-selection

- `misc.progressbar()` … console-based progressbar, to indicate the level of completeness

- `misc.save_file()` … GUI-dialog for saving file

## Details

Miscellaneous user interface utilities for

> - selecting files or directories. If nothing or a non-existing file/direcoty is selected, the return is “0”. Otherwise the file/directory is returned.

> - waitbar

misc.askquestion(DialogTitle='Interactive Selection', Question='Are we done yet?')

  Ask the user a yes/no question

  Parameters:

    - DialogTitle (string) – Window title

    - Question (string) – Question to the user

  Returns:

    yes_no – Selected answer.

  Return type:

    boolean

  Examples

      >>> my_wish = sksound.misc.askquestion('Work or Play', 'Do you want to go home?')

misc.get_dir(DialogTitle='Select Directory', DefaultName='.')

  Select a directory

  Parameters:

    - DialogTitle (string) – Window title

    - DefaultName (string) – Can be a directory AND filename

  Returns:

    directory – Selected directory.

  Return type:

    string

  Examples

      >>> myDir = skinematics.ui.getdir('c:\temp', 'Pick your directory')

misc.get_file(FilterSpec='*', DialogTitle='Select File: ', DefaultName='')

  Selecting an existing file.

  Parameters:

    - FilterSpec (query-string) – File filters

    - DialogTitle (string) – Window title

    - DefaultName (string) – Can be a directory AND filename

  Returns:

    - filename (string) – selected existing file

    - pathname (string) – selected path

  Examples

      >>> (myFile, myPath) = skinematics.ui.getfile('*.py', 'Testing file-selection', 'c:\temp\test.py')

misc.progressbar(it, prefix='', size=60)

  Shows a progress-bar on the commandline. This has the advantage that you don’t need to bother with windows managers. Nifty coding!

  Parameters:

    - it (integer array) – index variable

    - prefix (string) – Text preceding the progress-bar

    - size (integer) – Length of progress-bar

  Examples

      >>> import time
      >>> for ii in progressbar(range(50), 'Computing ', 25):
      >>>    #print(ii)
      >>>    time.sleep(0.05)

misc.save_file(FilterSpec='*', DialogTitle='Save File: ', DefaultName='')

  Selecting an existing or new file:

  Parameters:

    - FilterSpec (string) – File filters.

    - DialogTitle (string) – Window title.

    - DefaultName (string) – Can be a directory AND filename.

  Returns:

    - filename (string) – Selected file.

    - pathname (string) – Selecte path.

  Examples

      >>> (myFile, myPath) = skinematics.ui.savefile('*.py', 'Testing file-selection', 'c:\temp\test.py')