Add library stubs and refactor menu creation

pull/5/head
David Bartley 15 years ago
parent aabb7616b1
commit 146745cff0
  1. 11
      ceo/urwid/groups.py
  2. 31
      ceo/urwid/library.py
  3. 41
      ceo/urwid/main.py
  4. 5
      ceo/urwid/widgets.py

@ -4,9 +4,6 @@ from ceo.urwid import search
from ceo.urwid.widgets import *
from ceo.urwid.window import *
def menu_items(items):
return [ urwid.AttrWrap( ButtonText( cb, data, txt ), 'menu', 'selected') for (txt, cb, data) in items ]
def change_group_member(data):
push_wizard("%s %s Member" % (data["action"], data["name"]), [
(ChangeMember, data),
@ -22,17 +19,15 @@ def group_members(data):
add_data['action'] = 'Add'
remove_data = data.copy()
remove_data['action'] = 'Remove'
menu = [
menu = make_menu([
("Add %s member" % data["name"].lower(),
change_group_member, add_data),
("Remove %s member" % data["name"].lower(),
change_group_member, remove_data),
("List %s members" % data["name"].lower(), list_group_members, data),
("Back", raise_back, None),
]
listbox = urwid.ListBox( menu_items( menu ) )
push_window(listbox, "Manage %s" % data["name"])
])
push_window(menu, "Manage %s" % data["name"])
class IntroPage(WizardPanel):
def init_widgets(self):

@ -0,0 +1,31 @@
import urwid
from ceo import members
from ceo.urwid import search
from ceo.urwid.widgets import *
from ceo.urwid.window import *
def library(data):
menu = make_menu([
("Checkout Book", checkout_book, None),
("Return Book", return_book, None),
("Search Books", search_books, None),
("Add Book", add_book, None),
("Remove Book", remove_book, None),
("Back", raise_back, None),
])
push_window(menu, "Library")
def checkout_book(data):
pass
def return_book(data):
pass
def search_books(data):
pass
def add_book(data):
pass
def remove_book(data):
pass

@ -1,7 +1,8 @@
import sys, random, urwid.curses_display
from ceo.urwid.widgets import *
from ceo.urwid.window import *
from ceo.urwid import newmember, renew, info, search, positions, groups, shell
from ceo.urwid import newmember, renew, info, search, positions, groups, \
shell, library
ui = urwid.curses_display.Screen()
@ -51,26 +52,6 @@ syscom_data = {
"groups" : [ "office", "staff", "adm", "src" ],
}
def main_menu():
menu = [
("New Member", new_member, None),
("New Club Rep", new_club_user, None),
("Renew Membership", renew_member, None),
("Renew Club Rep", renew_club_user, None),
("New Club", new_club, None),
("Display Member", display_member, None),
("Change Shell", change_shell, None),
("Search", search_members, None),
("Manage Club or Group Members", manage_group, None),
("Manage Positions", manage_positions, None),
("Manage Office Staff", groups.group_members, office_data),
("Manage Systems Committee", groups.group_members, syscom_data),
("Exit", raise_abort, None),
]
listbox = urwid.ListBox( menu_items( menu ) )
return listbox
def new_member(*args, **kwargs):
push_wizard("New Member", [
newmember.IntroPage,
@ -161,7 +142,23 @@ def change_shell(data):
], (50, 20))
def run():
push_window( main_menu(), program_name() )
menu = make_menu([
("New Member", new_member, None),
("New Club Rep", new_club_user, None),
("Renew Membership", renew_member, None),
("Renew Club Rep", renew_club_user, None),
("New Club", new_club, None),
("Display Member", display_member, None),
("Change Shell", change_shell, None),
("Search", search_members, None),
("Manage Club or Group Members", manage_group, None),
("Manage Positions", manage_positions, None),
("Manage Office Staff", groups.group_members, office_data),
("Manage Systems Committee", groups.group_members, syscom_data),
("Library", library.library, None),
("Exit", raise_abort, None),
])
push_window( menu, program_name() )
event_loop( ui )
def start():

@ -5,8 +5,9 @@ import ceo.ldapi as ldapi
csclub_uri = "ldap://ldap1.csclub.uwaterloo.ca/ ldap://ldap2.csclub.uwaterloo.ca"
csclub_base = "dc=csclub,dc=uwaterloo,dc=ca"
def menu_items(items):
return [ urwid.AttrWrap( ButtonText( cb, data, txt ), 'menu', 'selected') for (txt, cb, data) in items ]
def make_menu(items):
items = [ urwid.AttrWrap( ButtonText( cb, data, txt ), 'menu', 'selected') for (txt, cb, data) in items ]
return urwid.ListBox( items )
def push_wizard(name, pages, dimensions=(50, 10)):
state = {}

Loading…
Cancel
Save