<s> """<STR_LIT>""" <EOL> from Tkinter import * <EOL> import tkMessageBox <EOL> class GetCfgSectionNameDialog ( Toplevel ) : <EOL> def __init__ ( self , parent , title , message , usedNames ) : <EOL> """<STR_LIT>""" <EOL> Toplevel . __init__ ( self , parent ) <EOL> self . configure ( borderwidth = <NUM_LIT:5> ) <EOL> self . resizable ( height = FALSE , width = FALSE ) <EOL> self . title ( title ) <EOL> self . transient ( parent ) <EOL> self . grab_set ( ) <EOL> self . protocol ( "<STR_LIT>" , self . Cancel ) <EOL> self . parent = parent <EOL> self . message = message <EOL> self . usedNames = usedNames <EOL> self . result = '<STR_LIT>' <EOL> self . CreateWidgets ( ) <EOL> self . withdraw ( ) <EOL> self . update_idletasks ( ) <EOL> self . messageInfo . config ( width = self . frameMain . winfo_reqwidth ( ) ) <EOL> self . geometry ( "<STR_LIT>" % <EOL> ( ( parent . winfo_rootx ( ) + ( ( parent . winfo_width ( ) / <NUM_LIT:2> ) <EOL> - ( self . winfo_reqwidth ( ) / <NUM_LIT:2> ) ) , <EOL> parent . winfo_rooty ( ) + ( ( parent . winfo_height ( ) / <NUM_LIT:2> ) <EOL> - ( self . winfo_reqheight ( ) / <NUM_LIT:2> ) ) ) ) ) <EOL> self . deiconify ( ) <EOL> self . wait_window ( ) <EOL> def CreateWidgets ( self ) : <EOL> self . name = StringVar ( self ) <EOL> self . fontSize = StringVar ( self ) <EOL> self . frameMain = Frame ( self , borderwidth = <NUM_LIT:2> , relief = SUNKEN ) <EOL> self . frameMain . pack ( side = TOP , expand = TRUE , fill = BOTH ) <EOL> self . messageInfo = Message ( self . frameMain , anchor = W , justify = LEFT , padx = <NUM_LIT:5> , pady = <NUM_LIT:5> , <EOL> text = self . message ) <EOL> entryName = Entry ( self . frameMain , textvariable = self . name , width = <NUM_LIT:30> ) <EOL> entryName . focus_set ( ) <EOL> self . messageInfo . pack ( padx = <NUM_LIT:5> , pady = <NUM_LIT:5> ) <EOL> entryName . pack ( padx = <NUM_LIT:5> , pady = <NUM_LIT:5> ) <EOL> frameButtons = Frame ( self ) <EOL> frameButtons . pack ( side = BOTTOM , fill = X ) <EOL> self . buttonOk = Button ( frameButtons , text = '<STR_LIT>' , <EOL> width = <NUM_LIT:8> , command = self . Ok ) <EOL> self . buttonOk . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> , padx = <NUM_LIT:5> , pady = <NUM_LIT:5> ) <EOL> self . buttonCancel = Button ( frameButtons , text = '<STR_LIT>' , <EOL> width = <NUM_LIT:8> , command = self . Cancel ) <EOL> self . buttonCancel . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:1> , padx = <NUM_LIT:5> , pady = <NUM_LIT:5> ) <EOL> def NameOk ( self ) : <EOL> nameOk = <NUM_LIT:1> <EOL> name = self . name . get ( ) <EOL> name . strip ( ) <EOL> if not name : <EOL> tkMessageBox . showerror ( title = '<STR_LIT>' , <EOL> message = '<STR_LIT>' , parent = self ) <EOL> nameOk = <NUM_LIT:0> <EOL> elif len ( name ) > <NUM_LIT:30> : <EOL> tkMessageBox . showerror ( title = '<STR_LIT>' , <EOL> message = '<STR_LIT>' + <EOL> '<STR_LIT>' , parent = self ) <EOL> nameOk = <NUM_LIT:0> <EOL> elif name in self . usedNames : <EOL> tkMessageBox . showerror ( title = '<STR_LIT>' , <EOL> message = '<STR_LIT>' , parent = self ) <EOL> nameOk = <NUM_LIT:0> <EOL> return nameOk <EOL> def Ok ( self , event = None ) : <EOL> if self . NameOk ( ) : <EOL> self . result = self . name . get ( ) . strip ( ) <EOL> self . destroy ( ) <EOL> def Cancel ( self , event = None ) : <EOL> self . result = '<STR_LIT>' <EOL> self . destroy ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> root = Tk ( ) <EOL> def run ( ) : <EOL> keySeq = '<STR_LIT>' <EOL> dlg = GetCfgSectionNameDialog ( root , '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> print dlg . result <EOL> Button ( root , text = '<STR_LIT>' , command = run ) . pack ( ) <EOL> root . mainloop ( ) </s>
