|Welcome to CS1315. Click on the python to add comments.|
|This page removed for FERPA compliance|
Spring 2003 Homework 4
Ask your questions on Homework 4 here...
So, it doesn't matter what folder and what pictures we use? We can create our own? or use the one from class?
|You're going to a directory path as input, so it better work for any directory containing JPEG images. Mark Guzdial|
In the first part of the assignment instructions, you said to name the fnction " linksREMOVED" and then at the end you said to name the function hw4 - which is correct?
The way the homework is stated, it sounds like we are given a specific folder with images to use. Above it sounds like we are to create a function that takes the directory as input. Can you please re-word the problem so this is more clear. Thank you
|It works just like the samples example in class today. We give you the path to a directory as a string. Mark Guzdial|
I created an html folder containg images called index.html using jes, but it won't open in the internet browser. this is the message i get : internet explorer could not open c:/jes1/hw4.html . ANY ADVICE.
|Try double-clicking on the file and seeing what is in it, or open it again from JES. Your note is unclear: You made a folder named index.html, but tried to open a file named hw4.html? Browsers can't open folders – they can open files that are in the .html format. Mark Guzdial|
the Instruction is a little confusing.I created an html page name Index.html containing images thru jes and try to open it in the browser. I thought this is what we should be doing first. the browser won't open the page.
|No, absolutely not. Did you come to class and see the Samples code run? You're building code very much like that. You are not just writing an index.html file – you are writing a program that CREATES an HTML file. Mark Guzdial|
On the slide, you have "Import OS" and then later in the function you have " for file in os.listdir(directory)". But in class, your program that you ran did not have this. What does it do and why would you need it?
|I did have it in the program, and we discussed this WEEKS ago. It's even in the book – see page 177. It's needed to process all the files in a directory. Mark Guzdial|
I got the function to work, but when I click on the image in the browser it goes to a page that says "REMOVED cannot be displayed". Is this because the images are on my computer and not the internet? Is it supposed to show the image in its real size after you click on the "thumbnail"?
|What is the target for the anchors you create? You have to create <a> tags to create clickable-anchors, and you'll use href= to set the target for the anchors. That's what will show it at it's real size. You want those targets to be the actual pictures. Yes, the created HTML should run fine if you create it in the same directory as your pictures – you don't have to upload it to a Web server. Mark Guzdial|
I think I almost have it, but I can't figure out what to put in the tags to get a link to each picture. I have tried so many different things, but nothing works! Can someone help me, please? Also, does the file have to have thumbnails as links to each picture? The way I understood it, it just had to have a link (which in my case will be the name of the file or some other text link).
|The nice thing about HTML is that you can just type it into a file and try it. Get the effect you want in plain HTML, then write a program that generates what you wrote. Mark Guzdial|
I can't figure it out either. I have the tags with the href, but I cant figure out what the href=. How do I get the targets to be the actual pictures?
I got it!!!! Look closely at the number of quotations in the slide and make sure your's look like them (especially for the word file!!)
ok, so with my code i had it search to see if the last three letters in the file name are jpg or JPG so that it doesn't try to make something other than a picture a link if there are things othre than pictures in the specific folder path. however, i am afraid that this won't work on computers where the file names do not end with jpg. will this be a problem?? jessica dickerson
Is it okay if your string is long? For example I execute "linksREMOVED("C:\Documents and Settings\Lauren Biddle\My Documents\My Pictures")" and this works for the way that my function is set up. But is this legal to get full credit for the lab?
|Absolutely – that's what a solution should look like. Mark Guzdial|
I have the program creating the index and making the picures links, but two of the pictures won't show up; either as the link or when I click on it. The others work properly, and even the ones that just show that red "x" for the link, have what seems to be the correct filename in the address window of the page, although it says it can't be displayed. What would make my program work for some JPEGs and not others?
|Check the filenames in your generated HTML and in the window (use the detail view). Are they spelled right? Did you grab non-JPG files? Are there issues like spaces in filenames that can confuse HTML? Mark Guzdial|
I'm still having some problems getting the pictures to link to the bigger versions. Here's my code: samples=samples+"
Can someone tell me what I'm doing wrong? Thanks!
Let me try that again:
samples=samples+'<a href="+file+">Filename</a><image src="'+file+'" height="100" /></p>\n'
|The problem is that you've placed "Filename" as the anchor text, what's clickable. You need the IMAGE be what's clickable. (I showed how to do this in class this morning, and talked about it on Monday.) Mark Guzdial|
ok, so i just read through everyones comments and my code is nothing like anyone else's. is this a problem. it does work and i tested it out, but does it have to be like the one in the notes from class or could we do it a totally different way? Jessica Dickerson
|Of course it can be a totally different way! That's fine! Mark Guzdial|
As requested, I posted genSamples2.py that I built in lecture this morning, on the Syllabus and Lecture Slides-Spring 2003 page next to the HTML lecture day. Mark Guzdial
I am a little confused about the wording for how we turn this in. I should save my jes file as "hw4.py" and then my program should be called def linksREMOVED()? Susan Holloman
1. What do you want the top of the html page to say?...I used the one from your example Samples from C:/..../pics
|No need to apologize! That's what this page is for! Mark Guzdial|
2. I have all of my pictures in order but when I put the cursor on it, it shows the directory. Is this right? The anchor shouldnt take us anywhere right?
|No, the anchor should take you to the picture. My guess is that you forgot the filename in the href. Mark Guzdial|
One more thing! How many pictures do you want in the directory? Will 7 be enough?
|We'll be testing on our own directories. It should work for any reasonable number (say, a few hundred). Mark Guzdial|
I've gotten the code to work and I made my samples file. When I pull up the html page, there are links to the pictures, but they don't go anywhere (just pulls up page with "REMOVED not found" at the top). I can't figure out what is wrong! any suggestions?
It also looks like when I click on the first picture that the 2nd link goes to that picture.
|Look at your HTML. What do the href's look like? Do they have the names of the pictures? If they don't, that's why you're getting the erorr that you are. Mark Guzdial|
sorry....that was from Student88
Nevermind...I fixed my own problem. I love it when that happens! Student88
samples=samples+"<p><a href="+file/"><image src=" '+file+' "height="100"/></p>\n'</a>
I keep getting an error when I input this. Jes can't read it as python. What is going on?
|Check your quotes. The file/" should probably be file+"/. There are similar errors elsewhere in that line. Mark Guzdial|
How do I just keep the words on here so this blank picture won't show up?
|Huh? Try again, please. What's "here"? What "blank picture"? Mark Guzdial|
How do you check to see if it works after you input linksREMOVED (blah blah blah? What comes next?
|It should create an HTML page that you can then open in a browser to see what it looks like. Mark Guzdial|
yeah i keep getting an error as well, i even copied the code professor Guzdial posted to try to see what i was doing wrong and i get an error with that code too.
my error was it can't read it as python by the way.
|You have to get the string addition right. "blah"+"blah" will you give you "blahblah". "blah" "blah" (no +) will give you an error that it doesn't look like Python. Mark Guzdial|
In the instructions, it says to have the height of 100, but does it matter about the width? Is it ok to set the width to 100 too?
|It's okay to set it like that, but then you'll get square icons that don't look like the original picture. Mark Guzdial|
I have been getting my function to work, I have an html file and it works fine. Today I tried it and I keep getting the error "A syntax error is contained in the code – I can't read it as Python" All of my friends are getting the same thing. I know the code works, I have the file to proove it. Why won't it work now? (And yes, I have re-started my computer.)
|You changed a space or a "+" or a quote somewhere. You can send me the file and I'll look at it, but you definitely did change the file. Mark Guzdial|
I keep getting the same error when I try to run it as well.
|Then look very carefully at each line and make sure that the quotes match and that you only have plus signs between strings. Mark Guzdial|
When running the program what comes after this line?
makeSampleREMOVED(r"c://mydocuments and settings/hw4images/samplepics")
I keep getting errors like"python can't read and file not found.
|Not sure how to answer this. Did you come to class and watch me do this in class? Mark Guzdial|
|Try using "\" instead of "/" - Jose|
This is just a guess, but I wonder if JES will only run that program once and save the resulting file to the JES directory. Once its in your JES file, JES might see that the file has already been created, and therefore throw out an error because it can't replace the first file you made. Dr. Guzdial can correct me if I am wrong, but that was the first thing that I could come up with.
|Nope – I ran the samples program several times in a row, making modifications each time. You can run it as often as you like. Mark Guzdial|
oh god i hate myself i've had the right code the whole time but when i executed it in the command line i forgot to put the r and quotes around the path.
|Why hate yourself? YOU FIGURED IT OUT! YOU RULE! Mark Guzdial|
what EXACTLY do you use as input? My comp keeps giving me "error-I can't read as python." what does that mean? i think i have it except for the input! Kelly Farrell
|"I can't read as Python" has nothing to do with the input. Check your code very carefully to make sure that quotes and parentheses match. Mark Guzdial|
I have completed the function and got it to load and all that good stuff. I tried to view my hw4.py in Internet Explorer to make sure everything was good with it. It showed me a screen with my code written on it, but broken up with "Samples from "+directory+"" in huge, bold letters. There was also a blank square box underneath it. What does this mean? Have I done something wrong?-REMOVED Williams
|REMOVED, don't look at HW4.py in IE. Look at the .html file you created in IE. Browsers understand HTML, not Python code. Mark Guzdial|
will someone post the anchor line??? please?!?!
If anyone can help me, please IM me at GTKelly26. I NEED help. Kelly Farrell
|Kelly, 404-894-5618 is my office number. I'll be here for another 20 minutes or so. Mark Guzdial|
My file works for making the samples page–but I just can seem to get it to link the pictures. I have moved and and ahref all over the place and taken them in and out and nothing changed. Can anyone offer me any suggestions? Here is my line of code that needs work I think :