<s> '''<STR_LIT>''' <EOL> from tkinter import Toplevel , StringVar , N , S , E , W , EW <EOL> try : <EOL> from tkinter . ttk import Frame , Button , Label , Entry <EOL> except ImportError : <EOL> from ttk import Frame , Button , Label , Entry <EOL> from arelle . CntlrWinTooltip import ToolTip <EOL> try : <EOL> import regex as re <EOL> except ImportError : <EOL> import re <EOL> '''<STR_LIT>''' <EOL> def askURL ( parent , url = None , buttonSEC = False , buttonRSS = False ) : <EOL> dialog = DialogURL ( parent , url , buttonSEC , buttonRSS ) <EOL> if dialog . accepted : <EOL> return dialog . url <EOL> return None <EOL> class DialogURL ( Toplevel ) : <EOL> def __init__ ( self , parent , url = None , buttonSEC = False , buttonRSS = False ) : <EOL> super ( DialogURL , self ) . __init__ ( parent ) <EOL> self . parent = parent <EOL> parentGeometry = re . match ( "<STR_LIT>" , parent . geometry ( ) ) <EOL> dialogX = int ( parentGeometry . group ( <NUM_LIT:3> ) ) <EOL> dialogY = int ( parentGeometry . group ( <NUM_LIT:4> ) ) <EOL> self . accepted = False <EOL> self . url = None <EOL> self . transient ( self . parent ) <EOL> self . title ( "<STR_LIT>" ) <EOL> self . urlVar = StringVar ( ) <EOL> self . urlVar . set ( url if url is not None else "<STR_LIT>" ) <EOL> frame = Frame ( self ) <EOL> urlLabel = Label ( frame , text = _ ( "<STR_LIT>" ) , underline = <NUM_LIT:0> ) <EOL> urlEntry = Entry ( frame , textvariable = self . urlVar , width = <NUM_LIT> ) <EOL> urlEntry . focus_set ( ) <EOL> okButton = Button ( frame , text = _ ( "<STR_LIT:OK>" ) , command = self . ok ) <EOL> cancelButton = Button ( frame , text = _ ( "<STR_LIT>" ) , command = self . close ) <EOL> if buttonSEC : <EOL> usSecButton = Button ( frame , text = _ ( "<STR_LIT>" ) , command = self . usSec ) <EOL> usSecButton . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:1> , sticky = W , pady = <NUM_LIT:3> ) <EOL> ToolTip ( usSecButton , text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> wraplength = <NUM_LIT> ) <EOL> if buttonRSS : <EOL> rssButton = Button ( frame , text = _ ( "<STR_LIT>" ) , command = self . rssFeed ) <EOL> rssButton . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:1> , pady = <NUM_LIT:3> ) <EOL> ToolTip ( rssButton , text = _ ( "<STR_LIT>" ) , <EOL> wraplength = <NUM_LIT> ) <EOL> urlLabel . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> , sticky = W , pady = <NUM_LIT:3> , padx = <NUM_LIT:3> ) <EOL> urlEntry . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:1> , columnspan = <NUM_LIT:3> , sticky = EW , pady = <NUM_LIT:3> , padx = <NUM_LIT:3> ) <EOL> okButton . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:2> , sticky = E , pady = <NUM_LIT:3> ) <EOL> ToolTip ( okButton , text = _ ( "<STR_LIT>" ) , wraplength = <NUM_LIT> ) <EOL> cancelButton . grid ( row = <NUM_LIT:1> , column = <NUM_LIT:3> , sticky = EW , pady = <NUM_LIT:3> , padx = <NUM_LIT:3> ) <EOL> ToolTip ( cancelButton , text = _ ( "<STR_LIT>" ) ) <EOL> frame . grid ( row = <NUM_LIT:0> , column = <NUM_LIT:0> , sticky = ( N , S , E , W ) ) <EOL> frame . columnconfigure ( <NUM_LIT:1> , weight = <NUM_LIT:1> ) <EOL> window = self . winfo_toplevel ( ) <EOL> window . columnconfigure ( <NUM_LIT:0> , weight = <NUM_LIT:1> ) <EOL> self . geometry ( "<STR_LIT>" . format ( dialogX + <NUM_LIT:50> , dialogY + <NUM_LIT:100> ) ) <EOL> self . bind ( "<STR_LIT>" , lambda * ignore : urlEntry . focus_set ( ) ) <EOL> self . bind ( "<STR_LIT>" , self . ok ) <EOL> self . bind ( "<STR_LIT>" , self . close ) <EOL> self . protocol ( "<STR_LIT>" , self . close ) <EOL> self . grab_set ( ) <EOL> self . wait_window ( self ) <EOL> def ok ( self , event = None ) : <EOL> self . url = self . urlVar . get ( ) . strip ( ) <EOL> if self . url and self . url [ <NUM_LIT:0> ] == '<STR_LIT:">' and self . url [ - <NUM_LIT:1> ] == '<STR_LIT:">' : <EOL> self . url = self . url [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> self . accepted = True <EOL> self . close ( ) <EOL> def close ( self , event = None ) : <EOL> self . parent . focus_set ( ) <EOL> self . destroy ( ) <EOL> def usSec ( self , event = None ) : <EOL> import webbrowser <EOL> webbrowser . open ( "<STR_LIT>" ) <EOL> def rssFeed ( self , event = None ) : <EOL> self . url = "<STR_LIT>" <EOL> self . accepted = True <EOL> self . close ( ) </s>
