Hello,
In the botom of this post you will see my source code.
The problem is when i launch main.py that doesn't make anything why ?
Thanks
olivier noblanc
Atousoft
I have main.py :
---------------------------------
import wx
import inc.importlist
----------------------------------
inc/importlist.py
------------------------------------
import wx.grid
import getdata
import time
import sys
-----------------------------------
inc/wxgrid.py
-------------------------------------
# -*- coding: cp1252 -*-
#starta = time.time()
import wx
import getdata
class MyFrame(wx.Fram e):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init_ _
kwds["style"] = wx.DEFAULT_FRAM E_STYLE
wx.Frame.__init __(self, *args, **kwds)
self.grid_1 = wx.grid.Grid(se lf, -1, size=(1, 1))
self.__set_prop erties()
self.__do_layou t()
# end wxGlade
def __set_propertie s(self):
# begin wxGlade: MyFrame.__set_p roperties
self.SetTitle(" frame_1")
self.SetSize((4 00, 400))
# end wxGlade
self.grid_1.Cre ateGrid(len(db. data), len(db.fields))
# met les labels des colonnes
index = 0
for item in db.fields:
self.grid_1.Set ColLabelValue(i ndex, item[0])
index += 1
# remplissage des données.
for row in range(len(db.da ta)):
for col in range(len(db.da ta[row])):
values = db.data[row][col]
self.grid_1.Set CellValue(row,c ol,str(values))
# mise en forme et affichage
def __do_layout(sel f):
# begin wxGlade: MyFrame.__do_la yout
sizer_1 = wx.BoxSizer(wx. VERTICAL)
sizer_1.Add(sel f.grid_1, 1, wx.EXPAND, 0)
self.SetAutoLay out(True)
self.SetSizer(s izer_1)
self.Layout()
# end wxGlade
# end of class MyFrame
if __name__ == "__main__":
app = wx.PySimpleApp( 0)
wx.InitAllImage Handlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindo w(frame_1)
frame_1.Show()
#startb = time.time() - starta
#print startb
app.MainLoop()
---------------------------------------
inc/getdata.py
----------------------------------------------
import MySQLdb
class Eb_db:
def __init__(self):
try:
connection = MySQLdb.connect (host="dellced" , user="ats",
passwd="", db="atsmedicdat abase" )
cursor = connection.curs or()
cursor.execute( "SELECT * FROM PATIENT " )
except MySQLdb.Operati onalError, message:
errorMessage = "Error %d:\n%s" % ( message[ 0 ], message[ 1 ] )
return
else:
self.data = cursor.fetchall ()
self.fields = cursor.descript ion
cursor.close()
connection.clos e()
-----------------------------------------
In the botom of this post you will see my source code.
The problem is when i launch main.py that doesn't make anything why ?
Thanks
olivier noblanc
Atousoft
I have main.py :
---------------------------------
import wx
import inc.importlist
----------------------------------
inc/importlist.py
------------------------------------
import wx.grid
import getdata
import time
import sys
-----------------------------------
inc/wxgrid.py
-------------------------------------
# -*- coding: cp1252 -*-
#starta = time.time()
import wx
import getdata
class MyFrame(wx.Fram e):
def __init__(self, *args, **kwds):
# begin wxGlade: MyFrame.__init_ _
kwds["style"] = wx.DEFAULT_FRAM E_STYLE
wx.Frame.__init __(self, *args, **kwds)
self.grid_1 = wx.grid.Grid(se lf, -1, size=(1, 1))
self.__set_prop erties()
self.__do_layou t()
# end wxGlade
def __set_propertie s(self):
# begin wxGlade: MyFrame.__set_p roperties
self.SetTitle(" frame_1")
self.SetSize((4 00, 400))
# end wxGlade
self.grid_1.Cre ateGrid(len(db. data), len(db.fields))
# met les labels des colonnes
index = 0
for item in db.fields:
self.grid_1.Set ColLabelValue(i ndex, item[0])
index += 1
# remplissage des données.
for row in range(len(db.da ta)):
for col in range(len(db.da ta[row])):
values = db.data[row][col]
self.grid_1.Set CellValue(row,c ol,str(values))
# mise en forme et affichage
def __do_layout(sel f):
# begin wxGlade: MyFrame.__do_la yout
sizer_1 = wx.BoxSizer(wx. VERTICAL)
sizer_1.Add(sel f.grid_1, 1, wx.EXPAND, 0)
self.SetAutoLay out(True)
self.SetSizer(s izer_1)
self.Layout()
# end wxGlade
# end of class MyFrame
if __name__ == "__main__":
app = wx.PySimpleApp( 0)
wx.InitAllImage Handlers()
frame_1 = MyFrame(None, -1, "")
app.SetTopWindo w(frame_1)
frame_1.Show()
#startb = time.time() - starta
#print startb
app.MainLoop()
---------------------------------------
inc/getdata.py
----------------------------------------------
import MySQLdb
class Eb_db:
def __init__(self):
try:
connection = MySQLdb.connect (host="dellced" , user="ats",
passwd="", db="atsmedicdat abase" )
cursor = connection.curs or()
cursor.execute( "SELECT * FROM PATIENT " )
except MySQLdb.Operati onalError, message:
errorMessage = "Error %d:\n%s" % ( message[ 0 ], message[ 1 ] )
return
else:
self.data = cursor.fetchall ()
self.fields = cursor.descript ion
cursor.close()
connection.clos e()
-----------------------------------------
Comment