Whats missing?

Daniel Faulkner m01ymu00 at cwcom.net
Tue Jun 1 19:24:56 CEST 1999


I was just messing about and found out that if I made some thing like
this it would not work but if I did it by typing at the python prompt

from urllib import urlopen
Data = urlopen("http://www.python.org/").read()
print Data

It would work but why is this?

from Tkinter import *
from urllib import urlopen

class HTMLBrowser(Frame):
    def Create_Widgets(self):
        # frames
        butFrame = Frame()
        butFrame.pack(side='top')
        # normal widgets
        self.QuitB = Button(butFrame, text='Quit', fg='red',
command=self.quit)
        self.UrlEnt = Entry(self, relief=SUNKEN)
        self.source_box = Text(self)
        self.startB = Button(butFrame, text='Start',
command=self.UrlGeting)
        # Pack it
        self.QuitB.pack(side='left')
        self.startB.pack(side='left')
        self.UrlEnt.pack(side='top', fill='x')
        self.source_box.pack(side='bottom')
    def lets_see_it(self):
        self.source_box.insert('0.0', self.Data)
    def UrlGeting(self):
        UrlCurr = self.UrlEnt.get()
        Data = urlopen('"' + UrlCurr + '"').read()
        self.source_box.insert('0.0', Data)
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.Create_Widgets()

# Test
Dat = urlopen("http://www.python.org/")
# print Dat

Browser = HTMLBrowser()
Browser.mainloop()





More information about the Python-list mailing list