GUI tk question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jumperbl
    New Member
    • Mar 2008
    • 17

    GUI tk question

    what is the purpose of of this line "makemodal = (len(sys.argv) > 1)" in this script:

    #!/usr/bin/env python
    import sys
    from Tkinter import *
    makemodal = (len(sys.argv) > 1)

    class Yoli(Frame):

    def __init__(self, master):
    Frame.__init__( self, master)
    self.grid()
    self.createwidg ets()

    def loveyoli(self):
    win = Toplevel()
    Label(win, text='I love you Yoli').pack()
    if makemodal:
    win.focus_set()
    win.grab_set()
    win.wait_window ()
    #print 'dialog exit'

    def callloveyoli(se lf):
    i = 0
    j = 10
    while i <j:
    self.loveyoli()
    i = i+1


    def createwidgets(s elf):
    self.numb_lbl = Label(text = "Enter a number")
    self.numb_lbl.g rid(row = 0, column = 0,
    columnspan = 2, sticky = W)
    Button(root, text='A screet',
    command=self.ca llloveyoli).gri d(row=4, column = 0,
    sticky = W)

    root = Tk()
    root.title('A message for Yoli')
    app = Yoli(root)
    root.mainloop()
  • jlm699
    Contributor
    • Jul 2007
    • 314

    #2
    Please use code tags when posting code as stated in the posting guidlines:
    Guidelines
    That being said, makemodal gives focus to a window until the window is closed. So the line makemodal( len(sys.argv) > 1 ) says " Make this program have focus if a parameter was passed to it.

    Comment

    Working...