#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0

    Print Characteristics in the root window


    Hi,

    I can change the print Chax in a widget with code like this:

    Code:
     # create third button
            self.bttn3 = Button(self, text = "Same here!", font = ('verdana', 20, 'roman'),
            fg = 'white', bg = 'red')
            self.bttn3.grid()
    But how do I change the text in the root window? I have tried many ways, none of which work. Here is one that doen't. Is it possible?

    Code:
    root = Tk()
    root.title("Lazy Buttons 2")
    root.font ('verdana', 30,'italic')
    Bill
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2009
    Posts
    474
    Rep Power
    33
    Here is an example that changes several values, as I am not positive what you are asking.
    Code:
    import Tkinter
    
    class EntryTest:
       """ shows using the same StringVar in the second list box
           and in the entry box
       """
       def __init__(self):
          self.top = Tkinter.Tk()
          self.top.title("Test of Entry")
          self.top.geometry("200x125+10+10")
    
          self.str_1 = Tkinter.StringVar()
          label_lit = Tkinter.StringVar()
    
          label_1 = Tkinter.Label(self.top, textvariable = label_lit )
          label_1.pack()
          label_lit.set( "Test of Label")
    
          label_2 = Tkinter.Label(self.top, textvariable = self.str_1 )
          label_2.pack()
    
          entry_1 = Tkinter.Entry(self.top, textvariable=self.str_1)
          entry_1.pack()
          self.str_1.set( "Entry Initial Value" )
    
          print_button = Tkinter.Button(self.top, text='PRINT CONTENTS',
                         command=self.getit, bg='blue', fg='white' )
          print_button.pack(fill=Tkinter.X, expand=1)
    
          exit_button= Tkinter.Button(self.top, text='EXIT',
                       command=self.top.quit, bg='red', fg='white' )
          exit_button.pack(fill=Tkinter.X, expand=1)
    
          entry_1.focus_set()
          self.top.mainloop()
    
       ##-----------------------------------------------------------------
       def getit(self) :
          print "getit: variable passed =", self.str_1.get()
    
    
    ##===============================================================
    if "__main__" == __name__  :
       ET=EntryTest()
       print "under __main__ =", ET.str_1.get()
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2009
    Posts
    7
    Rep Power
    0
    Hi,
    In the following code, from your example, suppose I wish to change the size of the title text: Is there a way of doing that?
    quote:
    def __init__(self):
    self.top = Tkinter.Tk()
    self.top.title("Test of Entry")
    self.top.geometry("200x125+10+10")
    end Quote:

    Thanks, Bill

IMN logo majestic logo threadwatch logo seochat tools logo