[959eb01] | 1 | """ |
---|
| 2 | Console Module display message of a dialog |
---|
| 3 | """ |
---|
| 4 | import wx |
---|
| 5 | import sys |
---|
| 6 | from sas.sascalc.dataloader.loader import Loader |
---|
| 7 | |
---|
| 8 | _BOX_WIDTH = 60 |
---|
| 9 | CONSOLE_WIDTH = 340 |
---|
| 10 | CONSOLE_HEIGHT = 240 |
---|
| 11 | if sys.platform.count("win32") > 0: |
---|
| 12 | _STATICBOX_WIDTH = 450 |
---|
| 13 | PANEL_WIDTH = 500 |
---|
| 14 | PANEL_HEIGHT = 550 |
---|
| 15 | FONT_VARIANT = 0 |
---|
| 16 | else: |
---|
| 17 | _STATICBOX_WIDTH = 480 |
---|
| 18 | PANEL_WIDTH = 530 |
---|
| 19 | PANEL_HEIGHT = 560 |
---|
| 20 | FONT_VARIANT = 1 |
---|
| 21 | |
---|
| 22 | class ConsoleDialog(wx.Dialog): |
---|
| 23 | """ |
---|
| 24 | Data summary dialog |
---|
| 25 | """ |
---|
| 26 | def __init__(self, parent=None, manager=None, data=None, |
---|
| 27 | title="Data Summary", size=(PANEL_WIDTH, PANEL_HEIGHT)): |
---|
| 28 | wx.Dialog.__init__(self, parent=parent, title=title, size=size) |
---|
| 29 | |
---|
| 30 | self.parent = parent |
---|
| 31 | self._manager = manager |
---|
| 32 | self._data = data |
---|
| 33 | self.sizer = wx.BoxSizer(wx.VERTICAL) |
---|
| 34 | self.msg_txt = wx.TextCtrl(self, size=(PANEL_WIDTH - 40, |
---|
| 35 | PANEL_HEIGHT - 60), |
---|
| 36 | style=wx.TE_MULTILINE) |
---|
| 37 | self.msg_txt.SetEditable(False) |
---|
| 38 | self.msg_txt.SetValue('No message available') |
---|
| 39 | self.sizer.Add(self.msg_txt, 1, wx.EXPAND | wx.ALL, 10) |
---|
| 40 | if self._data is not None: |
---|
| 41 | self.set_message(msg=self._data.__str__()) |
---|
| 42 | |
---|
| 43 | self.SetSizer(self.sizer) |
---|
| 44 | |
---|
| 45 | def set_manager(self, manager): |
---|
| 46 | """ |
---|
| 47 | Set the manager of this window |
---|
| 48 | """ |
---|
| 49 | self._manager = manager |
---|
| 50 | |
---|
| 51 | def set_message(self, msg=""): |
---|
| 52 | """ |
---|
| 53 | Display the message received |
---|
| 54 | """ |
---|
| 55 | self.msg_txt.SetValue(str(msg)) |
---|
| 56 | |
---|
| 57 | if __name__ == "__main__": |
---|
| 58 | |
---|
| 59 | app = wx.App() |
---|
| 60 | # Instantiate a loader |
---|
| 61 | loader = Loader() |
---|
| 62 | # Load data |
---|
| 63 | test_data = loader.load("MAR07232_rest.ASC") |
---|
| 64 | dlg = ConsoleDialog(data=test_data) |
---|
| 65 | dlg.ShowModal() |
---|
| 66 | app.MainLoop() |
---|