Пример #1
0
 def setupSourceFiles(self):
     for fileName in [
             'books.source', 'books.inc', 'books.bp', 'books.pa',
             'books.scripts', 'books.tables', 'test.bp', 'test.source',
             'images', 'books.pysrc', 'TESTS', 'TEST_BACKOUT', 'TEST_BATCH',
             'TEST_DBG', 'TEST_INC', 'TEST_LOCAL', 'TEST_MOCKS', 'TEST_OUT',
             'TEST_PROFILE', 'TEST_RESULTS', 'TEST_RUN', 'TEST_SCRIPTS',
             'TEST_STATE'
     ]:
         rec = u2py.DynArray()
         rec.replace(1, 'F')
         rec.replace(2, '../../bookstore/server/' + fileName)
         rec.replace(3, 'D_VOC')
         if fileName[-3:] == '.bp':
             rec.replace(4, 'M')
             rec.replace(7, 1, fileName)
             rec.replace(8, 1, fileName)
             rec.replace(7, 2, 'unidata')
             rec.replace(8, 2, 'unidata')
         self.VOC_FILE.write(fileName, rec)
         u2py.run('CREATE.FILE DICT ' + fileName + ' 1,1', capture=False)
         if fileName[-3:] == '.bp':
             self.compilePrograms(fileName)
         elif fileName[-3:] == '.pa':
             self.createRemotes(fileName)
Пример #2
0
def u2WritePyDict(theFile, itemId, theDictItem):
    if type(theFile).__name__ == 'File':
        myFile = theFile
    else:
        myFile = u2py.File(theFile)

    if type(theDictItem).__name__ == 'dict':
        fieldNames, fieldValues = zip(*theDictItem.items())
        fieldNames = u2py.DynArray(list(fieldNames))
        fieldValues = u2py.DynArray(list(fieldValues))
    else:
        raise ValueError("Expecting Python dict item for theDictItem")
        return null

    myFile.writenamedfields(itemId, fieldNames, fieldValues)
    return
Пример #3
0
def to_DynArray(x):
    if type(x) == u2py.DynArray:
        return x
    try:
        return u2py.DynArray(x)
    except ValueError:
        print("Exception occured while converting an object to a DynArray")
        raise
Пример #4
0
 def createRemotes(self, fileName):
     tempFL = u2py.File(fileName)
     slist = u2py.List(0, tempFL)
     for id in slist:
         rec = u2py.DynArray()
         rec.replace(1, 'R')
         rec.replace(2, fileName)
         rec.replace(3, str(id))
         self.VOC_FILE.write(str(id), rec)
Пример #5
0
def DELETE(inValue, field, value=None, subvalue=None):
    outValue = u2py.DynArray(inValue)
    if value == None:
        outValue.delete(field)
    else:
        if subvalue == None:
            outValue.delete(field, value)
        else:
            outValue.delete(field, value, subvalue)

    return outValue
Пример #6
0
def INSERT(inValue, field, arg1, arg2=None, arg3=None):
    outValue = u2py.DynArray(inValue)
    if arg2 == None:
        outValue.insert(int(field), arg1)
    else:
        if arg3 == None:
            outValue.insert(int(field), int(arg1), arg2)
        else:
            outValue.insert(int(field), int(arg1), int(arg2), arg3)

    return outValue
Пример #7
0
def REPLACE(inValue, field, arg1, arg2=None, arg3=None):
    outValue = u2py.DynArray(inValue)
    if arg2 == None:
        outValue.replace(int(field), arg1)
    else:
        if arg3 == None:
            outValue.replace(int(field), int(arg1), arg2)
        else:
            outValue.replace(int(field), int(arg1), int(arg2), arg3)

    return outValue
Пример #8
0
def writemember(formdata, uvfields, formfields):
    # get the UniVerse imports
    import os
    os.chdir("C:\\U2\\XDEMO\\pythonbetarocket")
    import u2py

    # open the file, read the latest version and write the details away
    file = u2py.File("MEMBERS")
    member_id = formdata.get('member_id')
    field_names = u2py.DynArray()
    for pos, dictname in uvfields.items():
        field_names.replace(pos, dictname)
    member_data = u2py.DynArray()
    if member_id == "NEW":
        # need to generate a new key
        member_id = genuniquekey("MEMBERS", 4)
    for pos, dictname in formfields.items():
        member_data.replace(pos, formdata.get(dictname))
    file.writenamedfields(member_id, field_names, member_data)
    # set the return key
    formdata['member_id'] = member_id
