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.business import gmOrganization
19 from Gnumed.wxpython import gmListWidgets
20
21
22
23
24
25
26
27 _log = logging.getLogger('gm.organization')
28
29
31
32 if parent is None:
33 parent = wx.GetApp().GetTopWindow()
34
35 def refresh(lctrl):
36 units = gmOrganization.get_org_units(order_by = 'organization, l10n_unit_category, unit')
37
38 items = [ [
39 gmTools.coalesce (
40 u['l10n_unit_category'],
41 u['l10n_organization_category']
42 ),
43 u'%s (%s)' % (
44 u['organization'],
45 u['l10n_organization_category']
46 ),
47 u['unit']
48 ] for u in units ]
49
50 lctrl.set_string_items(items)
51 lctrl.set_data(units)
52
53 gmListWidgets.get_choices_from_list (
54 parent = parent,
55 msg = _('\nUnits (sites, parts, departments, branches, ...) of organizations registered in GNUmed.\n'),
56 caption = _('Showing organizational units.'),
57 columns = [ _('Category'), _('Organization'), _('Organizational Unit') ],
58 single_selection = True,
59 refresh_callback = refresh
60 )
61
62
64
65 if parent is None:
66 parent = wx.GetApp().GetTopWindow()
67
68 def refresh(lctrl):
69 orgs = gmOrganization.get_orgs(order_by = 'l10n_category, organization')
70 items = [ [o['l10n_category'], o['organization']] for o in orgs ]
71 lctrl.set_string_items(items)
72 lctrl.set_data(orgs)
73
74 gmListWidgets.get_choices_from_list (
75 parent = parent,
76 msg = _('\nOrganizations registered in GNUmed.\n'),
77 caption = _('Showing organizations.'),
78 columns = [ _('Category'), _('Organization') ],
79 single_selection = True,
80 refresh_callback = refresh
81 )
82
83
84
85
86 if __name__ == "__main__":
87
88 if len(sys.argv) < 2:
89 sys.exit()
90
91 if sys.argv[1] != u'test':
92 sys.exit()
93
94 app = wx.PyWidgetTester(size = (600, 600))
95 app.SetWidget(cATCPhraseWheel, -1)
96 app.MainLoop()
97
98