1
2
3
4
5
6 import wx
7
8
9 import gettext
10
11
12
13 from Gnumed.wxpython.gmPhraseWheel import cPhraseWheel
14 from Gnumed.wxpython.gmDataMiningWidgets import cPatientListingCtrl
15 from Gnumed.wxpython.gmTextCtrl import cTextCtrl
16
17
18
21
22 kwds["style"] = kwds.get("style", 0) | wx.BORDER_NONE | wx.TAB_TRAVERSAL
23 wx.ScrolledWindow.__init__(self, *args, **kwds)
24 self._splitter = wx.SplitterWindow(self, wx.ID_ANY, style=wx.SP_3D | wx.SP_BORDER)
25 self.splitter_top_panel = wx.Panel(self._splitter, wx.ID_ANY, style=wx.BORDER_NONE | wx.TAB_TRAVERSAL)
26 self._PRW_report_name = cPhraseWheel(self.splitter_top_panel, wx.ID_ANY, "")
27 self._TCTRL_query = cTextCtrl(self.splitter_top_panel, wx.ID_ANY, "", style=wx.TE_MULTILINE | wx.TE_WORDWRAP)
28 self._BTN_run = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("&Run"), style=wx.BU_EXACTFIT)
29 self._BTN_clear = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Clear"), style=wx.BU_EXACTFIT)
30 self._BTN_save = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Save"), style=wx.BU_EXACTFIT)
31 self._BTN_delete = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Delete"), style=wx.BU_EXACTFIT)
32 self._BTN_contribute = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Contribute"), style=wx.BU_EXACTFIT)
33 self._BTN_visualize = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Plot"), style=wx.BU_EXACTFIT)
34 self._BTN_waiting_list = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Wait.List"), style=wx.BU_EXACTFIT)
35 self._BTN_save_results = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Save"), style=wx.BU_EXACTFIT)
36 self._BTN_schema = wx.Button(self.splitter_top_panel, wx.ID_ANY, _("Schema"), style=wx.BU_EXACTFIT)
37 self._splitter_bottom_panel = wx.Panel(self._splitter, wx.ID_ANY, style=wx.BORDER_NONE | wx.TAB_TRAVERSAL)
38 self._LCTRL_result = cPatientListingCtrl(self._splitter_bottom_panel, wx.ID_ANY, style=wx.BORDER_SIMPLE | wx.LC_REPORT | wx.LC_SINGLE_SEL)
39
40 self.__set_properties()
41 self.__do_layout()
42
43 self.Bind(wx.EVT_BUTTON, self._on_run_button_pressed, self._BTN_run)
44 self.Bind(wx.EVT_BUTTON, self._on_clear_button_pressed, self._BTN_clear)
45 self.Bind(wx.EVT_BUTTON, self._on_save_button_pressed, self._BTN_save)
46 self.Bind(wx.EVT_BUTTON, self._on_delete_button_pressed, self._BTN_delete)
47 self.Bind(wx.EVT_BUTTON, self._on_contribute_button_pressed, self._BTN_contribute)
48 self.Bind(wx.EVT_BUTTON, self._on_visualize_button_pressed, self._BTN_visualize)
49 self.Bind(wx.EVT_BUTTON, self._on_waiting_list_button_pressed, self._BTN_waiting_list)
50 self.Bind(wx.EVT_BUTTON, self._on_save_results_button_pressed, self._BTN_save_results)
51 self.Bind(wx.EVT_BUTTON, self._on_schema_button_pressed, self._BTN_schema)
52
53
55
56 self.SetScrollRate(10, 10)
57 self._PRW_report_name.SetToolTip(_("If you want to save this query into the database for later use you must provide a descriptive label for it here."))
58 self._TCTRL_query.SetToolTip(_("Enter the SQL commands to run here.\n\nIt doesn't matter whether or not you enter a trailing \";\".\n\nNote that:\n- the query is run in a read-only transaction\n- the result list will be artificially limited to the first 1000 rows\n- you can include a column named \"pk_patient\" to make the result rows activate the corresponding patient on double-clicking\n- by inserting $<ID_ACTIVE_PATIENT>$ you can access the patient ID of the patient active at the time of running the query"))
59 self._BTN_run.SetToolTip(_("Run the query and present the results below."))
60 self._BTN_run.SetDefault()
61 self._BTN_clear.SetToolTip(_("Clear all fields."))
62 self._BTN_save.SetToolTip(_("Save the report definition."))
63 self._BTN_delete.SetToolTip(_("Delete this report definition."))
64 self._BTN_contribute.SetToolTip(_("Contribute this report definition to the GNUmed community. The report name and SQL command will be sent to the mailing list.\n\nPatient data will NOT be put AT RISK.\n\nYou may want to be careful about the SQL itself as it just might contain bits of sensitive data in, say, the WHERE conditions."))
65 self._BTN_visualize.SetToolTip(_("Visualize (plot) data from two numeric columns of the result list below."))
66 self._BTN_visualize.Enable(False)
67 self._BTN_waiting_list.SetToolTip(_("Put all or selected results onto a waiting list."))
68 self._BTN_waiting_list.Enable(False)
69 self._BTN_save_results.SetToolTip(_("Save query results as a CSV file."))
70 self._BTN_save_results.Enable(False)
71 self._BTN_schema.SetToolTip(_("Show the database schema definition in your web browser."))
72 self._splitter.SetMinimumPaneSize(20)
73
74
76
77 _szr_main = wx.BoxSizer(wx.VERTICAL)
78 __szr_splitter_bottom = wx.BoxSizer(wx.VERTICAL)
79 _fgszr_top = wx.FlexGridSizer(3, 2, 1, 4)
80 _szr_buttons = wx.BoxSizer(wx.HORIZONTAL)
81 __LBL_report_name = wx.StaticText(self.splitter_top_panel, wx.ID_ANY, _("Report"))
82 _fgszr_top.Add(__LBL_report_name, 0, wx.ALIGN_CENTER_VERTICAL, 0)
83 _fgszr_top.Add(self._PRW_report_name, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
84 __LBL_query = wx.StaticText(self.splitter_top_panel, wx.ID_ANY, _("\nCommand\n(SQL)"))
85 _fgszr_top.Add(__LBL_query, 0, wx.ALIGN_CENTER_VERTICAL, 0)
86 _fgszr_top.Add(self._TCTRL_query, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
87 _fgszr_top.Add((20, 20), 0, wx.EXPAND, 0)
88 _szr_buttons.Add(self._BTN_run, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)
89 _szr_buttons.Add(self._BTN_clear, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND | wx.RIGHT, 3)
90 _szr_buttons.Add(self._BTN_save, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)
91 _szr_buttons.Add(self._BTN_delete, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)
92 _szr_buttons.Add(self._BTN_contribute, 0, wx.ALIGN_CENTER_VERTICAL, 0)
93 _szr_buttons.Add((20, 20), 1, wx.EXPAND, 0)
94 _LBL_results = wx.StaticText(self.splitter_top_panel, wx.ID_ANY, _("Results:"))
95 _szr_buttons.Add(_LBL_results, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)
96 _szr_buttons.Add(self._BTN_visualize, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)
97 _szr_buttons.Add(self._BTN_waiting_list, 0, wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, 3)
98 _szr_buttons.Add(self._BTN_save_results, 0, wx.ALIGN_CENTER_VERTICAL, 0)
99 _szr_buttons.Add((20, 20), 1, wx.EXPAND, 0)
100 _szr_buttons.Add(self._BTN_schema, 0, wx.ALIGN_CENTER_VERTICAL, 0)
101 _fgszr_top.Add(_szr_buttons, 0, wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND, 0)
102 self.splitter_top_panel.SetSizer(_fgszr_top)
103 _fgszr_top.AddGrowableRow(1)
104 _fgszr_top.AddGrowableCol(1)
105 __szr_splitter_bottom.Add(self._LCTRL_result, 1, wx.EXPAND, 0)
106 self._splitter_bottom_panel.SetSizer(__szr_splitter_bottom)
107 self._splitter.SplitHorizontally(self.splitter_top_panel, self._splitter_bottom_panel, 99)
108 _szr_main.Add(self._splitter, 1, wx.EXPAND, 0)
109 self.SetSizer(_szr_main)
110 _szr_main.Fit(self)
111 self.Layout()
112
113
115 print("Event handler '_on_run_button_pressed' not implemented!")
116 event.Skip()
117
119 print("Event handler '_on_clear_button_pressed' not implemented!")
120 event.Skip()
121
123 print("Event handler '_on_save_button_pressed' not implemented!")
124 event.Skip()
125
127 print("Event handler '_on_delete_button_pressed' not implemented!")
128 event.Skip()
129
131 print("Event handler '_on_contribute_button_pressed' not implemented!")
132 event.Skip()
133
135 print("Event handler '_on_visualize_button_pressed' not implemented!")
136 event.Skip()
137
139 print("Event handler '_on_waiting_list_button_pressed' not implemented!")
140 event.Skip()
141
143 print("Event handler '_on_save_results_button_pressed' not implemented!")
144 event.Skip()
145
147 print("Event handler '_on_schema_button_pressed' not implemented!")
148 event.Skip()
149
150
151