Hi all,
I’m trying to duplicate a simple Vb/Access app. I’ve gotten as far
as some simple Gui construction, and db connection but
I’m stuck with the event procedures.
Basically, I’m just trying to change the text in the wxTextCtrl
as I step through the database. The error I’m receiving is:
Traceback (most recent call last):
File "C:\Python20\wxframetest2.py", line 67, in OnNext
self.t.Clear()
AttributeError: 'MyFrame' instance has no attribute 't'
I understand why I’m receiving the error, but I’m not sure how to
go about fixing it.
Any help would be appreciated. (Code below)
TIA,
Bill.
(edited for length – pretty much copied from the
demo:
from wxPython.wx import *
import time
import dbi
import odbc
myconn = odbc.odbc(‘PROJECTLIST’)
mycursor = myconn.cursor()
mycursor.execute(‘Select * from ProjectList’)
mydata = []
···
#---------------------------------------------------------------
class MyFrame(wxFrame):
def init(self, parent, ID, title, pos, size):
wxFrame.init(self, parent, ID, title, pos, size)
panel = wxPanel(self, -1)
mydata = mycursor.fetchone()
wxStaticText(panel, -1, "Data1", wxPoint(5, 25), wxSize(75, 20))
t = wxTextCtrl(panel, 10, str(mydata[0]), wxPoint(80, 25),wxSize(150, 20))
t.SetInsertionPoint(0)
<snip - more gui widgets here>
#Next Button
#--------------------------------------------
btn_Next = wxButton(panel, 1005, “Next”)
btn_Next.SetPosition(wxPoint(150, 125))
EVT_BUTTON(self, 1005, self.OnNext)
#--------------------------------------------
def OnNext(self, event):
mydata = mycursor.fetchone()
print (mydata[0])
self.t.Clear()
self.t.WriteText(str(mydata[0]))