I am a newbie to python, but not programming.

I have a menubar item 

displaySubMenu.add_command(label="External", command=externalDisplay)

externalDisplay is a new class, which I have already imported.  The class is 
here:

from Tkinter import *
from datetime import datetime, date, time
import urllib
from PIL import Image
#import Image # PIL required
import ImageTk

backColor = "Gray"
highcolor = "Green"
entryColor = "Cyan"
okColor = "Green"
warnColor = "Red"

class externalDisplay(Frame):
    
    def __init__(self,callSign,nexrad):
        """Initialize yourself"""
        self.callSign = callSign
        self.nexrad = nexrad
        #"""Initialise the base class"""
        Frame.__init__(self)
        
        "Set the Window Title"""
        #self.title( "Test")


        self.findu = "http://www.findu.com/cgi-bin/radar-find.cgi?call="; + 
self.callSign + "&radar=" + self.nexrad

        """Display the main window" with a little bit of padding"""
        self.grid(padx=5,pady=5)
        self.CreateWidgets()
       
    def CreateWidgets(self):
        #"""Create all the widgets that we need"""
        self.f = Frame(self, bd=0, bg=backColor)
        self.title = "netcomm Online Radar"
        self.f.grid()
        #
        # Insert the date and time the radar image was updated
        #
        self.lblLastUpdate = Label(self.f, text="Last Updated: " + 
str(datetime.now()), bg=backColor)
        self.lblLastUpdate.grid( row=0, column=0, sticky=W)
        self.btnRefresh = Button(self.f, text="Refresh", 
command=handlesExternalDisplayByClick, 
bg=backColor,highlightbackground=okColor,highlightcolor=highcolor)
        self.btnRefresh.grid(row=0, column=1)
        self.btnRefresh = Button(self.f, text="Close", command=self.destroy, 
bg=backColor,highlightbackground=warnColor,highlightcolor=highcolor)
        self.btnRefresh.grid(row=0, column=2)
        #
        # Start the download from findu
        #
        #
        # This gets the image and saves it to the local disk as "image.png"
        #
        # NOTE - will ideally want to conver this to GIF and save it using
        #        the date as part of the filename so the net can be re-created
        #        for reporting and to create a flipbook of the radar images
        #
        urllib.urlretrieve(self.findu, "image.png")
        Image.open("image.png").save("image.gif")
        self.photo = PhotoImage(file="image.gif")
        #
        # create a canvas of the appropriate size for the image
        #
        self.w = Canvas(self.f, width=600, height=550)
        #
        # convert it into a photo item we can use in the display
        #
        self.netRadarImage = Label(self.w, image=self.photo)
        self.netRadarImage.image = self.photo
        self.w.grid(row=1, column=0, columnspan=3)
        self.netRadarImage.grid( row=1, column=0)

def handlesExternalDisplayByClick(self):
        #
        # destroy the existing frame the radar is in
        #
        self.destroy()
        #
        # rebuild the radarWidgets
        #
        createRadarWidgets(frameRadar)

def handlesRadarRefreshByClick(self):
        #
        # destroy the existing frame the radar is in
        #
        self.destroy()
        #
        # rebuild the radarWidgets
        #
        self.update()

if __name__ == "__main__":
    guiFrame = externalDisplay("AE5PL-10","fws")
    guiFrame.mainloop()

The problem is that the window defined in the class never appears, and I don't 
know why.  I would like to get all of the code for the window into a single 
file which I import, but since I can't make this work right, I don't want to 
invest the time yet.    Eve worse, is that when I run the code as a standalone 
module and click on the close  button, I am left with a tk window instead of 
the app actually closing.

Any suggestions are appreciated.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to