Пример #9
0
def COUNT(invalue, delim):
    '''
    invalue - variable ( u2py.DynArray, string or number )
    delim - delimiter

    Returns the count of the delimiter character in the invalue variable

    Note there is no STATUS function at this time.

   '''
    outValue = u2py.DynArray(invalue).count(delim)
    return outValue
Пример #10
0
def vendorDetailU2(vendorDetails,itemsId,recordID):
	vendorArray=u2py.DynArray()
	item=bytes("","utf-8")
	vendorFile=u2py.File('PO.VENDOR.MST')
	vendorArray.insert(1,0,0,vendorDetails['Company'])
	vendorArray.insert(2,0,0,vendorDetails['Contact'])
	vendorArray.insert(3,0,0,bytes(vendorDetails['Street'],"utf-8")+u2py.VM+bytes(vendorDetails['City'],"utf-8")+u2py.VM+bytes(vendorDetails['State'],"utf-8")+u2py.VM+bytes(vendorDetails['Zip'],"utf-8"))
	vendorArray.insert(4,0,0,vendorDetails['Phone'])
	for items in itemsId:
		item=item+bytes(items['items'],"utf-8")+u2py.VM
	vendorArray.insert(5,0,0,item[:-1])
	vendorFile.write(recordID,vendorArray)
Пример #11
0
def DCOUNT(invalue, delim):
    '''
    invalue - variable ( u2py.DynArray, string or number )
    delim - delimiter

    Returns the number of fields seperated by the delimiter character
    in the invalu2 variable

    Note there is no STATUS function at this time.

    '''
    outValue = u2py.DynArray(invalue).dcount(delim)
    return outValue
Пример #12
0
def EXTRACT(invalue, *myargs):
    if len(myargs) == 0 or len(myargs) > 3:
        outValue = invalue
        print("r1")
        return outValue
    else:
        if type(invalue) == u2py.DynArray:
            invalue = invalue.to_list()
        else:
            invalue = u2py.DynArray(invalue).to_list()

        this_att = myargs[0] - 1
        if (int(this_att) or this_att == 0) and len(invalue) > this_att:
            invalue = invalue[this_att]
        else:
            invalue = ""

        if len(myargs) > 1:
            print(str(invalue))
            invalue = u2py.DynArray(invalue).to_list()
            this_val = myargs[1] - 1
            if (int(this_val) or this_val
                    == 0) and len(invalue) > this_val and this_val > -1:
                invalue = invalue[this_val]
            else:
                invalue = ""

        if len(myargs) == 3:
            invalue = u2py.DynArray(invalue).to_list()
            this_sval = myargs[2] - 1
            if (int(this_sval) or this_sval
                    == 0) and len(invalue) > this_sval and this_sval > -1:
                invalue = invalue[this_sval]
            else:
                invalue = ""

        outValue = invalue
        outValue = set_type(outValue)
    return outValue
Пример #13
0
def readFromU2():
    data = []
    filename = request.args.get('filename')
    record = request.args.get('recordname')
    try:
        f = u2py.File(filename)
    except u2py.U2Error as e:
        return {'status': 404, 'msg': "File Not Found"}
    theArray = u2py.DynArray()
    try:
        data = f.read(record)
    except u2py.U2Error as e:
        return {'status': 404, 'msg': "Record Not Found"}
    data = tuple(data)
    print(theArray)
    return {"data": data}, 201
Пример #14
0
def readmember(formdata, uvfields, formfields):
    # get the UniVerse imports
    import os
    os.chdir("C:\\U2\\XDEMO\\pythonbetarocket")
    import u2py

    member_id = formdata.get('member_id')
    # read the file and get the details
    file = u2py.File("MEMBERS")
    field_names = u2py.DynArray()
    for pos, dictname in uvfields.items():
        field_names.replace(pos, dictname)
    member_data = file.readnamedfields(member_id, field_names)
    formdata['member_id'] = member_id
    for pos, dictname in formfields.items():
        formdata[dictname] = member_data.extract(pos)
    return formdata
