Package Gnumed :: Package wxpython :: Module gmOrganizationWidgets
[frames] | no frames]

Source Code for Module Gnumed.wxpython.gmOrganizationWidgets

  1  """GNUmed organization handling widgets. 
  2   
  3  copyright: authors 
  4  """ 
  5  #============================================================ 
  6  __author__ = "K.Hilbert" 
  7  __license__ = "GPL v2 or later (details at http://www.gnu.org)" 
  8   
  9  import logging, sys 
 10   
 11   
 12  import wx 
 13   
 14   
 15  if __name__ == '__main__': 
 16          sys.path.insert(0, '../../') 
 17  from Gnumed.pycommon import gmTools 
 18  from Gnumed.pycommon import gmMatchProvider 
 19  from Gnumed.pycommon import gmDispatcher 
 20  from Gnumed.business import gmOrganization 
 21  from Gnumed.wxpython import gmListWidgets 
 22  from Gnumed.wxpython import gmEditArea 
 23  from Gnumed.wxpython import gmPhraseWheel 
 24  from Gnumed.wxpython import gmPersonContactWidgets 
 25  from Gnumed.wxpython import gmAddressWidgets 
 26  from Gnumed.wxpython import gmGuiHelpers 
 27   
 28   
 29  _log = logging.getLogger('gm.organization') 
 30   
 31  #============================================================ 
 32  # organizational units API 
 33  #------------------------------------------------------------ 
