<s> '''<STR_LIT>''' <EOL> __all__ = ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> from kivy . uix . modalview import ModalView <EOL> from kivy . properties import ( StringProperty , ObjectProperty , OptionProperty , <EOL> NumericProperty , ListProperty ) <EOL> class PopupException ( Exception ) : <EOL> '''<STR_LIT>''' <EOL> class Popup ( ModalView ) : <EOL> '''<STR_LIT>''' <EOL> title = StringProperty ( '<STR_LIT>' ) <EOL> '''<STR_LIT>''' <EOL> title_size = NumericProperty ( '<STR_LIT>' ) <EOL> '''<STR_LIT>''' <EOL> title_align = OptionProperty ( '<STR_LIT:left>' , <EOL> options = [ '<STR_LIT:left>' , '<STR_LIT>' , '<STR_LIT:right>' , '<STR_LIT>' ] ) <EOL> '''<STR_LIT>''' <EOL> title_font = StringProperty ( '<STR_LIT>' ) <EOL> '''<STR_LIT>''' <EOL> content = ObjectProperty ( None ) <EOL> '''<STR_LIT>''' <EOL> title_color = ListProperty ( [ <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ] ) <EOL> '''<STR_LIT>''' <EOL> separator_color = ListProperty ( [ <NUM_LIT> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , <NUM_LIT> / <NUM_LIT> , <NUM_LIT:1.> ] ) <EOL> '''<STR_LIT>''' <EOL> separator_height = NumericProperty ( '<STR_LIT>' ) <EOL> '''<STR_LIT>''' <EOL> _container = ObjectProperty ( None ) <EOL> def add_widget ( self , widget ) : <EOL> if self . _container : <EOL> if self . content : <EOL> raise PopupException ( <EOL> '<STR_LIT>' ) <EOL> self . content = widget <EOL> else : <EOL> super ( Popup , self ) . add_widget ( widget ) <EOL> def on_content ( self , instance , value ) : <EOL> if self . _container : <EOL> self . _container . clear_widgets ( ) <EOL> self . _container . add_widget ( value ) <EOL> def on__container ( self , instance , value ) : <EOL> if value is None or self . content is None : <EOL> return <EOL> self . _container . clear_widgets ( ) <EOL> self . _container . add_widget ( self . content ) <EOL> def on_touch_down ( self , touch ) : <EOL> if self . disabled and self . collide_point ( * touch . pos ) : <EOL> return True <EOL> return super ( Popup , self ) . on_touch_down ( touch ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> from kivy . base import runTouchApp <EOL> from kivy . uix . button import Button <EOL> from kivy . uix . label import Label <EOL> from kivy . uix . gridlayout import GridLayout <EOL> from kivy . core . window import Window <EOL> content = GridLayout ( cols = <NUM_LIT:1> ) <EOL> content_cancel = Button ( text = '<STR_LIT>' , size_hint_y = None , height = <NUM_LIT> ) <EOL> content . add_widget ( Label ( text = '<STR_LIT>' ) ) <EOL> content . add_widget ( content_cancel ) <EOL> popup = Popup ( title = '<STR_LIT>' , <EOL> size_hint = ( None , None ) , size = ( <NUM_LIT> , <NUM_LIT> ) , <EOL> content = content , disabled = True ) <EOL> content_cancel . bind ( on_release = popup . dismiss ) <EOL> layout = GridLayout ( cols = <NUM_LIT:3> ) <EOL> for x in range ( <NUM_LIT:9> ) : <EOL> btn = Button ( text = str ( x ) ) <EOL> btn . bind ( on_release = popup . open ) <EOL> layout . add_widget ( btn ) <EOL> Window . add_widget ( layout ) <EOL> popup . open ( ) <EOL> runTouchApp ( ) </s>