Пример #15
0
 def setupWebserver(self):
     cmd = self.makePath(self.python_path, self.pythonexe)
     cmd = cmd + ' ' + self.makePath(self.home,
                                     'server\\books.pysrc\\webserver.py')
     cmd = cmd + ' --rootdir ' + self.home + '\\web'
     cmd = cmd.replace('\\', self.delim)
     with open('start_webserver.bat', 'w') as f:
         f.write(cmd)
     f.close()
     VOC = u2py.File("VOC")
     rec = u2py.DynArray()
     rec.replace(1, "PA")
     rec.replace(2, "DISPLAY Start personal web server")
     rec.replace(3, "DISPLAY Connect to http://localhost:8080")
     rec.replace(4, "DISPLAY To quit go to http://localhost:8080/stop")
     rec.replace(5, "DOS /c start_webserver.bat")
     VOC.write('start_webserver', rec)
Пример #16
0
def saveInvoice(orderNo,invoiceDetails,invoiceNo,invoiceDate,invoiceAmount,status):
	invoiceData=u2py.DynArray()
	invoiceFile= u2py.File("PO.INVOICE.MST")
	itemNo=description=quantityOrdered=quantityPending=quantityReceived=bytes("","utf-8")
	invoiceData.insert(1,0,0,invoiceDate)
	invoiceData.insert(6,0,0,orderNo)
	invoiceData.insert(7,0,0,status)
	for i in range(len(invoiceDetails)):
		itemNo=itemNo+bytes(invoiceDetails[i]['itemNo'],"utf-8")+u2py.VM
		quantityOrdered=quantityOrdered+bytes(invoiceDetails[i]['quantityOrdered'],"utf-8")+u2py.VM
		quantityPending=quantityPending+bytes(str(invoiceDetails[i]['quantityPending']),"utf-8")+u2py.VM
		quantityReceived=quantityReceived+bytes(invoiceDetails[i]['quantityReceived'],"utf-8")+u2py.VM
	invoiceData.insert(2,0,0,itemNo[:-1])
	invoiceData.insert(3,0,0,quantityOrdered[:-1])
	invoiceData.insert(4,0,0,quantityPending[:-1])
	invoiceData.insert(5,0,0,quantityReceived[:-1])
	invoiceFile.write(invoiceNo,	invoiceData)
Пример #17
0
    def initAccount(self):
        print('Initializing account')
        self.VOC_FILE = u2py.File('VOC')
        rec = u2py.DynArray()
        rec.replace(1, 'PA')
        rec.replace(2, 'PTERM CASE NOINVERT')
        self.VOC_FILE.write('LOGIN', rec)

        u2py.run('PTERM CASE NOINVERT', capture=False)
        u2py.run('LONGNAMES ON', capture=False)
        u2py.run('TERM ,9999', capture=False)

        self.setupUtilityPrograms()
        self.setupSourceFiles()
        self.setupDataFiles()
        self.setupPythonPath()
        self.setupPip()
        self.setupPackages()
        self.setupWebserver()
Пример #18
0
def set_type(invalue):
    if type(invalue) == type(list()):
        return invalue

    if type(invalue) == u2py.DynArray:
        invalue = invalue.to_list()
        if len(invalue) > 1:
            outValue = u2py.DynArray(invalue)
            return outValue
        else:
            invalue = invalue[0]
    try:
        outValue = int(invalue)
    except ValueError:
        try:
            outValue = float(invalue)
        except ValueError:
            outValue = invalue
    return outValue
Пример #19
0
def OCONV(invalue, convCode):
    '''
    invalue - variable ( u2py.DynArray, string or number )
    convCode - Conversion code (see UniVerse BASIC Command Reference Guide)
    
    Returns the output conversion if successful or invlaue if conversion
    failed.
    Note there is no STATUS function at this time.
    
    This function will return a float, int or string 
    based on the results of the conversion. 
    '''

    #
    in_type = type(invalue)
    if in_type == u2py.DynArray:
        outValue = invalue.oconv(convCode)
    else:
        strValue = str(u2py.DynArray(invalue).oconv(convCode))
        outValue = set_type(strValue)
    return outValue