34 -def edit_org_unit(parent=None, org_unit=None, single_entry=False, org=None):
35 ea = cOrgUnitEAPnl(parent = parent, id = -1) 36 ea.data = org_unit 37 ea.mode = gmTools.coalesce(org_unit, 'new', 'edit') 38 dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea, single_entry = single_entry) 39 if org is not None: 40 ea.organization = org 41 dlg.SetTitle(gmTools.coalesce(org_unit, _('Adding new organizational unit'), _('Editing organizational unit'))) 42 if dlg.ShowModal() == wx.ID_OK: 43 dlg.Destroy() 44 return True 45 dlg.Destroy() 46 return False
47 #============================================================
48 -class cOrgUnitPhraseWheel(gmPhraseWheel.cPhraseWheel):
49
50 - def __init__(self, *args, **kwargs):
51 query = u""" 52 SELECT DISTINCT ON (data) * FROM ( 53 SELECT * FROM (( 54 55 SELECT 56 pk_org_unit 57 AS data, 58 unit || ' (' || l10n_unit_category || '): ' || organization || ' (' || l10n_organization_category || ')' 59 AS list_label, 60 unit || ' (' || organization || ')' 61 AS field_label 62 FROM 63 dem.v_org_units 64 WHERE 65 unit %(fragment_condition)s 66 67 ) UNION ALL ( 68 69 SELECT 70 pk_org_unit 71 AS data, 72 l10n_unit_category || ' "' || unit || '": ' || organization || ' (' || l10n_organization_category || ')' 73 AS list_label, 74 unit || ' (' || organization || ')' 75 AS field_label 76 FROM 77 dem.v_org_units 78 WHERE 79 l10n_unit_category %(fragment_condition)s 80 OR 81 unit_category %(fragment_condition)s 82 83 ) UNION ALL ( 84 85 SELECT 86 pk_org_unit 87 AS data, 88 organization || ': ' || unit || ' (' || l10n_unit_category || ')' 89 AS list_label, 90 unit || ' (' || organization || ')' 91 AS field_label 92 FROM 93 dem.v_org_units 94 WHERE 95 organization %(fragment_condition)s 96 97 )) AS all_matches 98 ORDER BY list_label 99 ) AS ordered_matches 100 LIMIT 50 101 """ 102 mp = gmMatchProvider.cMatchProvider_SQL2(queries=query) 103 mp.setThresholds(1, 3, 5) 104 gmPhraseWheel.cPhraseWheel.__init__(self, *args, **kwargs) 105 self.SetToolTipString(_("Select an organizational unit.")) 106 self.matcher = mp
107 108 #============================================================
109 -class cOrgUnitsManagerPnl(gmListWidgets.cGenericListManagerPnl):
110 """A list for managing organizational units.""" 111
112 - def __init__(self, *args, **kwargs):
113 114 try: 115 self.__org = kwargs['org'] 116 del kwargs['org'] 117 except KeyError: 118 self.__org = None 119 120 gmListWidgets.cGenericListManagerPnl.__init__(self, *args, **kwargs) 121 122 self.refresh_callback = self.refresh 123 self.new_callback = self._add 124 self.edit_callback = self._edit 125 self.delete_callback = self._del 126 127 self.__show_none_if_no_org = True 128 self.__init_ui() 129 self.__refresh()
130 #-------------------------------------------------------- 131 # external API 132 #--------------------------------------------------------
133 - def refresh(self, lctrl=None):
134 self.__refresh()
135 #-------------------------------------------------------- 136 # event handlers 137 #--------------------------------------------------------
138 - def _add(self):
139 return edit_org_unit(parent = self, org_unit = None, single_entry = False, org = self.__org)
140 #--------------------------------------------------------
141 - def _edit(self, item):
142 return edit_org_unit(parent = self, org_unit = item, single_entry = True)
143 #--------------------------------------------------------
144 - def _del(self, item):
145 return gmOrganization.delete_org_unit(unit = item['pk_org'])
146 #--------------------------------------------------------
147 - def _on_list_item_focused(self, event):
148 pass
149 #-------------------------------------------------------- 150 # internal helpers 151 #--------------------------------------------------------
152 - def __init_ui(self):
153 self._LCTRL_items.SetToolTipString(_('Units (sites, parts, departments, branches, ...) of organizations registered in GNUmed.')) 154 self._LCTRL_items.set_columns(columns = [ _('Organizational Unit'), _('Unit Category'), u'#' ])
155 #self._LCTRL_items.set_column_widths(widths = [wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE]) 156 #--------------------------------------------------------
157 - def __refresh(self):
158 159 msg_template = _('Units of: %s') 160 161 if self.__org is None: 162 self._BTN_add.Enable(False) 163 self._BTN_edit.Enable(False) 164 self._BTN_remove.Enable(False) 165 pk = None 166 self.message = msg_template % _('<no organization selected>') 167 if self.__show_none_if_no_org: 168 self._LCTRL_items.set_string_items(items = None) 169 return 170 else: 171 self._BTN_add.Enable(True) 172 pk = self.__org['pk_org'] 173 org_str = u'%s (%s)' % ( 174 self.__org['organization'], 175 self.__org['l10n_category'] 176 ) 177 self.message = msg_template % org_str 178 179 units = gmOrganization.get_org_units(order_by = 'unit, l10n_unit_category', org = pk) 180 items = [ [ 181 u['unit'], 182 gmTools.coalesce(u['l10n_unit_category'], u''), 183 u['pk_org_unit'] 184 ] for u in units ] 185 186 self._LCTRL_items.set_string_items(items) 187 self._LCTRL_items.set_data(units)
188 #-------------------------------------------------------- 189 # properties 190 #--------------------------------------------------------
191 - def _get_org(self):
192 return self.__org
193
194 - def _set_org(self, org):
195 self.__org = org 196 self.__refresh()
197 198 org = property(_get_org, _set_org) 199 #--------------------------------------------------------
200 - def _get_show_none_if_no_org(self):
201 return self.__show_none_if_no_org
202
203 - def _set_show_none_if_no_org(self, show_none_if_no_org):
204 if show_none_if_no_org == self.__show_none_if_no_org: 205 return 206 if show_none_if_no_org: 207 self.__show_none_if_no_org = True 208 else: 209 self.__show_none_if_no_org = False 210 self.__refresh()
211 212 show_none_if_no_org = property(_get_show_none_if_no_org, _set_show_none_if_no_org)
213 214 #============================================================ 215 # org unit edit area 216 from Gnumed.wxGladeWidgets import wxgOrgUnitEAPnl 217
218 -class cOrgUnitEAPnl(wxgOrgUnitEAPnl.wxgOrgUnitEAPnl, gmEditArea.cGenericEditAreaMixin):
219
220 - def __init__(self, *args, **kwargs):
221 222 try: 223 data = kwargs['unit'] 224 del kwargs['unit'] 225 except KeyError: 226 data = None 227 228 wxgOrgUnitEAPnl.wxgOrgUnitEAPnl.__init__(self, *args, **kwargs) 229 gmEditArea.cGenericEditAreaMixin.__init__(self) 230 231 self.mode = 'new' 232 self.data = data 233 if data is not None: 234 self.mode = 'edit'
235 236 # self.__init_ui() 237 #---------------------------------------------------------------- 238 # def __init_ui(self): 239 # pass 240 #---------------------------------------------------------------- 241 # generic Edit Area mixin API 242 #----------------------------------------------------------------
243 - def _valid_for_save(self):
244 validity = True 245 246 if self._PRW_category.GetData() is not None: 247 self._PRW_category.display_as_valid(True) 248 else: 249 if self._PRW_category.GetValue().strip() == u'': 250 self._PRW_category.display_as_valid(True) 251 else: 252 validity = False 253 self._PRW_category.display_as_valid(False) 254 self._PRW_category.SetFocus() 255 256 if self._PRW_unit.GetData() is not None: 257 self._PRW_unit.display_as_valid(True) 258 else: 259 if self._PRW_unit.GetValue().strip() != u'': 260 self._PRW_unit.display_as_valid(True) 261 else: 262 validity = False 263 self._PRW_unit.display_as_valid(False) 264 self._PRW_unit.SetFocus() 265 266 if self._PRW_org.GetData() is None: 267 validity = False 268 self._PRW_org.display_as_valid(False) 269 self._PRW_org.SetFocus() 270 else: 271 self._PRW_org.display_as_valid(True) 272 273 return validity
274 #----------------------------------------------------------------
275 - def _save_as_new(self):
276 data = gmOrganization.create_org_unit ( 277 pk_organization = self._PRW_org.GetData(), 278 unit = self._PRW_unit.GetValue().strip() 279 ) 280 data['pk_category_unit'] = self._PRW_category.GetData() 281 data.save() 282 283 self.data = data 284 return True
285 #----------------------------------------------------------------
286 - def _save_as_update(self):
287 self.data['pk_org'] = self._PRW_org.GetData() 288 self.data['unit'] = self._PRW_unit.GetValue().strip() 289 self.data['pk_category_unit'] = self._PRW_category.GetData() 290 self.data.save() 291 return True
292 #----------------------------------------------------------------
293 - def _refresh_as_new(self):
294 self._PRW_org.SetText(value = u'', data = None) 295 self._PRW_unit.SetText(value = u'', data = None) 296 self._PRW_category.SetText(value = u'', data = None) 297 298 self._PRW_unit.SetFocus()
299 #----------------------------------------------------------------
301 self._PRW_org.SetText(value = self.data['organization'], data = self.data['pk_org']) 302 self._PRW_unit.SetText(value = u'', data = None) 303 self._PRW_category.SetText(value = self.data['unit_category'], data = self.data['pk_category_unit']) 304 305 self._PRW_unit.SetFocus()
306 #----------------------------------------------------------------
307 - def _refresh_from_existing(self):
308 self._PRW_org.SetText(value = self.data['organization'], data = self.data['pk_org']) 309 self._PRW_unit.SetText(value = self.data['unit'], data = self.data['pk_org_unit']) 310 self._PRW_category.SetText(value = self.data['unit_category'], data = self.data['pk_category_unit']) 311 312 self._PRW_unit.SetFocus()
313 #----------------------------------------------------------------
314 - def _set_org(self, org):
315 self._PRW_org.SetText(value = org['organization'], data = org['pk_org'])
316 317 organization = property(lambda x:x, _set_org)
318 #============================================================ 319 from Gnumed.wxGladeWidgets import wxgOrgUnitAddressPnl 320
321 -class cOrgUnitAddressPnl(wxgOrgUnitAddressPnl.wxgOrgUnitAddressPnl):
322
323 - def __init__(self, *args, **kwargs):
324 325 wxgOrgUnitAddressPnl.wxgOrgUnitAddressPnl.__init__(self, *args, **kwargs) 326 327 self.__unit = None
328 #-------------------------------------------------------- 329 # internal helpers 330 #--------------------------------------------------------
331 - def __refresh(self):
332 if self.__unit is None: 333 self.message = _('<no unit selected>') 334 self._PRW_address_searcher.SetText(u'', None) 335 self._PRW_address_searcher.Enable(False) 336 self._PRW_address_searcher.display_as_disabled(True) 337 self._BTN_save_picked_address.Enable(False) 338 self._BTN_add_new_address.Enable(False) 339 else: 340 if self.__unit['l10n_unit_category'] is None: 341 cat = u'' 342 left_delim = u'' 343 right_delim = u'' 344 else: 345 cat = u'%s ' % self.__unit['l10n_unit_category'] 346 left_delim = gmTools.u_left_double_angle_quote 347 right_delim = gmTools.u_right_double_angle_quote 348 self.message = u'%s%s%s%s' % ( 349 cat, 350 left_delim, 351 self.__unit['unit'], 352 right_delim 353 ) 354 self._PRW_address_searcher.Enable(True) 355 self._PRW_address_searcher.address = self.__unit['pk_address'] 356 self._PRW_address_searcher.Enable(True) 357 self._PRW_address_searcher.display_as_disabled(False) 358 self._BTN_save_picked_address.Enable(True) 359 self._BTN_add_new_address.Enable(True)
360 #-------------------------------------------------------- 361 # event handlers 362 #--------------------------------------------------------
364 if self._PRW_address_searcher.GetData() is None: 365 if self._PRW_address_searcher.GetValue().strip() != u'': 366 gmDispatcher.send(signal = 'statustext', msg = _('Invalid address selection.')) 367 self._PRW_address_searcher.display_as_valid(False) 368 self._PRW_address_searcher.SetFocus() 369 return 370 371 self._PRW_address_searcher.display_as_valid(True) 372 373 self.__unit['pk_address'] = self._PRW_address_searcher.GetData() 374 self.__unit.save() 375 self.__refresh()
376 #--------------------------------------------------------
377 - def _on_add_new_address_button_pressed(self, event):
378 ea = gmAddressWidgets.cAddressEditAreaPnl(self, -1) 379 ea.address_holder = self.__unit 380 ea.type_is_editable = False 381 dlg = gmEditArea.cGenericEditAreaDlg(self, -1, edit_area = ea) 382 dlg.SetTitle(_('Adding new address')) 383 if dlg.ShowModal() != wx.ID_OK: 384 return False 385 self.__refresh() 386 return True
387 #--------------------------------------------------------
388 - def _on_manage_addresses_button_pressed(self, event):
389 picked_address = gmAddressWidgets.manage_addresses(parent = self) 390 if picked_address is None: 391 return 392 393 question = u'%s\n\n %s\n' % ( 394 _('Link the following address to the organizational unit ?'), 395 u'\n '.join(picked_address.format()) 396 ) 397 398 link_it = gmGuiHelpers.gm_show_question ( 399 title = _('Linking selected address'), 400 question = question 401 ) 402 if not link_it: 403 return 404 405 self._PRW_address_searcher.address = picked_address['pk_address'] 406 self._PRW_address_searcher.display_as_valid(True) 407 self.__unit['pk_address'] = self._PRW_address_searcher.GetData() 408 self.__unit.save()
409 #-------------------------------------------------------- 410 # properties 411 #--------------------------------------------------------
412 - def _get_unit(self):
413 return self.__unit
414
415 - def _set_unit(self, unit):
416 self.__unit = unit 417 self.__refresh()
418 419 unit = property(_get_unit, _set_unit) 420 #--------------------------------------------------------
421 - def _get_message(self):
422 return self._LBL_message.GetLabel()
423
424 - def _set_message(self, msg):
425 if msg is None: 426 self._LBL_message.Hide() 427 self._LBL_message.SetLabel(u'') 428 else: 429 self._LBL_message.SetLabel(msg) 430 self._LBL_message.Show() 431 self.Layout()
432 433 message = property(_get_message, _set_message)
434 #============================================================ 435 # organizations API 436 #------------------------------------------------------------
437 -def manage_orgs(parent=None):
438 439 if parent is None: 440 parent = wx.GetApp().GetTopWindow() 441 442 dlg = cOrganizationManagerDlg(parent, -1) 443 dlg.ShowModal()
444 #============================================================
445 -def edit_org(parent=None, org=None, single_entry=False):
446 ea = cOrganizationEAPnl(parent = parent, id = -1) 447 ea.data = org 448 ea.mode = gmTools.coalesce(org, 'new', 'edit') 449 dlg = gmEditArea.cGenericEditAreaDlg2(parent = parent, id = -1, edit_area = ea, single_entry = single_entry) 450 dlg.SetTitle(gmTools.coalesce(org, _('Adding new organization'), _('Editing organization'))) 451 if dlg.ShowModal() == wx.ID_OK: 452 dlg.Destroy() 453 return True 454 dlg.Destroy() 455 return False
456 #============================================================
457 -class cOrganizationPhraseWheel(gmPhraseWheel.cPhraseWheel):
458
459 - def __init__(self, *args, **kwargs):
460 query = u""" 461 SELECT DISTINCT ON (data) * FROM ( 462 SELECT * FROM (( 463 464 SELECT 465 pk_org 466 AS data, 467 organization || ' (' || l10n_category || ')' 468 AS list_label, 469 organization || ' (' || l10n_category || ')' 470 AS field_label 471 FROM 472 dem.v_orgs 473 WHERE 474 organization %(fragment_condition)s 475 476 ) UNION ALL ( 477 478 SELECT 479 pk_org 480 AS data, 481 l10n_category || ': ' || organization 482 AS list_label, 483 organization || ' (' || l10n_category || ')' 484 AS field_label 485 FROM 486 dem.v_orgs 487 WHERE 488 l10n_category %(fragment_condition)s 489 OR 490 category %(fragment_condition)s 491 492 )) AS all_matches 493 ORDER BY list_label 494 ) AS ordered_matches 495 LIMIT 50 496 """ 497 mp = gmMatchProvider.cMatchProvider_SQL2(queries=query) 498 mp.setThresholds(1, 3, 5) 499 gmPhraseWheel.cPhraseWheel.__init__(self, *args, **kwargs) 500 self.SetToolTipString(_("Select an organization.")) 501 self.matcher = mp 502 self.selection_only = True
503 504 #==================================================================== 505 from Gnumed.wxGladeWidgets import wxgOrganizationEAPnl 506
507 -class cOrganizationEAPnl(wxgOrganizationEAPnl.wxgOrganizationEAPnl, gmEditArea.cGenericEditAreaMixin):
508
509 - def __init__(self, *args, **kwargs):
510 511 try: 512 data = kwargs['organization'] 513 del kwargs['organization'] 514 except KeyError: 515 data = None 516 517 wxgOrganizationEAPnl.wxgOrganizationEAPnl.__init__(self, *args, **kwargs) 518 gmEditArea.cGenericEditAreaMixin.__init__(self) 519 520 self.mode = 'new' 521 self.data = data 522 if data is not None: 523 self.mode = 'edit'
524 525 #self.__init_ui() 526 #----------------------------------------------------------------
527 - def __init_ui(self):
528 self._PRW_org.selection_only = False
529 #---------------------------------------------------------------- 530 # generic Edit Area mixin API 531 #----------------------------------------------------------------
532 - def _valid_for_save(self):
533 validity = True 534 535 if self._PRW_category.GetData() is None: 536 validity = False 537 self._PRW_category.display_as_valid(False) 538 self._PRW_category.SetFocus() 539 else: 540 self._PRW_category.display_as_valid(True) 541 542 if self.mode == 'edit': 543 if self._PRW_org.GetData() is None: 544 validity = False 545 self._PRW_org.display_as_valid(False) 546 self._PRW_org.SetFocus() 547 else: 548 self._PRW_org.display_as_valid(True) 549 else: 550 if self._PRW_org.GetValue().strip() == u'': 551 validity = False 552 self._PRW_org.display_as_valid(False) 553 self._PRW_org.SetFocus() 554 else: 555 if self._PRW_org.GetData() is not None: 556 validity = False 557 self._PRW_org.display_as_valid(False) 558 self._PRW_org.SetFocus() 559 else: 560 self._PRW_org.display_as_valid(True) 561 562 return validity
563 #----------------------------------------------------------------
564 - def _save_as_new(self):
565 self.data = gmOrganization.create_org ( 566 organization = self._PRW_org.GetValue().strip(), 567 category = self._PRW_category.GetData() 568 ) 569 return True
570 #----------------------------------------------------------------
571 - def _save_as_update(self):
572 self.data['pk_org'] = self._PRW_org.GetData() 573 self.data['pk_category_org'] = self._PRW_category.GetData() 574 self.data.save() 575 return True
576 #----------------------------------------------------------------
577 - def _refresh_as_new(self):
578 self._PRW_org.SetText(value = u'', data = None) 579 self._PRW_category.SetText(value = u'', data = None) 580 581 self._PRW_org.SetFocus()
582 #----------------------------------------------------------------
584 self._PRW_org.SetText(value = u'', data = None) 585 self._PRW_category.SetText(value = self.data['l10n_category'], data = self.data['pk_category_org']) 586 587 self._PRW_org.SetFocus()
588 #----------------------------------------------------------------
589 - def _refresh_from_existing(self):
590 self._PRW_org.SetText(value = self.data['organization'], data = self.data['pk_org']) 591 self._PRW_category.SetText(value = self.data['l10n_category'], data = self.data['pk_category_org']) 592 593 self._PRW_category.SetFocus()
594 595 #============================================================
596 -class cOrgCategoryPhraseWheel(gmPhraseWheel.cPhraseWheel):
597
598 - def __init__(self, *args, **kwargs):
599 query = u""" 600 SELECT DISTINCT ON (data) 601 * 602 FROM ( 603 SELECT 604 pk 605 AS data, 606 _(description) || ' (' || description || ')' 607 AS list_label, 608 _(description) 609 AS field_label 610 FROM 611 dem.org_category 612 WHERE 613 _(description) %(fragment_condition)s 614 OR 615 description %(fragment_condition)s 616 ORDER BY list_label 617 ) AS ordered_matches 618 LIMIT 50 619 """ 620 mp = gmMatchProvider.cMatchProvider_SQL2(queries=query) 621 mp.setThresholds(1, 3, 5) 622 gmPhraseWheel.cPhraseWheel.__init__(self, *args, **kwargs) 623 self.SetToolTipString(_("Select an organizational category.")) 624 self.matcher = mp 625 self.selection_only = True
626 627 #============================================================
628 -class cOrganizationsManagerPnl(gmListWidgets.cGenericListManagerPnl):
629 """A list for managing organizations.""" 630
631 - def __init__(self, *args, **kwargs):
632 633 gmListWidgets.cGenericListManagerPnl.__init__(self, *args, **kwargs) 634 635 self.refresh_callback = self.refresh 636 self.new_callback = self._add 637 self.edit_callback = self._edit 638 self.delete_callback = self._del 639 640 self.__init_ui() 641 self.refresh()
642 #-------------------------------------------------------- 643 # external API 644 #--------------------------------------------------------
645 - def refresh(self, lctrl=None):
646 orgs = gmOrganization.get_orgs(order_by = 'organization, l10n_category') 647 items = [ [o['organization'], o['l10n_category'], o['pk_org']] for o in orgs ] 648 self._LCTRL_items.set_string_items(items) 649 self._LCTRL_items.set_data(orgs)
650 #-------------------------------------------------------- 651 # event handlers 652 #--------------------------------------------------------
653 - def _add(self):
654 return edit_org(parent = self, org = None, single_entry = False)
655 #--------------------------------------------------------
656 - def _edit(self, item):
657 return edit_org(parent = self, org = item, single_entry = True)
658 #--------------------------------------------------------
659 - def _del(self, item):
660 return gmOrganization.delete_org(organization = item['pk_org'])
661 #--------------------------------------------------------
662 - def _on_list_item_focused(self, event):
663 pass
664 #-------------------------------------------------------- 665 # internal helpers 666 #--------------------------------------------------------
667 - def __init_ui(self):
668 self._LCTRL_items.SetToolTipString(_('Organizations registered in GNUmed.')) 669 self._LCTRL_items.set_columns(columns = [_('Organization'), _('Category'), u'#'])
670 #self._LCTRL_items.set_column_widths(widths = [wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE, wx.LIST_AUTOSIZE]) 671 #============================================================ 672 from Gnumed.wxGladeWidgets import wxgOrganizationManagerDlg 673
674 -class cOrganizationManagerDlg(wxgOrganizationManagerDlg.wxgOrganizationManagerDlg):
675
676 - def __init__(self, *args, **kwargs):
677 678 wxgOrganizationManagerDlg.wxgOrganizationManagerDlg.__init__(self, *args, **kwargs) 679 680 self.Centre(direction = wx.BOTH) 681 682 self._PNL_address.type_is_editable = False 683 self._PNL_orgs.select_callback = self._on_org_selected 684 self._PNL_units.select_callback = self._on_unit_selected 685 self._PNL_comms.message = _('Communication channels') 686 687 # FIXME: find proper button 688 #self._PNL_units.MoveAfterInTabOrder(self._PNL_orgs._BTN_) 689 690 self._on_org_selected(None) 691 self._PNL_orgs._LCTRL_items.SetFocus()
692 #-------------------------------------------------------- 693 # event handlers 694 #--------------------------------------------------------
695 - def _on_org_selected(self, item):
696 self._PNL_units.org = item 697 self._on_unit_selected(None)
698 #--------------------------------------------------------
699 - def _on_unit_selected(self, item):
700 self._PNL_address.unit = item 701 self._PNL_comms.channel_owner = item 702 if item is None: 703 self._PNL_comms._BTN_add.Enable(False) 704 else: 705 self._PNL_comms._BTN_add.Enable(True)
706 #============================================================ 707 # main 708 #------------------------------------------------------------ 709 if __name__ == "__main__": 710 711 if len(sys.argv) < 2: 712 sys.exit() 713 714 if sys.argv[1] != u'test': 715 sys.exit() 716 717 from Gnumed.pycommon import gmPG2 718 from Gnumed.pycommon import gmI18N 719 gmI18N.activate_locale() 720 gmI18N.install_domain() 721 722 #--------------------------------------------------------
723 - def test_org_prw():
724 app = wx.PyWidgetTester(size = (200, 50)) 725 pw = cOrganizationPhraseWheel(app.frame, -1) 726 app.frame.Show(True) 727 app.MainLoop()
728 #--------------------------------------------------------
729 - def test_org_unit_prw():
730 app = wx.PyWidgetTester(size = (200, 50)) 731 pw = cOrgUnitPhraseWheel(app.frame, -1) 732 app.frame.Show(True) 733 app.MainLoop()
734 #--------------------------------------------------------
735 - def test():
736 conn = gmPG2.get_connection() 737 app = wx.PyWidgetTester(size = (600, 600)) 738 dlg = cOrganizationManagerDlg(app.frame, -1, size = (600, 600)) 739 dlg.SetSize((600, 600)) 740 dlg.ShowModal() 741 # app.SetWidget(dlg, -1) 742 app.MainLoop()
743 #-------------------------------------------------------- 744 #test_org_unit_prw() 745 #test_org_prw() 746 test() 747 748 #====================================================================== 749