hpareek

Untitled

Jul 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1.         import wx
  2.         class MyFrame(wx.Frame):
  3.             def __init__(self, parent):
  4.             wx.Frame.__init__(self, parent, -1, "Dialog Test",size=(500,400))
  5.             self.panel = wx.Panel(self)
  6.             sizer = wx.BoxSizer(wx.VERTICAL)
  7.             self.button = wx.Button(self.panel, label="Click me")
  8.             sizer.Add(self.button, 0, wx.EXPAND | wx.ALL, 10)
  9.             self.panel.SetSizer(sizer)
  10.             self.Bind(wx.EVT_BUTTON, self.OnButton)
  11.  
  12.             def OnButton(self,event):
  13.             dlg = GetData(parent = self.panel)
  14.             dlg.ShowModal()
  15.             dlg.Destroy()
  16.  
  17.         class GetData(wx.Dialog):
  18.             def __init__(self, parent):
  19.             wx.Dialog.__init__(self, parent, wx.ID_ANY, "Name Input", size= (650,220))
  20.             self.panel = wx.Panel(self,wx.ID_ANY)
  21.             self.lblname = wx.StaticText(self.panel, label="Name", pos=(20,20))
  22.             self.name = wx.TextCtrl(self.panel, value="", pos=(110,20), size=(500,-1))
  23.             self.saveButton =wx.Button(self.panel, label="Save", pos=(110,160))
  24.             self.closeButton =wx.Button(self.panel, label="Cancel", pos=(210,160))
  25.             self.saveButton.Bind(wx.EVT_BUTTON, self.SaveConnString)
  26.             self.closeButton.Bind(wx.EVT_BUTTON, self.OnQuit)
  27.             self.Bind(wx.EVT_CLOSE, self.OnQuit)
  28.             self.Show()
  29.  
  30.             def OnQuit(self, event):
  31.             self.result_name = None
  32.             self.Destroy()
  33.  
  34.             def SaveConnString(self, event):
  35.             self.result_name = self.name.GetValue()
  36.             print name.split( )
  37.             print name.split(' ', 1 )
  38.             self.Destroy()
  39.  
  40.         app = wx.App()
  41.         frame = MyFrame(None)
  42.         frame.Show()
  43.         app.MainLoop()
Add Comment
Please, Sign In to add comment