@@ -67,25 +67,29 @@ def __init__(self,
67
67
with context .client .layout :
68
68
super ().__init__ ()
69
69
if options :
70
- self ._props [ ' options' ] = options
70
+ self ._props . update ( options )
71
71
else :
72
- self ._props ['options' ] = {
73
- 'message' : str (message ),
74
- 'position' : position ,
75
- 'multiLine' : multi_line ,
76
- 'spinner' : spinner ,
77
- 'closeBtn' : close_button ,
78
- 'timeout' : (timeout or 0 ) * 1000 ,
79
- 'group' : False ,
80
- 'attrs' : {'data-id' : f'nicegui-dialog-{ self .id } ' },
81
- }
72
+ if message != '' :
73
+ self ._props ['message' ] = str (message )
74
+ if position != 'bottom' :
75
+ self ._props ['position' ] = position
76
+ if multi_line :
77
+ self ._props ['multiLine' ] = multi_line
78
+ if spinner :
79
+ self ._props ['spinner' ] = spinner
80
+ if close_button :
81
+ self ._props ['closeBtn' ] = close_button
82
+ if timeout != 5.0 :
83
+ self ._props ['timeout' ] = (timeout or 0 ) * 1000
84
+ self ._props ['group' ] = False
85
+ self ._props ['attrs' ] = {'data-id' : f'nicegui-dialog-{ self .id } ' }
82
86
if type is not None :
83
- self ._props ['options' ][ ' type' ] = type
87
+ self ._props ['type' ] = type
84
88
if color is not None :
85
- self ._props ['options' ][ ' color' ] = color
89
+ self ._props ['color' ] = color
86
90
if icon is not None :
87
- self ._props ['options' ][ ' icon' ] = icon
88
- self ._props ['options' ]. update ( kwargs )
91
+ self ._props ['icon' ] = icon
92
+ self ._props ['kwargs' ] = kwargs
89
93
90
94
if on_dismiss :
91
95
self .on_dismiss (on_dismiss )
@@ -102,90 +106,90 @@ async def handle_dismiss() -> None:
102
106
@property
103
107
def message (self ) -> str :
104
108
"""Message text."""
105
- return self ._props ['options' ][ ' message' ]
109
+ return self ._props ['message' ]
106
110
107
111
@message .setter
108
112
def message (self , value : Any ) -> None :
109
- self ._props ['options' ][ ' message' ] = str (value )
113
+ self ._props ['message' ] = str (value )
110
114
self .update ()
111
115
112
116
@property
113
117
def position (self ) -> NotificationPosition :
114
118
"""Position on the screen."""
115
- return self ._props ['options' ][ ' position' ]
119
+ return self ._props ['position' ]
116
120
117
121
@position .setter
118
122
def position (self , value : NotificationPosition ) -> None :
119
- self ._props ['options' ][ ' position' ] = value
123
+ self ._props ['position' ] = value
120
124
self .update ()
121
125
122
126
@property
123
127
def type (self ) -> NotificationType :
124
128
"""Type of the notification."""
125
- return self ._props [ 'options' ] .get ('type' )
129
+ return self ._props .get ('type' )
126
130
127
131
@type .setter
128
132
def type (self , value : NotificationType ) -> None :
129
133
if value is None :
130
- self ._props [ 'options' ] .pop ('type' , None )
134
+ self ._props .pop ('type' , None )
131
135
else :
132
- self ._props ['options' ][ ' type' ] = value
136
+ self ._props ['type' ] = value
133
137
self .update ()
134
138
135
139
@property
136
140
def color (self ) -> Optional [str ]:
137
141
"""Color of the notification."""
138
- return self ._props [ 'options' ] .get ('color' )
142
+ return self ._props .get ('color' )
139
143
140
144
@color .setter
141
145
def color (self , value : Optional [str ]) -> None :
142
146
if value is None :
143
- self ._props [ 'options' ] .pop ('color' , None )
147
+ self ._props .pop ('color' , None )
144
148
else :
145
- self ._props ['options' ][ ' color' ] = value
149
+ self ._props ['color' ] = value
146
150
self .update ()
147
151
148
152
@property
149
153
def multi_line (self ) -> bool :
150
154
"""Whether the notification is multi-line."""
151
- return self ._props ['options' ][ ' multiLine' ]
155
+ return self ._props ['multiLine' ]
152
156
153
157
@multi_line .setter
154
158
def multi_line (self , value : bool ) -> None :
155
- self ._props ['options' ][ ' multiLine' ] = value
159
+ self ._props ['multiLine' ] = value
156
160
self .update ()
157
161
158
162
@property
159
163
def icon (self ) -> Optional [str ]:
160
164
"""Icon of the notification."""
161
- return self ._props [ 'options' ] .get ('icon' )
165
+ return self ._props .get ('icon' )
162
166
163
167
@icon .setter
164
168
def icon (self , value : Optional [str ]) -> None :
165
169
if value is None :
166
- self ._props [ 'options' ] .pop ('icon' , None )
170
+ self ._props .pop ('icon' , None )
167
171
else :
168
- self ._props ['options' ][ ' icon' ] = value
172
+ self ._props ['icon' ] = value
169
173
self .update ()
170
174
171
175
@property
172
176
def spinner (self ) -> bool :
173
177
"""Whether the notification is a spinner."""
174
- return self ._props ['options' ][ ' spinner' ]
178
+ return self ._props ['spinner' ]
175
179
176
180
@spinner .setter
177
181
def spinner (self , value : bool ) -> None :
178
- self ._props ['options' ][ ' spinner' ] = value
182
+ self ._props ['spinner' ] = value
179
183
self .update ()
180
184
181
185
@property
182
186
def close_button (self ) -> Union [bool , str ]:
183
187
"""Whether the notification has a close button."""
184
- return self ._props ['options' ][ ' closeBtn' ]
188
+ return self ._props ['closeBtn' ]
185
189
186
190
@close_button .setter
187
191
def close_button (self , value : Union [bool , str ]) -> None :
188
- self ._props ['options' ][ ' closeBtn' ] = value
192
+ self ._props ['closeBtn' ] = value
189
193
self .update ()
190
194
191
195
def on_dismiss (self , callback : Handler [UiEventArguments ]) -> Self :
0 commit comments