comparison sat_frontends/primitivus/xmlui.py @ 4037:524856bd7b19

massive refactoring to switch from camelCase to snake_case: historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:54:42 +0200
parents be6d91572633
children 4b842c1fb686
comparison
equal deleted inserted replaced
4036:c4464d7ae97b 4037:524856bd7b19
36 36
37 def _event_callback(self, ctrl, *args, **kwargs): 37 def _event_callback(self, ctrl, *args, **kwargs):
38 """" Call xmlui callback and ignore any extra argument """ 38 """" Call xmlui callback and ignore any extra argument """
39 args[-1](ctrl) 39 args[-1](ctrl)
40 40
41 def _xmluiOnChange(self, callback): 41 def _xmlui_on_change(self, callback):
42 """ Call callback with widget as only argument """ 42 """ Call callback with widget as only argument """
43 urwid.connect_signal(self, "change", self._event_callback, callback) 43 urwid.connect_signal(self, "change", self._event_callback, callback)
44 44
45 45
46 class PrimitivusEmptyWidget(xmlui.EmptyWidget, urwid.Text): 46 class PrimitivusEmptyWidget(xmlui.EmptyWidget, urwid.Text):
91 def selectable(self): 91 def selectable(self):
92 if self.read_only: 92 if self.read_only:
93 return False 93 return False
94 return super(PrimitivusStringWidget, self).selectable() 94 return super(PrimitivusStringWidget, self).selectable()
95 95
96 def _xmluiSetValue(self, value): 96 def _xmlui_set_value(self, value):
97 self.set_edit_text(value) 97 self.set_edit_text(value)
98 98
99 def _xmluiGetValue(self): 99 def _xmlui_get_value(self):
100 return self.get_edit_text() 100 return self.get_edit_text()
101 101
102 102
103 class PrimitivusJidInputWidget(xmlui.JidInputWidget, PrimitivusStringWidget): 103 class PrimitivusJidInputWidget(xmlui.JidInputWidget, PrimitivusStringWidget):
104 pass 104 pass
114 def selectable(self): 114 def selectable(self):
115 if self.read_only: 115 if self.read_only:
116 return False 116 return False
117 return super(PrimitivusPasswordWidget, self).selectable() 117 return super(PrimitivusPasswordWidget, self).selectable()
118 118
119 def _xmluiSetValue(self, value): 119 def _xmlui_set_value(self, value):
120 self.set_edit_text(value) 120 self.set_edit_text(value)
121 121
122 def _xmluiGetValue(self): 122 def _xmlui_get_value(self):
123 return self.get_edit_text() 123 return self.get_edit_text()
124 124
125 125
126 class PrimitivusTextBoxWidget( 126 class PrimitivusTextBoxWidget(
127 xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents 127 xmlui.TextBoxWidget, sat_widgets.AdvancedEdit, PrimitivusEvents
133 def selectable(self): 133 def selectable(self):
134 if self.read_only: 134 if self.read_only:
135 return False 135 return False
136 return super(PrimitivusTextBoxWidget, self).selectable() 136 return super(PrimitivusTextBoxWidget, self).selectable()
137 137
138 def _xmluiSetValue(self, value): 138 def _xmlui_set_value(self, value):
139 self.set_edit_text(value) 139 self.set_edit_text(value)
140 140
141 def _xmluiGetValue(self): 141 def _xmlui_get_value(self):
142 return self.get_edit_text() 142 return self.get_edit_text()
143 143
144 144
145 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents): 145 class PrimitivusBoolWidget(xmlui.BoolWidget, urwid.CheckBox, PrimitivusEvents):
146 def __init__(self, _xmlui_parent, state, read_only=False): 146 def __init__(self, _xmlui_parent, state, read_only=False):
150 def selectable(self): 150 def selectable(self):
151 if self.read_only: 151 if self.read_only:
152 return False 152 return False
153 return super(PrimitivusBoolWidget, self).selectable() 153 return super(PrimitivusBoolWidget, self).selectable()
154 154
155 def _xmluiSetValue(self, value): 155 def _xmlui_set_value(self, value):
156 self.set_state(value == "true") 156 self.set_state(value == "true")
157 157
158 def _xmluiGetValue(self): 158 def _xmlui_get_value(self):
159 return C.BOOL_TRUE if self.get_state() else C.BOOL_FALSE 159 return C.BOOL_TRUE if self.get_state() else C.BOOL_FALSE
160 160
161 161
162 class PrimitivusIntWidget(xmlui.IntWidget, sat_widgets.AdvancedEdit, PrimitivusEvents): 162 class PrimitivusIntWidget(xmlui.IntWidget, sat_widgets.AdvancedEdit, PrimitivusEvents):
163 def __init__(self, _xmlui_parent, value, read_only=False): 163 def __init__(self, _xmlui_parent, value, read_only=False):
167 def selectable(self): 167 def selectable(self):
168 if self.read_only: 168 if self.read_only:
169 return False 169 return False
170 return super(PrimitivusIntWidget, self).selectable() 170 return super(PrimitivusIntWidget, self).selectable()
171 171
172 def _xmluiSetValue(self, value): 172 def _xmlui_set_value(self, value):
173 self.set_edit_text(value) 173 self.set_edit_text(value)
174 174
175 def _xmluiGetValue(self): 175 def _xmlui_get_value(self):
176 return self.get_edit_text() 176 return self.get_edit_text()
177 177
178 178
179 class PrimitivusButtonWidget( 179 class PrimitivusButtonWidget(
180 xmlui.ButtonWidget, sat_widgets.CustomButton, PrimitivusEvents 180 xmlui.ButtonWidget, sat_widgets.CustomButton, PrimitivusEvents
181 ): 181 ):
182 def __init__(self, _xmlui_parent, value, click_callback): 182 def __init__(self, _xmlui_parent, value, click_callback):
183 sat_widgets.CustomButton.__init__(self, value, on_press=click_callback) 183 sat_widgets.CustomButton.__init__(self, value, on_press=click_callback)
184 184
185 def _xmluiOnClick(self, callback): 185 def _xmlui_on_click(self, callback):
186 urwid.connect_signal(self, "click", callback) 186 urwid.connect_signal(self, "click", callback)
187 187
188 188
189 class PrimitivusListWidget(xmlui.ListWidget, sat_widgets.List, PrimitivusEvents): 189 class PrimitivusListWidget(xmlui.ListWidget, sat_widgets.List, PrimitivusEvents):
190 def __init__(self, _xmlui_parent, options, selected, flags): 190 def __init__(self, _xmlui_parent, options, selected, flags):
191 sat_widgets.List.__init__(self, options=options, style=flags) 191 sat_widgets.List.__init__(self, options=options, style=flags)
192 self._xmluiSelectValues(selected) 192 self._xmlui_select_values(selected)
193 193
194 def _xmluiSelectValue(self, value): 194 def _xmlui_select_value(self, value):
195 return self.selectValue(value) 195 return self.select_value(value)
196 196
197 def _xmluiSelectValues(self, values): 197 def _xmlui_select_values(self, values):
198 return self.selectValues(values) 198 return self.select_values(values)
199 199
200 def _xmluiGetSelectedValues(self): 200 def _xmlui_get_selected_values(self):
201 return [option.value for option in self.getSelectedValues()] 201 return [option.value for option in self.get_selected_values()]
202 202
203 def _xmluiAddValues(self, values, select=True): 203 def _xmlui_add_values(self, values, select=True):
204 current_values = self.getAllValues() 204 current_values = self.get_all_values()
205 new_values = copy.deepcopy(current_values) 205 new_values = copy.deepcopy(current_values)
206 for value in values: 206 for value in values:
207 if value not in current_values: 207 if value not in current_values:
208 new_values.append(value) 208 new_values.append(value)
209 if select: 209 if select:
210 selected = self._xmluiGetSelectedValues() 210 selected = self._xmlui_get_selected_values()
211 self.changeValues(new_values) 211 self.change_values(new_values)
212 if select: 212 if select:
213 for value in values: 213 for value in values:
214 if value not in selected: 214 if value not in selected:
215 selected.append(value) 215 selected.append(value)
216 self._xmluiSelectValues(selected) 216 self._xmlui_select_values(selected)
217 217
218 218
219 class PrimitivusJidsListWidget(xmlui.ListWidget, sat_widgets.List, PrimitivusEvents): 219 class PrimitivusJidsListWidget(xmlui.ListWidget, sat_widgets.List, PrimitivusEvents):
220 def __init__(self, _xmlui_parent, jids, styles): 220 def __init__(self, _xmlui_parent, jids, styles):
221 sat_widgets.List.__init__( 221 sat_widgets.List.__init__(
222 self, 222 self,
223 options=jids + [""], # the empty field is here to add new jids if needed 223 options=jids + [""], # the empty field is here to add new jids if needed
224 option_type=lambda txt, align: sat_widgets.AdvancedEdit( 224 option_type=lambda txt, align: sat_widgets.AdvancedEdit(
225 edit_text=txt, align=align 225 edit_text=txt, align=align
226 ), 226 ),
227 on_change=self._onChange, 227 on_change=self._on_change,
228 ) 228 )
229 self.delete = 0 229 self.delete = 0
230 230
231 def _onChange(self, list_widget, jid_widget=None, text=None): 231 def _on_change(self, list_widget, jid_widget=None, text=None):
232 if jid_widget is not None: 232 if jid_widget is not None:
233 if jid_widget != list_widget.contents[-1] and not text: 233 if jid_widget != list_widget.contents[-1] and not text:
234 # if a field is empty, we delete the line (except for the last line) 234 # if a field is empty, we delete the line (except for the last line)
235 list_widget.contents.remove(jid_widget) 235 list_widget.contents.remove(jid_widget)
236 elif jid_widget == list_widget.contents[-1] and text: 236 elif jid_widget == list_widget.contents[-1] and text:
237 # we always want an empty field as last value to be able to add jids 237 # we always want an empty field as last value to be able to add jids
238 list_widget.contents.append(sat_widgets.AdvancedEdit()) 238 list_widget.contents.append(sat_widgets.AdvancedEdit())
239 239
240 def _xmluiGetSelectedValues(self): 240 def _xmlui_get_selected_values(self):
241 # XXX: there is not selection in this list, so we return all non empty values 241 # XXX: there is not selection in this list, so we return all non empty values
242 return [jid_ for jid_ in self.getAllValues() if jid_] 242 return [jid_ for jid_ in self.get_all_values() if jid_]
243 243
244 244
245 class PrimitivusAdvancedListContainer( 245 class PrimitivusAdvancedListContainer(
246 xmlui.AdvancedListContainer, sat_widgets.TableContainer, PrimitivusEvents 246 xmlui.AdvancedListContainer, sat_widgets.TableContainer, PrimitivusEvents
247 ): 247 ):
251 options["HIGHLIGHT"] = () 251 options["HIGHLIGHT"] = ()
252 sat_widgets.TableContainer.__init__( 252 sat_widgets.TableContainer.__init__(
253 self, columns=columns, options=options, row_selectable=selectable != "no" 253 self, columns=columns, options=options, row_selectable=selectable != "no"
254 ) 254 )
255 255
256 def _xmluiAppend(self, widget): 256 def _xmlui_append(self, widget):
257 self.addWidget(widget) 257 self.add_widget(widget)
258 258
259 def _xmluiAddRow(self, idx): 259 def _xmlui_add_row(self, idx):
260 self.setRowIndex(idx) 260 self.set_row_index(idx)
261 261
262 def _xmluiGetSelectedWidgets(self): 262 def _xmlui_get_selected_widgets(self):
263 return self.getSelectedWidgets() 263 return self.get_selected_widgets()
264 264
265 def _xmluiGetSelectedIndex(self): 265 def _xmlui_get_selected_index(self):
266 return self.getSelectedIndex() 266 return self.get_selected_index()
267 267
268 def _xmluiOnSelect(self, callback): 268 def _xmlui_on_select(self, callback):
269 """ Call callback with widget as only argument """ 269 """ Call callback with widget as only argument """
270 urwid.connect_signal(self, "click", self._event_callback, callback) 270 urwid.connect_signal(self, "click", self._event_callback, callback)
271 271
272 272
273 class PrimitivusPairsContainer(xmlui.PairsContainer, sat_widgets.TableContainer): 273 class PrimitivusPairsContainer(xmlui.PairsContainer, sat_widgets.TableContainer):
275 options = {"ADAPT": (0,), "HIGHLIGHT": (0,)} 275 options = {"ADAPT": (0,), "HIGHLIGHT": (0,)}
276 if self._xmlui_main.type == "param": 276 if self._xmlui_main.type == "param":
277 options["FOCUS_ATTR"] = "param_selected" 277 options["FOCUS_ATTR"] = "param_selected"
278 sat_widgets.TableContainer.__init__(self, columns=2, options=options) 278 sat_widgets.TableContainer.__init__(self, columns=2, options=options)
279 279
280 def _xmluiAppend(self, widget): 280 def _xmlui_append(self, widget):
281 if isinstance(widget, PrimitivusEmptyWidget): 281 if isinstance(widget, PrimitivusEmptyWidget):
282 # we don't want highlight on empty widgets 282 # we don't want highlight on empty widgets
283 widget = urwid.AttrMap(widget, "default") 283 widget = urwid.AttrMap(widget, "default")
284 self.addWidget(widget) 284 self.add_widget(widget)
285 285
286 286
287 class PrimitivusLabelContainer(PrimitivusPairsContainer, xmlui.LabelContainer): 287 class PrimitivusLabelContainer(PrimitivusPairsContainer, xmlui.LabelContainer):
288 pass 288 pass
289 289
290 290
291 class PrimitivusTabsContainer(xmlui.TabsContainer, sat_widgets.TabsContainer): 291 class PrimitivusTabsContainer(xmlui.TabsContainer, sat_widgets.TabsContainer):
292 def __init__(self, _xmlui_parent): 292 def __init__(self, _xmlui_parent):
293 sat_widgets.TabsContainer.__init__(self) 293 sat_widgets.TabsContainer.__init__(self)
294 294
295 def _xmluiAppend(self, widget): 295 def _xmlui_append(self, widget):
296 self.body.append(widget) 296 self.body.append(widget)
297 297
298 def _xmluiAddTab(self, label, selected): 298 def _xmlui_add_tab(self, label, selected):
299 tab = PrimitivusVerticalContainer(None) 299 tab = PrimitivusVerticalContainer(None)
300 self.addTab(label, tab, selected) 300 self.add_tab(label, tab, selected)
301 return tab 301 return tab
302 302
303 303
304 class PrimitivusVerticalContainer(xmlui.VerticalContainer, urwid.ListBox): 304 class PrimitivusVerticalContainer(xmlui.VerticalContainer, urwid.ListBox):
305 BOX_HEIGHT = 5 305 BOX_HEIGHT = 5
306 306
307 def __init__(self, _xmlui_parent): 307 def __init__(self, _xmlui_parent):
308 urwid.ListBox.__init__(self, urwid.SimpleListWalker([])) 308 urwid.ListBox.__init__(self, urwid.SimpleListWalker([]))
309 self._last_size = None 309 self._last_size = None
310 310
311 def _xmluiAppend(self, widget): 311 def _xmlui_append(self, widget):
312 if "flow" not in widget.sizing(): 312 if "flow" not in widget.sizing():
313 widget = urwid.BoxAdapter(widget, self.BOX_HEIGHT) 313 widget = urwid.BoxAdapter(widget, self.BOX_HEIGHT)
314 self.body.append(widget) 314 self.body.append(widget)
315 315
316 def render(self, size, focus=False): 316 def render(self, size, focus=False):
329 329
330 class PrimitivusDialog(object): 330 class PrimitivusDialog(object):
331 def __init__(self, _xmlui_parent): 331 def __init__(self, _xmlui_parent):
332 self.host = _xmlui_parent.host 332 self.host = _xmlui_parent.host
333 333
334 def _xmluiShow(self): 334 def _xmlui_show(self):
335 self.host.showPopUp(self) 335 self.host.show_pop_up(self)
336 336
337 def _xmluiClose(self): 337 def _xmlui_close(self):
338 self.host.removePopUp(self) 338 self.host.remove_pop_up(self)
339 339
340 340
341 class PrimitivusMessageDialog(PrimitivusDialog, xmlui.MessageDialog, sat_widgets.Alert): 341 class PrimitivusMessageDialog(PrimitivusDialog, xmlui.MessageDialog, sat_widgets.Alert):
342 def __init__(self, _xmlui_parent, title, message, level): 342 def __init__(self, _xmlui_parent, title, message, level):
343 PrimitivusDialog.__init__(self, _xmlui_parent) 343 PrimitivusDialog.__init__(self, _xmlui_parent)
344 xmlui.MessageDialog.__init__(self, _xmlui_parent) 344 xmlui.MessageDialog.__init__(self, _xmlui_parent)
345 sat_widgets.Alert.__init__( 345 sat_widgets.Alert.__init__(
346 self, title, message, ok_cb=lambda __: self._xmluiClose() 346 self, title, message, ok_cb=lambda __: self._xmlui_close()
347 ) 347 )
348 348
349 349
350 class PrimitivusNoteDialog(xmlui.NoteDialog, PrimitivusMessageDialog): 350 class PrimitivusNoteDialog(xmlui.NoteDialog, PrimitivusMessageDialog):
351 # TODO: separate NoteDialog 351 # TODO: separate NoteDialog
360 xmlui.ConfirmDialog.__init__(self, _xmlui_parent) 360 xmlui.ConfirmDialog.__init__(self, _xmlui_parent)
361 sat_widgets.ConfirmDialog.__init__( 361 sat_widgets.ConfirmDialog.__init__(
362 self, 362 self,
363 title, 363 title,
364 message, 364 message,
365 no_cb=lambda __: self._xmluiCancelled(), 365 no_cb=lambda __: self._xmlui_cancelled(),
366 yes_cb=lambda __: self._xmluiValidated(), 366 yes_cb=lambda __: self._xmlui_validated(),
367 ) 367 )
368 368
369 369
370 class PrimitivusFileDialog( 370 class PrimitivusFileDialog(
371 PrimitivusDialog, xmlui.FileDialog, files_management.FileDialog 371 PrimitivusDialog, xmlui.FileDialog, files_management.FileDialog
377 style = [] 377 style = []
378 if filetype == C.XMLUI_DATA_FILETYPE_DIR: 378 if filetype == C.XMLUI_DATA_FILETYPE_DIR:
379 style.append("dir") 379 style.append("dir")
380 files_management.FileDialog.__init__( 380 files_management.FileDialog.__init__(
381 self, 381 self,
382 ok_cb=lambda path: self._xmluiValidated({"path": path}), 382 ok_cb=lambda path: self._xmlui_validated({"path": path}),
383 cancel_cb=lambda __: self._xmluiCancelled(), 383 cancel_cb=lambda __: self._xmlui_cancelled(),
384 message=message, 384 message=message,
385 title=title, 385 title=title,
386 style=style, 386 style=style,
387 ) 387 )
388 388
431 profile=profile, 431 profile=profile,
432 ) 432 )
433 PrimitivusWidget.__init__(self, self.main_cont, self.xmlui_title) 433 PrimitivusWidget.__init__(self, self.main_cont, self.xmlui_title)
434 434
435 435
436 def _parseChilds(self, _xmlui_parent, current_node, wanted=("container",), data=None): 436 def _parse_childs(self, _xmlui_parent, current_node, wanted=("container",), data=None):
437 # Small hack to always have a VerticalContainer as main container in Primitivus. 437 # Small hack to always have a VerticalContainer as main container in Primitivus.
438 # this used to be the default behaviour for all frontends, but now 438 # this used to be the default behaviour for all frontends, but now
439 # TabsContainer can also be the main container. 439 # TabsContainer can also be the main container.
440 if _xmlui_parent is self: 440 if _xmlui_parent is self:
441 node = current_node.childNodes[0] 441 node = current_node.childNodes[0]
442 if node.nodeName == "container" and node.getAttribute("type") == "tabs": 442 if node.nodeName == "container" and node.getAttribute("type") == "tabs":
443 _xmlui_parent = self.widget_factory.createVerticalContainer(self) 443 _xmlui_parent = self.widget_factory.createVerticalContainer(self)
444 self.main_cont = _xmlui_parent 444 self.main_cont = _xmlui_parent
445 return super(XMLUIPanel, self)._parseChilds(_xmlui_parent, current_node, wanted, 445 return super(XMLUIPanel, self)._parse_childs(_xmlui_parent, current_node, wanted,
446 data) 446 data)
447 447
448 448
449 def constructUI(self, parsed_dom): 449 def construct_ui(self, parsed_dom):
450 def postTreat(): 450 def post_treat():
451 assert self.main_cont.body 451 assert self.main_cont.body
452 452
453 if self.type in ("form", "popup"): 453 if self.type in ("form", "popup"):
454 buttons = [] 454 buttons = []
455 if self.type == "form": 455 if self.type == "form":
456 buttons.append(urwid.Button(_("Submit"), self.onFormSubmitted)) 456 buttons.append(urwid.Button(_("Submit"), self.on_form_submitted))
457 if not "NO_CANCEL" in self.flags: 457 if not "NO_CANCEL" in self.flags:
458 buttons.append(urwid.Button(_("Cancel"), self.onFormCancelled)) 458 buttons.append(urwid.Button(_("Cancel"), self.on_form_cancelled))
459 else: 459 else:
460 buttons.append( 460 buttons.append(
461 urwid.Button(_("OK"), on_press=lambda __: self._xmluiClose()) 461 urwid.Button(_("OK"), on_press=lambda __: self._xmlui_close())
462 ) 462 )
463 max_len = max([len(button.get_label()) for button in buttons]) 463 max_len = max([len(button.get_label()) for button in buttons])
464 grid_wid = urwid.GridFlow(buttons, max_len + 4, 1, 0, "center") 464 grid_wid = urwid.GridFlow(buttons, max_len + 4, 1, 0, "center")
465 self.main_cont.body.append(grid_wid) 465 self.main_cont.body.append(grid_wid)
466 elif self.type == "param": 466 elif self.type == "param":
467 tabs_cont = self.main_cont.body[0].base_widget 467 tabs_cont = self.main_cont.body[0].base_widget
468 assert isinstance(tabs_cont, sat_widgets.TabsContainer) 468 assert isinstance(tabs_cont, sat_widgets.TabsContainer)
469 buttons = [] 469 buttons = []
470 buttons.append(sat_widgets.CustomButton(_("Save"), self.onSaveParams)) 470 buttons.append(sat_widgets.CustomButton(_("Save"), self.on_save_params))
471 buttons.append( 471 buttons.append(
472 sat_widgets.CustomButton( 472 sat_widgets.CustomButton(
473 _("Cancel"), lambda x: self.host.removeWindow() 473 _("Cancel"), lambda x: self.host.remove_window()
474 ) 474 )
475 ) 475 )
476 max_len = max([button.getSize() for button in buttons]) 476 max_len = max([button.get_size() for button in buttons])
477 grid_wid = urwid.GridFlow(buttons, max_len, 1, 0, "center") 477 grid_wid = urwid.GridFlow(buttons, max_len, 1, 0, "center")
478 tabs_cont.addFooter(grid_wid) 478 tabs_cont.add_footer(grid_wid)
479 479
480 xmlui.XMLUIPanel.constructUI(self, parsed_dom, postTreat) 480 xmlui.XMLUIPanel.construct_ui(self, parsed_dom, post_treat)
481 urwid.WidgetWrap.__init__(self, self.main_cont) 481 urwid.WidgetWrap.__init__(self, self.main_cont)
482 482
483 def show(self, show_type=None, valign="middle"): 483 def show(self, show_type=None, valign="middle"):
484 """Show the constructed UI 484 """Show the constructed UI
485 @param show_type: how to show the UI: 485 @param show_type: how to show the UI:
499 if show_type not in ("popup", "window"): 499 if show_type not in ("popup", "window"):
500 raise ValueError("Invalid show_type [%s]" % show_type) 500 raise ValueError("Invalid show_type [%s]" % show_type)
501 501
502 self._dest = show_type 502 self._dest = show_type
503 if show_type == "popup": 503 if show_type == "popup":
504 self.host.showPopUp(self, valign=valign) 504 self.host.show_pop_up(self, valign=valign)
505 elif show_type == "window": 505 elif show_type == "window":
506 self.host.newWidget(self, user_action=self.user_action) 506 self.host.new_widget(self, user_action=self.user_action)
507 else: 507 else:
508 assert False 508 assert False
509 self.host.redraw() 509 self.host.redraw()
510 510
511 def _xmluiClose(self): 511 def _xmlui_close(self):
512 if self._dest == "window": 512 if self._dest == "window":
513 self.host.removeWindow() 513 self.host.remove_window()
514 elif self._dest == "popup": 514 elif self._dest == "popup":
515 self.host.removePopUp(self) 515 self.host.remove_pop_up(self)
516 else: 516 else:
517 raise exceptions.InternalError( 517 raise exceptions.InternalError(
518 "self._dest unknown, are you sure you have called XMLUI.show ?" 518 "self._dest unknown, are you sure you have called XMLUI.show ?"
519 ) 519 )
520 520
521 521
522 class XMLUIDialog(xmlui.XMLUIDialog): 522 class XMLUIDialog(xmlui.XMLUIDialog):
523 dialog_factory = GenericFactory() 523 dialog_factory = GenericFactory()
524 524
525 525
526 xmlui.registerClass(xmlui.CLASS_PANEL, XMLUIPanel) 526 xmlui.register_class(xmlui.CLASS_PANEL, XMLUIPanel)
527 xmlui.registerClass(xmlui.CLASS_DIALOG, XMLUIDialog) 527 xmlui.register_class(xmlui.CLASS_DIALOG, XMLUIDialog)
528 create = xmlui.create 528 create = xmlui.create