hpareek

Untitled

Jun 29th, 2017
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.31 KB | None | 0 0
  1.         import wx
  2.         import os
  3.  
  4.         conn = sqlite3.connect('KHAMAN.db')
  5.  
  6.         c = conn.cursor()
  7.  
  8.         class Example(wx.Frame):
  9.             def __init__(self, parent, title):
  10.             super(Example, self).__init__(parent, title=title, size=(1000,800))
  11.             self.inter_list = list()
  12.             self.plot_list = list()
  13.             self.InitUI()
  14.             self.Layout()
  15.             self.Centre()
  16.             self.Show()
  17.  
  18.             def InitUI(self):
  19.             self.p = wx.Panel(self)
  20.             bs = wx.BoxSizer(wx.VERTICAL)
  21.             gs = wx.GridSizer(10, 18, 5, 5)
  22.             bs.Add(gs, 1, wx.EXPAND)
  23.             self.search_btn=wx.Button(self.p,-1,"Search!")
  24.             self.search_btn.Bind(wx.EVT_BUTTON, self.OnSearch, self.search_btn)
  25.             bs.Add(self.search_btn,0,wx.ALIGN_CENTER)
  26.             self.p.SetSizer(bs)
  27.  
  28.             def OnSearch(self, event):
  29.             dlg = GetData(parent = self.p)
  30.             dlg.ShowModal()
  31.             if dlg.result_name:
  32.                 print "Elements: "+dlg.result_elements+"\n"
  33.                 print "Name: "+dlg.result_name+"\n"
  34.                 print "Formula: "+dlg.result_formula+"\n"
  35.             else:
  36.                 print "No Input found\n"
  37.             dlg.Destroy()
  38.  
  39.         class GetData(wx.Dialog):
  40.             def __init__(self, parent):
  41.             wx.Dialog.__init__(self, parent, wx.ID_ANY, "New Molecule", size= (650,220))
  42.             self.p = wx.Panel(self,wx.ID_ANY)
  43.             self.lblelements = wx.StaticText(self.p, label="Elements", pos=(20,20))
  44.             self.elements = wx.TextCtrl(self.p, value="", pos=(110,20), size=(500,-1))
  45.             self.lblnam = wx.StaticText(self.p, label="Name", pos=(20,60))
  46.             self.name = wx.TextCtrl(self.p, value="", pos=(110,60), size=(500,-1))
  47.             self.lblform = wx.StaticText(self.p, label="Formula", pos=(20,100))
  48.             self.formula = wx.TextCtrl(self.p, value="", pos=(110,100), size=(500,-1))
  49.             self.saveButton =wx.Button(self.p, label="Save", pos=(110,170))
  50.             self.closeButton =wx.Button(self.p, label="Cancel", pos=(210,170))
  51.             self.saveButton.Bind(wx.EVT_BUTTON, self.SaveConnString)
  52.             self.closeButton.Bind(wx.EVT_BUTTON, self.OnQuit)
  53.             self.Bind(wx.EVT_CLOSE, self.OnQuit)
  54.             self.Show()
  55.  
  56.             def OnQuit(self, event):
  57.             self.result_number = None
  58.             self.Destroy()
  59.  
  60.             def SaveConnString(self, event):
  61.             self.result_elements = self.elements.GetValue()
  62.             self.result_name = self.name.GetValue()
  63.             self.result_formula = self.formula.GetValue()
  64.             self.Destroy()
  65.        
  66.  
  67.         app = wx.App()
  68.         Example(None, title = 'Raman Spectroscopy Database')
  69.         app.MainLoop()
Add Comment
Please, Sign In to add comment