Пример #20
0
def ICONV(invalue, convCode):
    '''
    invalue - variable ( u2py.DynArray, string or number )
    convCode - Conversion code (see UniVerse BASIC Command Reference Guide)
    #
    Returns the input conversion if successful or invlaue if conversion
    failed.
    Note there is no STATUS function at this time.
    
    This function will return a float, int or string 
    based on the results of the conversion. 
    '''
    strValue = str(u2py.DynArray(invalue).iconv(convCode))
    try:
        outValue = int(strValue)
    except ValueError:
        try:
            outValue = float(strValue)
        except ValueError:
            outValue = strValue
    return outValue
Пример #21
0
    def loadAssets(self, fileName):
        tempFL = u2py.File(fileName)
        filePath = self.makePath(self.asset_path, fileName.lower()) + '.tab'
        if not os.path.exists(filePath):
            return False
        print('Loading assets for ' + fileName)
        ct = 0
        with open(filePath, 'rU') as f:
            for line in f:
                da = bytearray(line.rstrip('\n'), 'utf-8')
                for i in range(len(da)):
                    if da[i] == 9: da[i] = 254  # tab to field mark
                    elif da[i] == 124: da[i] = 253  # pipe to value mark

                rec = u2py.DynArray(da)
                recId = str(rec.extract(1))
                rec.delete(1)
                tempFL.write(recId, rec)
                ct += 1
        print(str(ct) + ' records loaded')
        return True
Пример #22
0
def u2ReadPyDict(theFile, itemId, fieldList):
    if type(theFile).__name__ == 'File':
        myFile = theFile
    else:
        myFile = u2py.File(theFile)

    if type(fieldList).__name__ == 'list':
        fieldDynArray = u2py.DynArray(fieldList)
    else:
        raise ValueError("Expecting Python list of field names")
        return null

    notFound = 0
    try:
        rec = myFile.readnamedfields(itemId, fieldDynArray)
        rec_list = rec.to_list()
        my_dict = dict(zip(fieldList, rec_list))
    except u2py.U2Error as e:
        print("item " + str(itemId) + " was not read from the file")
        print(str(e))

    return my_dict
Пример #23
0
def savedata():
    theArray = u2py.DynArray()
    excel_file = request.files['file']
    filePath = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                            excel_file.filename)
    recordname = request.form['recordname']
    filename = request.form['filename']
    try:
        f = u2py.File(filename)
    except u2py.U2Error as e:
        return {'status': 404, 'msg': 'File not found'}
    data = tuple(f.read(recordname))
    if (len(data) != 0):
        val = len(data) + 1
    else:
        val = len(data)
    for i, j in data.iterrows():
        theArray.insert(val, 0, 0, j['empname'])
        val += 1
    f.write(recordname, theArray)
    f.close()
    return {'status': 200, 'msg': 'Data saved successfully'}
Пример #24
0
    def run(self, args):
        orderId = ''

        if 'client' in args:
            U2_BOOKS = u2py.File("U2_BOOKS")
            U2_SHIPPING = u2py.File("U2_SHIPPING")
            order = u2py.DynArray()
            order.replace(1, args['client'])
            order.replace(2, 'NEW')  # order status
            if 'deliv_addr' in args:
                order.replace(3, args['deliv_addr'])
            order.replace(4, 'WEB')  # origin
            if 'ship_id' in args:
                shipId = args['ship_id']
            else:
                shipId = 'FREE'

            order.replace(5, shipId)  # shipping type
            shipRec = U2_SHIPPING.read(shipId)
            order.replace(6, str(shipRec.extract(2)))  # shipping cost
            ct = 0
            for id in args['books']:
                ct = ct + 1
                order.replace(10, ct, id)  # book key
                bookRec = U2_BOOKS.read(id)
                order.replace(11, ct, '1')  # qty
                order.replace(12, ct, str(bookRec.extract(8)))  # price
                order.replace(13, ct, str(bookRec.extract(12)))  # tax code
            sub = u2py.Subroutine("u2_setSalesOrder", 3)
            sub.args[0] = ''
            sub.args[1] = order
            sub.call()
            orderId = str(sub.args[0])
            errText = str(sub.args[2])
        else:
            errText = 'Missing cart details'

        return {'order': orderId, 'error': errText}
