| 400 | |
| 401 | |
| 402 | class MainFrame(wx.Frame): |
| 403 | |
| 404 | def __init__(self): |
| 405 | wx.Frame.__init__(self, None) |
| 406 | |
| 407 | self.build() |
| 408 | |
| 409 | def build(self): |
| 410 | # Menu Bar |
| 411 | self.MenuBar = wx.MenuBar() |
| 412 | |
| 413 | self.plots = wx.Menu() |
| 414 | self.PHPlot = wx.Menu() |
| 415 | self.TSPlot = wx.Menu() |
| 416 | self.tables = wx.Menu() |
| 417 | self.PsychPlot = wx.MenuItem(self.plots, -1, 'Psychrometric Plot') |
| 418 | self.SatTable = wx.MenuItem(self.tables, -1, ' Saturation Table', "", wx.ITEM_NORMAL) |
| 419 | |
| 420 | for Fluid in sorted(CP.__fluids__): |
| 421 | mnuItem = wx.MenuItem(self.PHPlot, -1, Fluid, "", wx.ITEM_NORMAL) |
| 422 | self.PHPlot.AppendItem(mnuItem) |
| 423 | self.Bind(wx.EVT_MENU, lambda event: self.OnPHPlot(event, mnuItem), mnuItem) |
| 424 | |
| 425 | mnuItem = wx.MenuItem(self.TSPlot, -1, Fluid, "", wx.ITEM_NORMAL) |
| 426 | self.TSPlot.AppendItem(mnuItem) |
| 427 | self.Bind(wx.EVT_MENU, lambda event: self.OnTSPlot(event, mnuItem), mnuItem) |
| 428 | |
| 429 | self.MenuBar.Append(self.plots, "Plots") |
| 430 | self.plots.AppendItem(self.PsychPlot) |
| 431 | self.plots.AppendMenu(-1, 'p-h plot', self.PHPlot) |
| 432 | self.plots.AppendMenu(-1, 'T-s plot', self.TSPlot) |
| 433 | self.MenuBar.Append(self.tables, "Tables") |
| 434 | self.tables.AppendItem(self.SatTable) |
| 435 | self.Bind(wx.EVT_MENU, self.OnSatTable, self.SatTable) |
| 436 | self.Bind(wx.EVT_MENU, self.OnPsychPlot, self.PsychPlot) |
| 437 | |
| 438 | self.SetMenuBar(self.MenuBar) |
| 439 | |
| 440 | def OnPsychPlot(self, event=None): |
| 441 | |
| 442 | # Load the options |
| 443 | dlg = PsychOptions(None) |
| 444 | if dlg.ShowModal() == wx.ID_OK: |
| 445 | Tmin = float(dlg.Tmin.GetValue()) + 273.15 |
| 446 | Tmax = float(dlg.Tmax.GetValue()) + 273.15 |
| 447 | p = float(dlg.p.GetValue()) |
| 448 | PPF = PsychPlotFrame(Tmin=Tmin, Tmax=Tmax, p=p, size=(1000, 700)) |
| 449 | PPF.Show() |
| 450 | dlg.Destroy() |
| 451 | |
| 452 | def OnSatTable(self, event): |
| 453 | TBL = SaturationTable(None) |
| 454 | TBL.Show() |
| 455 | |
| 456 | def OnPHPlot(self, event, mnuItem): |
| 457 | # Make a p-h plot instance in a new frame |
| 458 | # Get the label (Fluid name) |
| 459 | Fluid = self.PHPlot.FindItemById(event.Id).Label |