I am trying to create a GUI that will display a new window with information about my program when the user clicks on the info button (a green "i" bitmap). So far all I can get my program to do is show the new window (using Toplevel() ) when the program loads, not when the user presses the information bitmap. I think it has something to do with my command for the information button. Anyone have any ideas or have a GOOD resource that they could point me to?
 
Thanks
 

from Tkinter import *

class Application(Frame):
  """ A GUI application with three buttons. """
 
  def __init__(self, master):
    """ Initialize the Frame. """
    Frame.__init__(self,master)
    self.grid()
    self.create_widgets()
  
  def update_text(self):
    message = self.toolbar.get()
    self.results.delete(0.0, END)
    self.results.insert(0.0, message)
   
  def create_widgets(self):
    # create variable for single toolbar selection
    self.toolbar = StringVar()
   
    """Create button, text and entry widgets. """
    #create welcome text
    welcome = Label(self)
    welcome["text"] = "You are now about to run Automation Testing.\n"\
    "Please check the toolbar to be tested and then select\n"\
    "the test you would like to perform."
   
    welcome.grid(row = 0, column = 0, columnspan = 3, sticky = W)
   
    #create Upr Radio
    Radiobutton(self, text = "Upr", variable = self.toolbar,
                value = "upr", command = self.update_text).grid(row = 1, column = 0, sticky = W)
   
    #create Com Radio
    Radiobutton(self, text = "Com", variable = self.toolbar,
                value = "com", command = self.update_text ).grid(row = 1, column = 1, sticky = W)
   
    #create CI Radio
    Radiobutton(self, text = "CI", variable = self.toolbar,
                value = "ci", command = self.update_text).grid(row = 1, column = 2, sticky = W)
               
    #create text box
    self.results = Text(self, width = 40, height = 4, wrap = WORD)
    self.results.grid(row = 2, column = 0, columnspan = 3, sticky = W)   
   
    #create Performance button
    self.perf_bttn = Button(self)
    self.perf_bttn["text"] = "Performance"
    self.perf_bttn["command"] = self.perf
    self.perf_bttn.grid(row = 3, column = 0, sticky = W)
    message = self.toolbar.get()
   
    #create PII button
    self.pii_bttn = Button(self)
    self.pii_bttn["text"] = "PII"
    self.pii_bttn.grid(row = 3, column = 1, sticky = W)
   
    #create info button
    self.info_bttn = Button(self)
    self.info_bttn["fg"] = "green"
    self.info_bttn["bitmap"] = "info"
    self.info_bttn.command = self.info ()
    self.info_bttn.grid(row = 3, column = 2, sticky = W)
   
    #create exit button
    self.exit_bttn = Button(self)
    self.exit_bttn["fg"] = "red"
    self.exit_bttn["cursor"] = "pirate"
    self.exit_bttn["text"] = "EXIT"
    self.exit_bttn["command"] = root.quit
    self.exit_bttn.grid(row = 3, column = 3, sticky = W)
 
  def perf(self):
    import performance
    performance.perf(self.toolbar.get())

   
  def info(self):
    # create child window
    win = Toplevel()
   
   
   
   
 
# main
root = Tk()
root.title("Automation Testing")
app = Application(root)
root.mainloop()

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

Reply via email to