| 1 | ## Copyright 2005, 2006, 2007, 2008, 2009 Virginia Polytechnic Institute and State University |
|---|
| 2 | ## |
|---|
| 3 | ## This file is part of the OSSIE ALF Waveform Application Visualization Environment |
|---|
| 4 | ## |
|---|
| 5 | ## ALF is free software; you can redistribute it and/or modify |
|---|
| 6 | ## it under the terms of the GNU General Public License as published by |
|---|
| 7 | ## the Free Software Foundation; either version 2 of the License, or |
|---|
| 8 | ## (at your option) any later version. |
|---|
| 9 | ## |
|---|
| 10 | ## ALF is distributed in the hope that it will be useful, but WITHOUT ANY |
|---|
| 11 | ## WARRANTY; without even the implied warranty of |
|---|
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | ## GNU General Public License for more details. |
|---|
| 14 | ## |
|---|
| 15 | ## You should have received a copy of the GNU General Public License |
|---|
| 16 | ## along with OSSIE Waveform Developer; if not, write to the Free Software |
|---|
| 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 18 | |
|---|
| 19 | import wx |
|---|
| 20 | from namingserviceDialog import NamingserviceDialog |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | class ALFNSChoiceDialog(wx.Dialog): |
|---|
| 24 | def __init__(self, parent): |
|---|
| 25 | wx.Dialog.__init__(self, |
|---|
| 26 | parent=None, |
|---|
| 27 | id=-1, |
|---|
| 28 | title='Warning!', |
|---|
| 29 | pos=wx.DefaultPosition, |
|---|
| 30 | size=wx.Size(400, 100)) |
|---|
| 31 | self.parent = parent |
|---|
| 32 | |
|---|
| 33 | panel = wx.Panel(self) |
|---|
| 34 | vbox = wx.BoxSizer(wx.VERTICAL) |
|---|
| 35 | hbox = wx.BoxSizer(wx.HORIZONTAL) |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | text = wx.StaticText(panel, -1, "The naming service is not running locally!") |
|---|
| 39 | startLocallyButton = wx.Button(panel, -1, 'Start Locally') |
|---|
| 40 | connectRemoteButton = wx.Button(panel, -1, 'Connect Remotely') |
|---|
| 41 | cancelButton = wx.Button(panel, -1, 'Cancel') |
|---|
| 42 | startLocallyButton.Bind(wx.EVT_BUTTON, self.startLocally) |
|---|
| 43 | connectRemoteButton.Bind(wx.EVT_BUTTON, self.connectRemote) |
|---|
| 44 | cancelButton.Bind(wx.EVT_BUTTON, self.OnExit) |
|---|
| 45 | |
|---|
| 46 | hbox.Add(startLocallyButton, 1, wx.LEFT, 5) |
|---|
| 47 | hbox.Add(connectRemoteButton, 1, wx.LEFT | wx.RIGHT, 5) |
|---|
| 48 | hbox.Add(cancelButton, 1, wx.RIGHT, 5) |
|---|
| 49 | |
|---|
| 50 | vbox.Add(text, 0, wx.ALIGN_CENTER| wx.TOP, 10) |
|---|
| 51 | vbox.Add(hbox, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10) |
|---|
| 52 | panel.SetSizer(vbox) |
|---|
| 53 | vbox.Fit(self) |
|---|
| 54 | self.Center() |
|---|
| 55 | self.ShowModal() |
|---|
| 56 | |
|---|
| 57 | self.Destroy() |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | def startLocally(self, event): |
|---|
| 61 | self.parent.nbUtils.startNamingService() |
|---|
| 62 | self.EndModal(-1) |
|---|
| 63 | |
|---|
| 64 | def connectRemote(self, event): |
|---|
| 65 | self.parent.namingservice_dialog = NamingserviceDialog(self.parent) |
|---|
| 66 | self.EndModal(-1) |
|---|
| 67 | |
|---|
| 68 | def OnExit(self, event): |
|---|
| 69 | self.EndModal(-2) |
|---|
| 70 | #self.GetParent().Destroy() |
|---|
| 71 | |
|---|
| 72 | def main(): |
|---|
| 73 | app = wx.App() |
|---|
| 74 | frame = wx.Frame(None, -1, "test") |
|---|
| 75 | frame.Center() |
|---|
| 76 | frame.Show() |
|---|
| 77 | anscd = ALFNSChoiceDialog(frame) |
|---|
| 78 | app.MainLoop() |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | if __name__ == '__main__': |
|---|
| 82 | main() |
|---|
| 83 | |
|---|
| 84 | |
|---|