Пример #25
0
def writePurchaseOrder(purchaseOrderDetails,itemOrderDetails,recordID,submitStatus):
    itemID = quantity = cost = bytes("","utf-8")
    orderFile = u2py.File("PO.ORDER.MST")
    orderData = u2py.DynArray()
    orderData.insert(1,0,0,purchaseOrderDetails['orderDate'])
    orderData.insert(2,0,0,submitStatus)
    orderData.insert(7,0,0,purchaseOrderDetails['companyName'])
    orderData.insert(8,0,0,purchaseOrderDetails['contactName'])
    orderData.insert(9,0,0,bytes(purchaseOrderDetails['street'],"utf-8") + 
                u2py.VM + bytes(purchaseOrderDetails['city'],"utf-8") + 
                u2py.VM + bytes(purchaseOrderDetails['state'],"utf-8") + 
                u2py.VM+bytes(str(purchaseOrderDetails['zipCode']),"utf-8"))
    orderData.insert(10,0,0,str(purchaseOrderDetails['phoneNumber']))

    for item in itemOrderDetails:
        itemID = itemID + bytes(item['itemID'],"utf-8")+u2py.VM
        quantity = quantity + bytes(str(item['quantity']),"utf-8")+u2py.VM
        cost = cost + bytes(str(item['unitCost']),"utf-8")+u2py.VM
    
    orderData.insert(11,0,0,itemID[:-1])
    orderData.insert(12,0,0,quantity[:-1])
    orderData.insert(13,0,0,cost[:-1])
    orderData.insert(14,0,0,purchaseOrderDetails['vendorName'])
    orderFile.write(recordID,orderData)
Пример #26
0
def calc_routes(nodes, jobs, jobs_file, num_our_locs):
    priority_counters = []
    # Initialise priority counters
    for i in range(num_our_locs):
        nodes[i].priority = 1

    done = False
    while not done:
        min_date = 1000000
        next_job = None

        # Get and format today's date
        today = date.today()
        today_str = "%i/%i/%i" % (today.day, today.month, today.year)
        today_int = int(u2py.DynArray(today_str).iconv("d4/"))
        for job in jobs:
            if job.start_date >= today_int and job.priority == 0:
                next_job = job
                min_date = 0
            if job.date_filed < min_date and job.priority == 0:
                next_job = job
                min_date = job.date_filed

        # Trace back through the MST to the nearest home location
        path = []
        next_node = next_job.node
        cont_from = ""
        path.append(next_node)
        our_loc = path[0].parent
        while next_node.parent.our_loc != "y":
            path.append(next_node.parent)
            # If we reach another route then store the branch point
            if next_node.parent.job.priority != 0 and cont_from == "":
                cont_from = str(next_node.parent.description)
            next_node = next_node.parent
            our_loc = next_node.parent
        if cont_from == "":
            cont_from = str(our_loc.description)

        # Write the updated records
        visit_order = 1
        for node in reversed(path):
            job = node.job
            if job.priority == 0:
                job.priority = our_loc.priority_counter

                # Write info
                rec = jobs_file.read(job.id)
                line_to = u2py.DynArray()
                line_to.insert(1, 1, 0, node.parent.latitude)
                line_to.insert(1, 2, 0, node.parent.longitude)
                rec.replace(4, job.priority)
                rec.replace(5, today_int)
                rec.replace(6, our_loc.id)
                rec.replace(7, visit_order)
                rec.replace(8, cont_from)
                rec.replace(10, line_to)
                jobs_file.write(job.id, rec)

                visit_order += 1
                cont_from = ""

        our_loc.priority_counter += 1

        # Check if we are done
        done = True
        for job in jobs:
            if job.priority == 0:
                done = False
