hey, im having trouble making a python program run using a window, honestly i dont even know where to start. I have to make a coffee program where there is a menu and the user has to choose between adding, modifying, searching, showing, and deleting any entrys made to the program. I have the program written out so it runs but without a menu so it just goes through everything i previously mentioned. can someone help me?...idk if i can post the code in here because it is a very large program file.

Your program can't be that long, lets show the code.

Run using a window?

As in run with a Graphical User Interface?

yes,, i agree with my friend on above...you must show yoour code so i can help you..

thx

hey, im having trouble making a python program run using a window, honestly i dont even know where to start. I have to make a coffee program where there is a menu and the user has to choose between adding, modifying, searching, showing, and deleting any entrys made to the program. I have the program written out so it runs but without a menu so it just goes through everything i previously mentioned. can someone help me?...idk if i can post the code in here because it is a very large program file.

#Coffee Problem
#4/2/2010


    def add():
    # Create a variable to control the loop.
        another = 'y'

    # Open the coffee.txt file in append mode.
        coffee_file = open('coffee.txt', 'a')

    # Add records to the file.
        while another == 'y' or another == 'Y':
            try:
                    # Get the coffee record data.
                print 'Enter the following coffee data:'
                descr = raw_input('Description: ')
                qty = input('Quantity (in pounds): ')

            # Append the data to the file.
                coffee_file.write(descr + '\n')
                coffee_file.write(str(qty) + '\n')

            # Determine whether the user wants to add
            # another record to the file.
            except:
                print'Sorry wrong input, please try again.'
            print 'Do you want to add another record?'
            another = raw_input('Y = yes, anything else = no: ')

    # Close the file.
        coffee_file.close()
        print 'Data appended to coffee.txt.'

# Call the main function.
add()

def delete():
    import os  # Needed for the remove and rename functions

    # Create a bool variable to use as a flag.
    found = False
    # Get the .
    search = raw_input('Which coffee do you want to delete? ')
    # Open the original coffee.txt file.
    coffee_file = open('coffee.txt', 'r')

    # Open the temporary file.
    temp_file = open('temp.txt', 'w')

    # Read the first record's description field.
    descr = coffee_file.readline()

    # Read the rest of the file.
    while descr != '':
        # Read the quantity field.
        qty = float(coffee_file.readline())

        # Strip the \n from the description.
        descr = descr.rstrip('\n')

        # If this is not the record to delete, then
        # write it to the temporary file.
        if descr != search:
            # Write the record to the temp file.
            temp_file.write(descr + '\n')
            temp_file.write(str(qty) + '\n')
            
            # Set the found flag to True.
            found = True

        # Read the next description.
        descr = coffee_file.readline()

    # Close the coffee file and the temporary file.
    coffee_file.close()
    temp_file.close()

    # Delete the original coffee.txt file.
    os.remove('coffee.txt')

    # Rename the temporary file.
    os.rename('temp.txt', 'coffee.txt')

    # If the search value was not found in the file
    # display a message.
    if found:
        print 'The file has been updated.'
    else:
        print 'That item was not found in the file.'

# Call the main function.
delete()

import os  # Needed for the remove and rename functions

def modify():
    # Create a bool variable to use as a flag.
    found = False
    again = True

    # Get the search value and the new quantity.
    search = raw_input('Enter a description to search for: ')
    
    # Open the original coffee.txt file.
    coffee_file = open('coffee.txt', 'r')

    # Open the temporary file.
    temp_file = open('temp.txt', 'w')

    # Read the first record's description field.
    descr = coffee_file.readline()

    # Read the rest of the file.
    while descr != '':
        # Read the quantity field.
        qty = float(coffee_file.readline())

        # Strip the \n from the description.
        descr = descr.rstrip('\n')

        # Write either this record to the temporary file,
        # or the new record if this is the one that is
        # to be modified.
        if descr == search:
            while again:
                try:
                    again = False
                    new_qty = input('Enter the new quantity: ')
                except:
                    again = True
                    print "Enter a number for quantity."
    
            
            # Write the modified record to the temp file.
            temp_file.write(descr + '\n')
            temp_file.write(str(new_qty) + '\n')
            
            # Set the found flag to True.
            found = True
        else:
            # Write the original record to the temp file.
            temp_file.write(descr + '\n')
            temp_file.write(str(qty) + '\n')

        # Read the next description.
        descr = coffee_file.readline()

    # Close the coffee file and the temporary file.
    coffee_file.close()
    temp_file.close()

    # Delete the original coffee.txt file.
    os.remove('coffee.txt')

    # Rename the temporary file.
    os.rename('temp.txt', 'coffee.txt')

    # If the search value was not found in the file
    # display a message.
    if found:
        print 'The file has been updated.'
    else:
        print 'That item was not found in the file.'

# Call the main function.
modify()

def search():
    # Create a bool variable to use as a flag.
    found = False

    # Get the search value.
    search = raw_input('Enter a description to search for: ')

    # Open the coffee.txt file.
    coffee_file = open('coffee.txt', 'r')

    # Read the first record's description field.
    descr = coffee_file.readline()

    # Read the rest of the file.
    while descr != '':
        # Read the quantity field.
        qty = float(coffee_file.readline())

        # Strip the \n from the description.
        descr = descr.rstrip('\n')

        # Determine whether this record matches
        # the search value.
        if descr == search:
            # Display the record.
            print 'Description:', descr
            print 'Quantity:', qty
            print
            # Set the found flag to True.
            found = True

        # Read the next description.
        descr = coffee_file.readline()

    # Close the file.
    coffee_file.close()

    # If the search value was not found in the file
    # display a message.
    if not found:
        print 'That item was not found in the file.'

# Call the main function.
search()

def show():
    # Create a bool variable to use as a flag.
    found = False

    # Get the search value.
    search = raw_input('Enter a description to search for: ')

    # Open the coffee.txt file.
    coffee_file = open('coffee.txt', 'r')

    # Read the first record's description field.
    descr = coffee_file.readline()

    # Read the rest of the file.
    while descr != '':
        # Read the quantity field.
        qty = float(coffee_file.readline())

        # Strip the \n from the description.
        descr = descr.rstrip('\n')

        # Determine whether this record matches
        # the search value.
        if descr == search:
            # Display the record.
            print 'Description:', descr
            print 'Quantity:', qty
            print
            # Set the found flag to True.
            found = True

        # Read the next description.
        descr = coffee_file.readline()

    # Close the file.
    coffee_file.close()

    # If the search value was not found in the file
    # display a message.
    if not found:
        print 'That item was not found in the file.'

# Call the main function.
show()

There you go please help if you can.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.