Beispiel #1
0
    def __init__(self, master):
        """keep a record of the calling parent object"""
        self.master = master

        """container for ALL the addressbook"""
        self.books = addressbook.addressbook()

        """setup frames for the menu bar and the area below it"""
        self.topFrame = tk.Frame(self.master)
        self.topFrame.pack(side = tk.TOP)
        self.bottomFrame = tk.Frame(self.master)
        self.bottomFrame.pack(fill=tk.BOTH)

        """add the menubar to the upper frame"""
        self.menuBar = tk.Menu(self.topFrame)
        self.fileMenu = tk.Menu(self.menuBar, tearoff=0)

        """set the default states for the file menu"""
        self.fileMenu.add_command(label="New", command=self.cmdNew)
        self.fileMenu.add_command(label="Open", command=self.cmdOpen)
        self.fileMenu.add_command(label="Close", command=self.cmdClose, state=tk.DISABLED)
        self.fileMenu.add_command(label="Save", command=self.cmdSave, state=tk.DISABLED)
        self.fileMenu.add_command(label="Save As", command=self.cmdSaveAs, state=tk.DISABLED)
        self.fileMenu.add_command(label="Import", command=self.cmdImport, state=tk.DISABLED)
        self.fileMenu.add_command(label="Export", command=self.cmdExport, state=tk.DISABLED)
        self.fileMenu.add_command(label="Print Mailing", command=self.cmdPrint, state=tk.DISABLED)
        self.fileMenu.add_command(label="Merge", command=self.cmdMerge, state=tk.DISABLED)
        self.fileMenu.add_command(label="Quit", command=self.cmdQuit)
        self.menuBar.add_cascade(label="File", menu=self.fileMenu)

        """add the menu bar"""
        self.master.config(menu=self.menuBar)
Beispiel #2
0
    def cmdMerge(self):
        print "merge"
        self.openFileName = askopenfilename()

        if self.openFileName != "":
            """setup the backend addressbook"""
            self.newBook = addressbook.addressbook()
            self.newBook.addressBookImport(self.openFileName,self.app)
            self.mainBook.mergeAddressBook(self.newBook)
            self.app.cmdUpdateListbox(self.mainBook.contacts)
Beispiel #3
0
    def cmdNew(self):
        """setup out backend addressbook"""
        self.mainBook = addressbook.addressbook()
        """setup the GUI and pass in the addressbook backend"""
        self.app = addressbookgui.AddressBookFrame(self.bottomFrame,self.mainBook)

        """enable menu options"""
        self.fileMenu.entryconfig(2,state=tk.NORMAL) #close
        self.fileMenu.entryconfig(4,state=tk.NORMAL) #Save As
        self.fileMenu.entryconfig(5,state=tk.NORMAL) #Import
        self.fileMenu.entryconfig(6,state=tk.NORMAL) #export
        self.fileMenu.entryconfig(7,state=tk.NORMAL) #print
        self.fileMenu.entryconfig(8,state=tk.NORMAL) #merge

        """disable new & open"""
        self.fileMenu.entryconfig(0,state=tk.DISABLED) #new
        self.fileMenu.entryconfig(1,state=tk.DISABLED) #open
Beispiel #4
0
 def __init__(self):
     self.MENU_INPUT = 1
     self.MENU_REMOVE = 2
     self.MENU_MODIFY = 3
     self.MENU_SEARCH = 4
     self.MENU_ALL_PRINT = 5
     self.MENU_SAVE = 6
     self.MENU_LOAD = 7
     self.MENU_DB_LOAD = 8
     self.MENU_DB_SAVE = 9
     self.MENU_FINISH = 0
     self.ERROR_NO_MENU = 1
     self.ERROR_FULL = 2
     self.ERROR_EMPTY = 3
     self.ERROR_NOT_SEARCH = 4
     self.ERROR_LOAD_FAIL = 5
     self.book = addressbook.addressbook()
Beispiel #5
0
    def setUp(self):
        self.book = addressbook()

        self.testInfo1 = personInfo()
        self.testInfo1.name = "test1"
        self.testInfo1.phone = "0001110000"
        self.testInfo1.address = "abc"
        self.testInfo2 = personInfo()
        self.testInfo2.name = "test2"
        self.testInfo2.phone = "0002220000"
        self.testInfo2.address = "def"
        self.testInfo3 = personInfo()
        self.testInfo3.name = "test3"
        self.testInfo3.phone = "0003330000"
        self.testInfo3.address = "ghi"

        self.book.input(self.testInfo1)
        self.book.input(self.testInfo2)
        self.book.input(self.testInfo3)
Beispiel #6
0
    def cmdOpen(self):
        """display dialog for load file"""
        self.openFileName = askopenfilename()

        if self.openFileName != "":
            """setup the backend addressbook"""
            self.mainBook = addressbook.addressbook()
            """setup the GUI addressbook frame"""
            self.app = addressbookgui.AddressBookFrame(self.bottomFrame,self.mainBook)
            """open the selected file into our addressbook"""
            self.mainBook.addressBookImport(self.openFileName,self.app)
            """disable new & open"""
            self.fileMenu.entryconfig(0,state=tk.DISABLED) #new
            self.fileMenu.entryconfig(1,state=tk.DISABLED) #open

            """enable menu options"""
            self.fileMenu.entryconfig(2,state=tk.NORMAL) #close
            self.fileMenu.entryconfig(4,state=tk.NORMAL) #Save As
            self.fileMenu.entryconfig(5,state=tk.NORMAL) #Import
            self.fileMenu.entryconfig(6,state=tk.NORMAL) #export
            self.fileMenu.entryconfig(7,state=tk.NORMAL) #print
            self.fileMenu.entryconfig(8,state=tk.NORMAL) #merge
Beispiel #7
0
def main():
    testAddressBook = addressbook()

    testContact1 = contact("John Doe")
    testLast1 = "San Diego CA 94501"
    testDelivery1 = "1401 SW Main St."
    testSecond1 = ""
    testAddr1 = address(testLast1, testDelivery1, testSecond1)
    testEmail1 = "*****@*****.**"
    testEmail2 = "*****@*****.**"
    testPhoneNumber1 = "542-345-6745"
    testContact1.addAddress(testAddr1)
    testContact1.addEmail(testEmail1)
    testContact1.addEmail(testEmail2)
    testContact1.addPhoneNumber(testPhoneNumber1)
    print(testContact1)
    print(testContact1.mailingFormat())
    #print(testContact1.city)
    #print(testContact1.state)
    #print(testContact1.zip)

    '''testContact2 = contact("Mary Sue")
Beispiel #8
0
import contact
import addressbook
import re
from sys import exit
import random

__author__ = 'Muhammad Arslan <*****@*****.**>'

app = addressbook.addressbook(
    str(input("Enter name of book  (Will be created if doesn't exist) \n> ")))
main_menu = '\n1. Show all contacts.\n2. Add contact.\n3. Search.\n4. Delete a contact.\n5.Update contact.\n6. Exit\n\n>'


def exitProg():
    exitMessages = ['You have my permission to die.']
    print(random.choice(exitMessages))
    exit(0)


def getOption(prompt):
    inp = input(prompt)
    try:
        inp = int(inp)
    except ValueError:
        print('You should have selected a proper option.')
        return 13
    return inp


def showContacts():
    print('show all')