Пример #27
0
def set_dynArray(dimArray):
    """ Update the named common with the contents of the nested list.
        This sets the DYNARRAY into common by sending data to the SET_NC_MIKE routine."""
    to_pass = u2py.DynArray(dimArray)
    set_iT = u2py.call("SET_NC_MIKE", "DYNARRAY", to_pass)
Пример #28
0
def set_one_element(pos, the_data):
"""Call the U2 Subroutine that looks at the named common as one dim Array
and set one element, please note that MV counting of array elements
starts with 1"""
    to_pass = u2py.DynArray(the_data)
    get_it = u2py.call("SET_ONE_ELEMENT", pos, to_pass)
Пример #29
0
def reportcard():
    global R, F, F2
    #Global variables we need

    TC = u2py.DynArray("COURSE_NBR")
    TC.insert(2, "TEACHER")
    #TC is a Dynamic Array that refers to the COURSE_NBR and TEACHER virtual fields in STUDENT

    D = F.readnamedfields(entryText.get(), TC)
    #D accesses the COURSE_NBR and TEACHER for the current student

    G = u2py.DynArray("GPA1")
    result = F.readnamedfields(entryText.get(), G)
    #Similar to the previous lines, G refers to the virtual GPA1 field in STUDENTS

    rc = Toplevel()
    rc.title('Report Card for ' + str(R.extract(2)) + " " + str(R.extract(1)))
    rc.config(background="white")
    rc.geometry("500x800")
    rc.columnconfigure(0, minsize=80)
    rc.columnconfigure(1, minsize=80)
    rc.columnconfigure(2, minsize=60)
    rc.columnconfigure(3, minsize=60)
    rc.columnconfigure(4, minsize=80)
    #Creates popup menu

    rcl1 = Label(rc,
                 text="First Name",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=0, column=0, pady=10, sticky=W)
    rcl1 = Label(rc,
                 text="Last Name",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=0, column=1, pady=10, sticky=W)
    rcl1 = Label(rc, text="Major", fg="blue", bg="white",
                 font=("Verdana", 8)).grid(row=0, column=2, pady=10, sticky=W)
    rcl1 = Label(rc, text="Minor", fg="blue", bg="white",
                 font=("Verdana", 8)).grid(row=0, column=3, pady=10, sticky=W)
    rcl1 = Label(rc,
                 text="Advisor",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=0, column=4, pady=10, sticky=W)
    rcl1 = Label(rc, text="GPA", fg="blue", bg="white",
                 font=("Verdana", 8)).grid(row=0, column=5, pady=10, sticky=W)
    rcl1 = Label(rc, text=result, fg="blue", bg="white",
                 font=("Verdana", 8)).grid(row=2,
                                           column=5,
                                           pady=(0, 10),
                                           sticky=W)

    rcl1 = Label(rc,
                 text=str(R.extract(2)),
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=2,
                                           column=0,
                                           pady=(0, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text=str(R.extract(1)),
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=2,
                                           column=1,
                                           pady=(0, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text=str(R.extract(3)),
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=2,
                                           column=2,
                                           pady=(0, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text=str(R.extract(4)),
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=2,
                                           column=3,
                                           pady=(0, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text=str(R.extract(5)),
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=2,
                                           column=4,
                                           pady=(0, 10),
                                           sticky=W)

    rcl1 = Label(rc,
                 text="Semester",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=4,
                                           column=0,
                                           pady=(20, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text="Classes",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=4,
                                           column=1,
                                           pady=(20, 10),
                                           sticky=W)
    rcl1 = Label(rc, text="Grade", fg="blue", bg="white",
                 font=("Verdana", 8)).grid(row=4,
                                           column=6,
                                           pady=(20, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text="Teacher",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=4,
                                           column=4,
                                           pady=(20, 10),
                                           sticky=W)
    rcl1 = Label(rc,
                 text="Credits",
                 fg="blue",
                 bg="white",
                 font=("Verdana", 8)).grid(row=4,
                                           column=5,
                                           pady=(20, 10),
                                           sticky=W)
    #Various labels to display student information

    #THE FOLLOWING CODE ONLY DISPLAYS 2 SEMESTERS OF CLASSES
    #You can make a loop to display more semesters
    i = 1
    k = 1
    y = str(R.extract(7, i, k))
    z = str(R.extract(8, i, k))
    f2 = str(D.extract(2, 1, i))
    x = str(R.extract(6, i))
    rcl1 = Label(rc, text=x, fg="blue", bg="white",
                 font=("Verdana", 8)).grid(row=4 + i,
                                           column=0,
                                           pady=5,
                                           sticky=W)
    C = F2.read(y)
    #Various variables we need to update throughout the Loop
    #y is class, z is grade, f2 is teacher, x is semester
    #This code is suppose to loop through each class in a semester, then loop through the semesters

    while y != "":

        rcl1 = Label(rc,
                     text=str(C.extract(1)),
                     fg="blue",
                     bg="white",
                     font=("Verdana", 8)).grid(row=4 + k,
                                               column=1,
                                               columnspan=5,
                                               pady=5,
                                               sticky=W)
        rcl1 = Label(rc, text=z, fg="blue", bg="white",
                     font=("Verdana", 8)).grid(row=4 + k,
                                               column=6,
                                               pady=5,
                                               sticky=W)
        rcl1 = Label(rc,
                     text=str(C.extract(2)),
                     fg="blue",
                     bg="white",
                     font=("Verdana", 8)).grid(row=4 + k,
                                               column=5,
                                               pady=5,
                                               sticky=W)
        rcl1 = Label(rc, text=f2, fg="blue", bg="white",
                     font=("Verdana", 8)).grid(row=4 + k,
                                               column=4,
                                               pady=5,
                                               sticky=W)

        k = k + 1
        y = str(R.extract(7, i, k))
        z = str(R.extract(8, i, k))
        f2 = str(D.extract(2, 1, k))
        if y != "":
            C = F2.read(y)
    else:
        i = i + 1
        x = str(R.extract(6, i))
        rcl1 = Label(rc, text=x, fg="blue", bg="white",
                     font=("Verdana", 8)).grid(row=5 + k,
                                               column=0,
                                               pady=5,
                                               sticky=W)
        k2 = k + 4
    #Displays the classes and its information in the first semester and increments the semester

    k = 1
    y = str(R.extract(7, i, k))
    z = str(R.extract(8, i, k))
    f2 = str(D.extract(2, 2, k))
    C = F2.read(y)
    #Sets variables to the first class in the second semester

    while y != "":
        rcl1 = Label(rc,
                     text=str(C.extract(1)),
                     fg="blue",
                     bg="white",
                     font=("Verdana", 8)).grid(row=k2 + k,
                                               column=1,
                                               columnspan=5,
                                               pady=5,
                                               sticky=W)
        rcl1 = Label(rc, text=z, fg="blue", bg="white",
                     font=("Verdana", 8)).grid(row=k2 + k,
                                               column=6,
                                               pady=5,
                                               sticky=W)
        rcl1 = Label(rc,
                     text=str(C.extract(2)),
                     fg="blue",
                     bg="white",
                     font=("Verdana", 8)).grid(row=k2 + k,
                                               column=5,
                                               pady=5,
                                               sticky=W)
        rcl1 = Label(rc, text=f2, fg="blue", bg="white",
                     font=("Verdana", 8)).grid(row=k2 + k,
                                               column=4,
                                               pady=5,
                                               sticky=W)

        k = k + 1
        y = str(R.extract(7, i, k))
        z = str(R.extract(8, i, k))
        f2 = str(D.extract(2, 2, k))
        if y != "":
            C = F2.read(y)
Пример #30
0
# Declare Variables #
#####################
entryText = StringVar()
idText = StringVar()
fnameText = StringVar()
lnameText = StringVar()
majorText = StringVar()
minorText = StringVar()
advisorText = StringVar()
semesterText = StringVar()
classType = ""
i = 1
#Semester tracker
k = 1
#Class tracker
R = u2py.DynArray()
#Empty dynamic array

########################
# Access UniData files #
########################
F = u2py.File("STUDENT")
F2 = u2py.File("COURSES")
T = u2py.DynArray("TEACHERS")


############
# Exit GUI #
############
def quitgui():
    root.destroy()