uicurses
index
multiui/uicurses.py

# uicurses - the curses interface for multiui
# Copyright (C) 2003, 2004 Seneca Cunningham
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA

 
Modules
       
cStringIO
curses
os

 
Classes
       
Errorwin
Inputline
Messagewin
Multiactionwin
Actionwin
Multipleselectwin
Scrollwin
Selectwin
Statuswin

 
class Actionwin(Multiactionwin)
    A window that performs one constant action on whichever item is 
selected.
 
When an item is chosen by the user, the action is called with the
first argument passed being the selected item.  The selected item
is passed in the form of a list, where the first element is the
line it is on, and the second element is the text from the original
items list.
 
items   - a list containing the menu items
title   - the window title
action  - the funtion to call
*args   - additional arguements for the funtion
 
  Methods defined here:
__init__(self, items, title, action, *args)
additem(self, item)
Adds an item to the Actionwin
setaction(self, action, *args)
Sets the action for the Actionwin

Data and other attributes defined here:
action = None
args = None

Methods inherited from Multiactionwin:
getaction(self, index)
Returns the action associated with a given index
uiloop(self, height, y, x, posy, posx, scrollpad, win)

Data and other attributes inherited from Multiactionwin:
actionlist = []
itemlist = []
title = ''

 
class Errorwin
    Makes an error window.
 
The user presses any key to clear the window.  The caption can only
be a single line message.
 
title   - the window's title
caption - the window's caption
 
  Methods defined here:
__init__(self, title='Error', caption='Please press the any key to continue')

 
class Inputline
    Makes a window that grabs a line of user input.
 
title   - the window title
caption - the window caption
line    - the minimum length of the input line
maxline - the maximum length of the user input (default 1024 chars)
 
  Methods defined here:
__init__(self, title='', caption='', line=None, maxline=1024)
getinput(self)
Returns the user's input as a string
userinput(self, x, inpad, win, ypos, xpos, maxline)
user input loop

Data and other attributes defined here:
text = ''

 
class Messagewin
    Makes a window to present a message to the user.
 
The user presses any key to clear the window.  The caption can only
be a single line message.
 
title   - the window's title
caption - the window's caption
 
  Methods defined here:
__init__(self, title='Message', caption='Please press the any key to continue')

 
class Multiactionwin
    Makes a menu window with each item associated with a (possibly)
unique action.
 
The items are passed in the form of a list of tuples of at least
two items.  The first item is the text of the item, the second
is the action, any following elements are passed to the action,
after the item.
 
If the action for a menu item is None, this function returns.
 
actions - the dictionary containing the items and actions
title   - title for the menu window
 
  Methods defined here:
__init__(self, actions, title=None)
additem(self, item)
Adds an item to the Multiactionwin
getaction(self, index)
Returns the action associated with a given index
setaction(self, index, action, *args)
Sets the action of a given index to the specified action
uiloop(self, height, y, x, posy, posx, scrollpad, win)

Data and other attributes defined here:
actionlist = []
itemlist = []
title = ''

 
class Multipleselectwin
    A window type that allows the user to select a number of items.
 
This funtion returns a list of the items to choose between, where
each item is represented by a list where the first element is the
line number, the second is 0 if the item is not selected and 1 if it
is selected, and the third is the text of the item passed to
multipleselect.
 
items - the items for the user to select
title - the window title
caption - the window's caption
selectmessage - the message to show on the line of a selected item
 
  Methods defined here:
__init__(self, items, title, caption, selectmessage='<selected>')
prepare the window
getselection(self)
Returns the selection

Data and other attributes defined here:
items = []

 
class Scrollwin
    Makes a window with static content that the user can scroll through.
 
The window is centred on the screen and is closed by the user
pressing 'b'.  The width of the content can be greater than the
width of the window.
 
content - the text for the user to scroll through
title   - the window's title
minx    - the minimum width for the window
maxx    - the maximum width for the window, but not the content
miny    - the minimum height of the window
maxy    - the maximum height of the window
 
  Methods defined here:
__init__(self, content, title=None, minx=60, maxx=148, miny=20, maxy=48)
make sure that the arguments make sense

 
class Selectwin
    A window that allows the user to select one item.
 
When getselection is called, the item chosen by the user is
returned in the form of a list, where the first element is the
line it is on, and the second element is the text from the original
items list.
 
items   - a list containing the menu items
title   - the window title
caption - the caption to show
 
  Methods defined here:
__init__(self, items, title, caption)
getselection(self)
Returns the selected item from the menu

Data and other attributes defined here:
item = None
items = None

 
class Statuswin
    Makes a status window.
 
The caption can only be a single line message.
 
title   - the window's title
caption - the window's caption
size    - the width of the window
 
  Methods defined here:
__init__(self, title=None, caption='', size=60)
hidewin(self)
Hides the statuswin.
newstatus(self, caption=None)
Changes the caption of the statuswin.
 
caption - the new caption

 
Functions
       
addtitle(win, title)
Adds the title to a window.
 
Centres the title text and places the text on the border if the
title is shorter than the window width.
 
win   - the window to add the title to
title - the title to add
centrewin(y, x)
Centres a window on the screen.
 
Returns a tuple containing 4 elements, suitable for inputting
into curses.newwin:  the first two elements are the dimentions
passed to this function, the second are the position.  Just remember
the '*' for tuple expansion if feeding the return directly into
curses.newwin.
 
y - height of the window
x - width of the window
errprep(win, warning='ERROR')
Prepares an error window.
 
Sets the colour scheme, adds the border, and sets the title of the
window.
 
win   - the window to prepare
title - the window's title
externapp(app)
Run an external application without messing up the display.
 
app - a string of what to run, including arguments
setup(tocall, *args)
Sets up the module.
 
Starts up curses and calls startcurses to finish the starting
 
tocall - the method to call after setting up
*args  - the arguments for that method
startcurses(stdscr, tocall, *args)
Sets up the module-specific values.
 
maxdims contains a tuple of the screen dimentions in the form (y, x)
Colour pair 1 is the normal window colour scheme, colour pair 2
contains the colour scheme for error windows, colour pair 3 is for
user input lines
 
stdstr - the window of the entire screen area
tocall - the method to call after setting up
*args  - the arguments for that method
winprep(win, title=None)
Prepares a regular window.
 
Sets the colour scheme, adds the border, and sets the title of the
window.
 
win   - the window to prepare
title - the window's title

 
Data
        maxdims = [0, 0]


Hosted by SourceForge.net Logo