Hello everyone, I'm new on wxPython programming
I want to make an database with sqlite3, but I don't know how to make a database report with, just like an Microsoft Access
Here's the code:
import wx
import sqlite3 as lite
class myframe(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(480, 220))
panel = wx.Panel(self, -1)
gs = wx.FlexGridSizer(3, 2, 9, 9)
vbox = wx.BoxSizer(wx.VERTICAL)
hbox = wx.BoxSizer(wx.HORIZONTAL)
name = wx.StaticText(panel, -1, 'Name')
bp = wx.StaticText(panel, -1, 'Number')
self.tc1 = wx.TextCtrl(panel, -1, size=(300, -1))
self.tc2 = wx.TextCtrl(panel, -1, size=(100, -1))
gs.AddMany([(name), (self.tc1, 1, wx.LEFT, 10),
(bp), (self.tc2, 1, wx.LEFT, 10)])
vbox.Add(gs, 0, wx.ALL, 10)
vbox.Add((-1, 30))
insert = wx.Button(panel, -1, 'Insert', size=(-1, 30))
cancel = wx.Button(panel, -1, 'Cancel', size=(-1, 30))
hbox.Add(insert)
hbox.Add(cancel, 0, wx.LEFT, 5)
vbox.Add(hbox, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
self.Bind(wx.EVT_BUTTON, self.OnInsert, id=insert.GetId())
self.Bind(wx.EVT_BUTTON, self.OnCancel, id=cancel.GetId())
panel.SetSizer(vbox)
self.Centre()
self.Show(True)
def OnInsert(self, event):
try:
con = lite.connect('database')
cur = con.cursor()
nama = self.tc1.GetValue()
bp = self.tc2.GetValue()
cur.execute('insert values', (Name, Number))
con.commit()
cur.close()
con.close()
except lite.Error, error:
dlg = wx.MessageDialog(self, str(error), 'Error occured')
dlg.ShowModal()
def OnCancel(self, event):
self.Close()
app = wx.App()
myframe(None, -1, 'Insert Name')
app.MainLoop()
Where and what should I write to make an report?
Thank's for your help.