Hi All,
I am very new to python Gui programming and am trying to create a simple Gui which will get a set of results from an sql query which goes into Oracle and display these results in the text box below. If u can also help me get the positioning of my labels,combo box and buttons to re-size if I expand the frame that would be great. Code below. Thank u sooo much!
import wx
import cx_Oracle
class MainWindow(wx.Panel):
def __init__(self,parent,id):
wx.Panel.__init__(self,parent,id)
self.background = wx.Panel(self)
lblHeader = wx.StaticText(self,-1,label='TITLE',pos=(100,10),style=wx.ALIGN_CENTER)
font = wx.Font(15,wx.BOLD,wx.NORMAL,wx.ITALIC)
lblHeader.SetFont(font)
lblComboBox = wx.StaticText(self,-1,label='Fund_id:',pos=(5,65))
self.Fund_id = wx.ComboBox(self, -1, pos=(120,60), size=(100,25), choices=('fund'), style=wx.CB_DROPDOWN)
lblStartDate = wx.StaticText(self, -1, label='Start_date:', pos=(5,105))
self.StartDate = wx.TextCtrl(self, -1, pos=(120,100), size=(100,25))
lblEndDate = wx.StaticText(self,-1,label='End_date:',pos=(5,145))
self.EndDate=wx.TextCtrl(self,-1,pos=(120,140),size=(100,25))
self.myButton = wx.Button(self, label='Execute', pos=(50,200), size=(100,25))
self.Bind(wx.EVT_BUTTON,self.OnExecute,id= self.myButton.GetId())
Exit = wx.Button(self, label='Exit', pos=(200,200), size=(100,25))
self.Bind(wx.EVT_BUTTON, self.OnExit, id=Exit.GetId())
self.transferArea = wx.TextCtrl(self, pos=(20,250),size= (1000,200),style = wx.TE_READONLY | wx.TE_MULTILINE)
def OnExecute(self,event):
# try:
connection = cx_Oracle.connect('/@db')
cursor = connection.cursor()
fund_id = self.Fund_id.GetValue()
start_date = self.StartDate.GetValue()
end_date = self.EndDate.GetValue()
sql="""Select * from table where fund_id = '%s' and datetime >= to_date('%s','DD/MM/YYYY') and datetime <= to_date('%s','DD/MM/YYYY')""" % (fund_id,start_date,end_date)
print sql
cursor.execute(sql)
result = cursor.fetchall()
return result
def OnExit(self,e):
self.Close() # Close the frame.
app = wx.App()
frame = wx.Frame(None,-1,"MY TITLE")
MainWindow(frame,-1)
frame.Show(1)
app.MainLoop()