From rshepard at appl-ecosys.com Wed Dec 7 18:41:51 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 7 Dec 2011 09:41:51 -0800 (PST) Subject: [portland] Error: object does not support item assignment Message-ID: Yesterday I sent this to the wxPython mail list and no one's responded. I'd like to move forward with this project so I'm asking for help here. I'm writing a wxPython application to enter data into a postgres table (using psycopg2). There is a class written by someone else as part of a database query tool that I'm using to set up the database connection. The class runs as a stand-alone application. I don't know how to approach resolving this problem. The error stopping the python script is: Traceback (most recent call last): File "./biolwq.py", line 513, in frame_1 = OneFrame(None, -1, "") File "./biolwq.py", line 59, in __init__ self.projDB = LoginDialog(self) File "/.../postgresLogin.py", line 92, in __init__ data['port']='5432' TypeError: 'OneFrame' object does not support item assignment Lines 86-92 in postgresLogin.py are: if field == 'port': try: port_t.SetValue(environ['PGPORT']) data['port']=port_t.GetValue() except KeyError: port_t.SetValue('5432') data['port']='5432' The postgres port is the only value explicitly set; the others are blank text control widgets waiting for user input. The two files shown above are about 22K in size; I've attached copies. Help appreciated, Rich -- To unsubscribe, send email to wxPython-users+unsubscribe at googlegroups.com or visit http://groups.google.com/group/wxPython-users?hl=en -------------- next part -------------- #!/usr/bin/env python import wx import psycopg2 as psycopg from postgresLogin import * from biotaPage import modBiota """ This model of the Jerritt Canyon Mine drainages includes water chemistry, biota (including bacteria), and spatial aspects. It allows users to enter new data, edit data, submit queries to the postgres back end, and run GRASS and R models on the data. """ """ 1. User logs in by accessing the postgres database. 2. Display notebook with tabs for chemistry and biota. 3. """ class WqNotebook(wx.Notebook): """ This class is the tabbed notebook that holds the widgets for the database tables. Each tab's widgets are created on a panel in a separate file. """ def __init__(self, *args, **kwds): wx.Notebook.__init__(self, *args, **kwds) self.pane_1 = modBiota(self, wx.ID_ANY) #self.pane_2 = modChem(self, wx.ID_ANY) #self.pane_3 = modBact(self, wx.ID_ANY self.AddPage(self.pane_1, "Biota") #self.AddPage(self.pane_2, "Chemistry") #self.AddPage(self.pane_3, "Bacteria") # self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnNBPageChanged) # def OnNBPageChanged(self, event): # print "Event handler `OnNBPageChanged' not implemented" # event.Skip() # End of Notebook class class OneFrame(wx.Frame): """ This class is the main window for the biological water quality model. It provides the menus, status bar, and window decorations expected of a stand-alone application. Created in a running form ... 2011 by R.B. Shepard. """ def __init__(self, *args, **kwds): kwds["style"] = wx.DEFAULT_FRAME_STYLE|wx.FULL_REPAINT_ON_RESIZE|wx.TAB_TRAVERSAL wx.Frame.__init__(self, *args, **kwds) self.mainNB = WqNotebook(self, wx.ID_ANY, style=0) self.projDB = LoginDialog(self) # Menu Bar self.frame_1_menubar = wx.MenuBar() self.SetMenuBar(self.frame_1_menubar) menuFile = wx.Menu() item = menuFile.Append(wx.ID_ANY, '&New \tCtrl-N', 'Create a new project', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFileNew, item) item = menuFile.Append(wx.ID_ANY, '&Open \tCtrl-O', 'Open a project', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFileOpen, item) item = menuFile.Append(wx.ID_ANY, '&Save \tCtrl-S', 'Save project', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFileSave, item) item = menuFile.Append(wx.ID_ANY, 'Save &as \tCtrl-A', 'Save with new name', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFileSaveas, item) item = menuFile.Append(wx.ID_ANY, '&Close \tCtrl-C', 'Close project', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFileClose, item) item = menuFile.Append(wx.ID_ANY, '&Quit \tCtrl-Q', 'Quit Eikos', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFileQuit, item) self.frame_1_menubar.Append(menuFile, 'File') menuScoping = wx.Menu() item = menuScoping.Append(wx.ID_ANY, '&Scan cards \tAlt-S', 'Scan preference forms', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnScan, item) item = menuScoping.Append(wx.ID_ANY, '&Print records \tCtrl-P', 'Print preference records', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnPrintScoping, item) item = menuScoping.Append(wx.ID_ANY, 'Importance weights \tCtrl-I', 'Calculate component importance weights', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnCalcImpWt, item) self.frame_1_menubar.Append(menuScoping, 'Scoping') menuPolicy = wx.Menu() item = menuPolicy.Append(wx.ID_ANY, '&Add', 'Add new policy to model',wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnPolicyAdd, item) item= menuPolicy.Append(wx.ID_ANY, '&Edit', 'Edit an existing policy', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnPolicyEdit, item) item = menuPolicy.Append(wx.ID_ANY, '&Remove', 'Remove policy from model', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnPolicyRem, item) item = menuPolicy.Append(wx.ID_ANY, '&Save', 'Save policy in model', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnPolicySave, item) menuPolicy.AppendSeparator() item = menuPolicy.Append(wx.ID_ANY, 'A&dd Variable', 'Add variable to policy', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnVar2pol, item) item = menuPolicy.Append(wx.ID_ANY, 'Re&move Variable', 'Remove variable from policy', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnVarfrompol, item) self.frame_1_menubar.Append(menuPolicy, "Policy") menuVar = wx.Menu() item = menuVar.Append(wx.ID_ANY, '&Define', 'Define a variable', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnVarDef, item) item = menuVar.Append(wx.ID_ANY, '&Edit', 'Edit an existing variable.', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnVarEdit, item) item = menuVar.Append(wx.ID_ANY, '&Remove', 'Remove a variable', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnVarRem, item) item = menuVar.Append(wx.ID_ANY, '&Save', 'Save the variable', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnVarSav, item) menuVar.AppendSeparator() item = menuVar.Append(wx.ID_ANY, 'A&dd fuzzy set', 'Add fuzzy set to variable', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFzySet2var, item) item = menuVar.Append(wx.ID_ANY, 'Re&move fuzzy set', 'Remove fuzzy set from variable', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFzySetfromvar, item) self.frame_1_menubar.Append(menuVar, "Variables") menuFzySet = wx.Menu() item = menuFzySet.Append(wx.ID_ANY, '&Define', 'Define a new fuzzy set', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFzySetDef, item) item = menuFzySet.Append(wx.ID_ANY, '&Edit', 'Edit an existing fuzzy set.', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFzySetEdit, item) item = menuFzySet.Append(wx.ID_ANY, '&Remove', 'Remove a fuzzy set', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFzySetRem, item) item = menuFzySet.Append(wx.ID_ANY, '&Save', 'Save fuzzy set', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnFzySetSav, item) self.frame_1_menubar.Append(menuFzySet, "Fuzzy Sets") menuHedge = wx.Menu() item = menuHedge.Append(wx.ID_ANY, '&Define', 'Define a new hedge', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnHedDef, item) item = menuHedge.Append(wx.ID_ANY, '&Edit', 'Edit an existing hedge.', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnHedEdit, item) item = menuHedge.Append(wx.ID_ANY, '&Remove', 'Remove added hedge', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnHedRem, item) item = menuHedge.Append(wx.ID_ANY, '&Save', 'Save the new hedge', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnHedSav, item) self.frame_1_menubar.Append(menuHedge, "Hedges") menuRule = wx.Menu() item = menuRule.Append(wx.ID_ANY, '&Add', 'Add a rule to the model', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnRuleAdd, item) item = menuRule.Append(wx.ID_ANY, '&Edit', 'Edit an existing rule.', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnRuleEdit, item) item = menuRule.Append(wx.ID_ANY, '&Remove', 'Remove a rule from the model', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnRuleRem, item) item = menuRule.Append(wx.ID_ANY, '&Save', 'Save the set of rules', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnRuleSav, item) self.frame_1_menubar.Append(menuRule, "Rules") menuHelp = wx.Menu() item = menuHelp.Append(wx.ID_ANY, '&About', 'About Eikos', wx.ITEM_NORMAL) self.Bind(wx.EVT_MENU, self.OnHelpAbout, item) self.frame_1_menubar.Append(menuHelp, "Help") # Status Bar self.Eikos_statusbar = self.CreateStatusBar(1, 0) self.__set_properties() self.__do_layout() def __set_properties(self): self.SetTitle("Eikos") self.SetSize((800, 600)) self.Eikos_statusbar.SetStatusWidths([-1]) # statusbar fields Eikos_statusbar_fields = ["Status:"] for i in range(len(Eikos_statusbar_fields)): self.Eikos_statusbar.SetStatusText(Eikos_statusbar_fields[i], i) def __do_layout(self): sizer_1 = wx.BoxSizer(wx.HORIZONTAL) sizer_1.Add(self.mainNB, 1, wx.ALL|wx.EXPAND, 5) self.SetAutoLayout(True) self.SetSizer(sizer_1) self.Layout() def OnStart(self, event): """ This message dialog box is called to remind the user to open or create a project before doing anything else. """ nag = wx.MessageDialog(self, 'You must open or create a project first.', "Reminder", wx.OK|wx.ICON_EXCLAMATION) nag.ShowModal() nag.Destroy() def message(self, event): """ This message dialog box is called to show the user that the selected function has not yet been implemented. It tells the user that something has happened.""" notYet = wx.MessageDialog(self, 'This function is not yet implemented. Please come back soon.', "Uh-oh!", wx.OK|wx.ICON_EXCLAMATION) notYet.ShowModal() notYet.Destroy() def helpdlg(self,event): """ This message dialog box provides a brief summary of what the application is.""" about = wx.MessageDialog(self, 'Eikos is an approximate reasoning model that computes\nwith words. It solves complex problems based on the\nknowledge of experts and/or with common sense.', 'About Eikos', wx.OK|wx.ICON_INFORMATION) about.ShowModal() about.Destroy() def OnFileNew(self, event): """ Create a new file and open it.""" self.dirname = '' wd = wx.DirDialog(self, "Chose the default directory", ".", style=wx.DD_NEW_DIR_BUTTON) if wd.ShowModal() == wx.ID_OK: dirname = wd.GetPath() ted = wx.TextEntryDialog(self, "Enter the project name", "New Project Name", "", style=wx.RAISED_BORDER|wx.OK|wx.CANCEL) if ted.ShowModal() == wx.ID_OK: projname = ted.GetValue() tcName = self.mainNB.pane_1.tcName tcName.WriteText(projname) self._openDB() ted.Destroy() wd.Destroy() def OnFileOpen(self, event): """ Open a project file.""" self.dirname = '' dlg = wx.FileDialog(self, "Choose a project", self.dirname, "", "*.pdb", wx.OPEN) if dlg.ShowModal() == wx.ID_OK: self.projname=dlg.GetFilename() self.dirname=dlg.GetDirectory() self.SetTitle(('Eikos: - %s') % projname) fn=open(os.path.join(self.dirname,self.filename),'rw') self.tcName.WriteText(projname) self._openDb() dlg.Destroy() def OnFileSave(self, event): if self.FileName == None: return self.OnFileSaveasMenu(event) else: self.model.SaveFile(self.modName) def OnFileSaveas(self, event): dlg = wx.FileDialog(self, "Save file as", ".", "", "*.*", wx.SAVE) try: if dlg.ShowModal() == wx.ID_OK: modName = dlg.GetPath() self.model.SaveFile(modName) self.FileName = modName self.SetTitle(('Eikos - %s') % modName) finally: dlg.Destroy() def OnFileClose(self, event): # first, close the SQLite3 database projDB.closeDb() # not sure about this guy: fn.close() self.FileName = None self.model.Clear() self.SetTitle('Eikos') def OnFileQuit(self, event): projDB.closeDb() # this one, too: fn.close() self.Close() def OnScan(self, event): # scanner row translations DATA_MAP_BLANK = { chr(32)+chr(32): 0 } DATA_MAP_2 = { chr(32)+chr(36): 'Natural', chr(96)+chr(32): 'Eonomic', chr(36)+chr(32): 'Societal' } DATA_MAP_5 = { chr(32)+chr(36): 'Support', chr(96)+chr(32): 'Neutral', chr(36)+chr(32): 'Oppose' } DATA_MAP_7 = { chr(32)+chr(16): 1.000, chr(32)+chr(8): 2.000, chr(32)+chr(4): 3.000, chr(32)+chr(2): 4.000, chr(32)+chr(1): 5.000, chr(64)+chr(32): 6.000, chr(16)+chr(32): 7.000, chr(8)+chr(32): 8.000, chr(4)+chr(32): 9.000, chr(34)+chr(8): 0.500, chr(34)+chr(4): 0.333, chr(34)+chr(2): 0.025, chr(34)+chr(1): 0.200, chr(66)+chr(32): 0.167, chr(18)+chr(32): 0.143, chr(10)+chr(32): 0.125, chr(6)+chr(32): 0.111 } # Open serial port ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1) ser.open() if ser.isOpen() != True: serial.SerialException searchString = '\r' row_num = 0 vote_id =0 # connection and cursor to SQLite3 database: self._openDB(projname) while True: row_num += 1 line = ser.read(3) line = string.replace(line, searchString, '\n') if rowNum == 2: row_value = DATA_MAP_2[line] cur.execute("insert into 'voting' (row, line) values (row_num, row_value)") con.commit() if rowNum == 5: row_value = DATA_MAP_5[line] cur.execute("insert into 'voting' (row, line) values (row_num, row_value)") con.commit() if rowNum >= 7: row_value = DATA_MAP_7[line] cur.execute("insert into 'voting' (row, line) values (row_num, row_value)") con.commit() else: row_value = DATA_MAP_BLANK[line] cur.execute("insert into 'voting' (row, line) values (row_num, row_value)") con.commit() # close the SQLite3 cursor and connection. cur.close() con.close() # close the serial port ser.Close() def OnPrintScoping(self, event): """ This class represents the print and print setup common dialogs. You may obtain a wx.PrinterDC device context from a successfully dismissed print dialog. User information is stored in a wx.PrintDialogData object that is passed to the dialog at creation time, and it is filled in by the user. As with other dialogs, do not use this data once the dialog is dismissed, and do not destroy the dialog until you have everything you need from it. """ data = wx.PrintDialogData() data.EnableSelection(True) data.EnablePrintToFile(True) data.EnablePageNumbers(True) data.SetMinPage(1) data.SetMaxPage(5) data.SetAllPages(True) dlg = wx.PrintDialog(self, data) if dlg.ShowModal() == wx.ID_OK: data = dlg.GetPrintDialogData() # self.log.WriteText('GetAllPages: %d\n' % data.GetAllPages()) dlg.Destroy() def OnCalcImpWt(self, event): self.message(event) event.Skip() def OnPolicyAdd(self, event): self.message(event) event.Skip() def OnPolicyEdit(self, event): self.message(event) event.Skip() def OnPolicyRem(self, event): self.message(event) event.Skip() def OnPolicySave(self, event): self.message(event) event.Skip() def OnVarDef(self, event): self.message(event) event.Skip() def OnVarEdit(self, event): self.message(event) event.Skip() def OnVarRem(self, event): self.message(event) event.Skip() def OnVarSav(self, event): self.message(event) event.Skip() def OnVar2pol(self, event): self.message(event) event.Skip() def OnFzySetDef(self, event): self.message(event) event.Skip() def OnFzySetEdit(self, event): self.message(event) event.Skip() def OnFzySetRem(self, event): self.message(event) event.Skip() def OnFzySetSav(self, event): self.message(event) event.Skip() def OnVarfrompol(self, event): self.message(event) event.Skip() def OnFzySet2var(self, event): self.message(event) event.Skip() def OnFzySetfromvar(self, event): self.message(event) event.Skip() def OnHedDef(self, event): self.message(event) event.Skip() def OnHedEdit(self, event): self.message(event) event.Skip() def OnHedRem(self, event): self.message(event) event.Skip() def OnHedSav(self, event): self.message(event) event.Skip() def OnRuleAdd(self, event): print "Event handler, 'OnRuleAdd,' not yet implemented." event.Skip() def OnRuleEdit(self, event): print "Event handler, 'OnRuleEdit,' not yet implemented." event.Skip() def OnRuleRem(self, event): print "Event handler, 'OnRuleRem,' not yet implemented." event.Skip() def OnRuleSav(self, event): print "Event handler, 'OnRuleSav,' not yet implemented." event.Skip() def OnHelpAbout(self, event): self.helpdlg(event) # end of class OneFrame if __name__ == "__main__": eikos = wx.App(0) frame_1 = OneFrame(None, -1, "") eikos.SetTopWindow(frame_1) frame_1.Show() frame_1.OnStart(None) eikos.MainLoop() -------------- next part -------------- #!/usr/bin/env python import wx import pprint import re from os import environ import sys import psycopg2 as psycopg from TextWindow import TextWin from multiFrame import * about_txt = """\ Enter Parameters For PostgreSQL Login. """ class DataXferValidator(wx.PyValidator): def __init__(self, data, key): wx.PyValidator.__init__(self) self.data = data self.key = key def Clone(self): """ Note that every validator must implement the Clone() method. """ return DataXferValidator(self.data, self.key) def Validate(self, win): return True def TransferToWindow(self): textCtrl = self.GetWindow() textCtrl.SetValue(self.data.get(self.key, "")) return True def TransferFromWindow(self): textCtrl = self.GetWindow() self.data[self.key] = textCtrl.GetValue() return True class LoginDialog(wx.Dialog): def __init__(self, data): wx.Dialog.__init__(self, None, -1, "PostgreSQL Login Dialog", style=wx.DEFAULT_FRAME_STYLE) if sys.platform == 'darwin' : self.panel = wx.Panel(self,-1) self.panel.SetBackgroundColour("light blue") else : self.SetBackgroundColour("light blue") # Create the text controls about = wx.StaticText(self, -1, about_txt) user_l = wx.StaticText(self, -1, "User: ") password_l = wx.StaticText(self, -1, "Password: ") host_l = wx.StaticText(self, -1, "Host: ") dbname_l = wx.StaticText(self, -1, "Dbname: ") port_l = wx.StaticText(self, -1, "Port: ") user_t = wx.TextCtrl(self, validator=DataXferValidator(data, "user")) password_t = wx.TextCtrl(self,style=wx.TE_PASSWORD, validator=DataXferValidator(data, "password")) host_t = wx.TextCtrl(self, validator=DataXferValidator(data, "host")) dbname_t = wx.TextCtrl(self, validator=DataXferValidator(data, "dbname")) port_t = wx.TextCtrl(self, validator=DataXferValidator(data, "port")) for field in ("user","password","host","dbname","port") : if field == 'user': try: user_t.SetValue(environ['PGUSER']) data['user']=user_t.GetValue() except KeyError: pass if field =='host': try: host_t.SetValue(environ['PGHOST']) data['host'] = host_t.GetValue() except KeyError: pass if field=='dbname': try: dbname_t.SetValue(environ['PGDATABASE']) data['dbname']=dbname_t.GetValue() except KeyError: pass if field == 'port': try: port_t.SetValue(environ['PGPORT']) data['port']=port_t.GetValue() except KeyError: port_t.SetValue('5432') data['port']='5432' # Use standard button IDs okay = wx.Button(self, wx.ID_OK,"Login") okay.SetDefault() cancel = wx.Button(self, wx.ID_CANCEL) # Layout with sizers sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(about, 0, wx.ALL, 5) sizer.Add(wx.StaticLine(self), 0, wx.EXPAND|wx.ALL, 5) fgs = wx.FlexGridSizer(5, 2, 5, 5) fgs.Add(user_l, 0, wx.ALIGN_RIGHT) fgs.Add(user_t, 0, wx.EXPAND) fgs.Add(password_l, 0, wx.ALIGN_RIGHT) fgs.Add(password_t, 0, wx.EXPAND) fgs.Add(host_l, 0, wx.ALIGN_RIGHT) fgs.Add(host_t, 0, wx.EXPAND) fgs.Add(dbname_l, 0, wx.ALIGN_RIGHT) fgs.Add(dbname_t, 0, wx.EXPAND) fgs.Add(port_l, 0, wx.ALIGN_RIGHT) fgs.Add(port_t, 0, wx.EXPAND) fgs.AddGrowableCol(1) sizer.Add(fgs, 0, wx.EXPAND|wx.ALL, 5) btns = wx.StdDialogButtonSizer() btns.AddButton(okay) btns.AddButton(cancel) btns.Realize() sizer.Add(btns, 0, wx.EXPAND|wx.ALL, 5) self.SetSizer(sizer) sizer.Fit(self) if sys.platform == 'darwin' : self.panel.SetSize(self.GetSize()) self.Bind(wx.EVT_SIZE,self.doResize) def doResize(self,event): self.panel.SetSize(self.GetSize()) event.Skip() if __name__ == '__main__' : app = wx.PySimpleApp() #data = { "user" : "levan", "port" : "5432" } data = {} dlg = LoginDialog(data) dlg.Center() if dlg.ShowModal() == wx.ID_OK : #wx.MessageBox("You entered these values:\n\n" +pprint.pformat(data)) dsn="" for field in ("user","password","host","dbname","port") : if data[field] !='': dsn = dsn + field + '=' + data[field]+' ' # Try to do the connection conn = None try: conn=psycopg.connect(dsn) except psycopg.DatabaseError, errorInfo: wx.MessageBox("Error: "+ str(errorInfo)) if conn != None : #wx.MessageBox("Sucessfull Connection!") conn.set_isolation_level(0) BuildAppWin(conn,data) dlg.Destroy() #app.MainLoop() From robin at alldunn.com Wed Dec 7 19:28:06 2011 From: robin at alldunn.com (Robin Dunn) Date: Wed, 07 Dec 2011 10:28:06 -0800 Subject: [portland] Error: object does not support item assignment In-Reply-To: References: Message-ID: <4EDFB036.1080704@alldunn.com> On 12/7/11 9:41 AM, Rich Shepard wrote: > Yesterday I sent this to the wxPython mail list and no one's responded. > I'd like to move forward with this project so I'm asking for help here. > > I'm writing a wxPython application to enter data into a postgres table > (using psycopg2). There is a class written by someone else as part of a > database query tool that I'm using to set up the database connection. The > class runs as a stand-alone application. I don't know how to approach > resolving this problem. > > The error stopping the python script is: > > Traceback (most recent call last): > File "./biolwq.py", line 513, in > frame_1 = OneFrame(None, -1, "") > File "./biolwq.py", line 59, in __init__ > self.projDB = LoginDialog(self) > File > "/.../postgresLogin.py", > line 92, in __init__ > data['port']='5432' TypeError: 'OneFrame' object does not support item > assignment > > Lines 86-92 in postgresLogin.py are: > > if field == 'port': > try: > port_t.SetValue(environ['PGPORT']) > data['port']=port_t.GetValue() > except KeyError: > port_t.SetValue('5432') > data['port']='5432' > > The postgres port is the only value explicitly set; the others are blank > text control widgets waiting for user input. > It looks to me like you are expected to be passing a dictionary (or some other mapping type) to LoginDialog rather than the frame. -- Robin Dunn Software Craftsman http://wxPython.org From ethan at stoneleaf.us Wed Dec 7 19:08:41 2011 From: ethan at stoneleaf.us (Ethan Furman) Date: Wed, 07 Dec 2011 10:08:41 -0800 Subject: [portland] Error: object does not support item assignment In-Reply-To: References: Message-ID: <4EDFABA9.9050003@stoneleaf.us> Rich Shepard wrote: > Traceback (most recent call last): > File "./biolwq.py", line 513, in > frame_1 = OneFrame(None, -1, "") > File "./biolwq.py", line 59, in __init__ > self.projDB = LoginDialog(self) > File > "/.../postgresLogin.py", > line 92, in __init__ > data['port']='5432' TypeError: 'OneFrame' object does not support > item assignment class OneFrame(wx.Frame) In order to support item assignment the `__setitem__` method must be defined. I do not see that in the `OneFrame` class, so unless `wx.Frame` has it, it won't work. My question is: should `data` actually be a `OneFrame` object, or should it be some other namespace/object? ~Ethan~ From rshepard at appl-ecosys.com Wed Dec 7 19:59:54 2011 From: rshepard at appl-ecosys.com (Rich Shepard) Date: Wed, 7 Dec 2011 10:59:54 -0800 (PST) Subject: [portland] Error: object does not support item assignment In-Reply-To: <4EDFABA9.9050003@stoneleaf.us> References: <4EDFABA9.9050003@stoneleaf.us> Message-ID: On Wed, 7 Dec 2011, Ethan Furman wrote: > class OneFrame(wx.Frame) > > In order to support item assignment the `__setitem__` method must be defined. > I do not see that in the `OneFrame` class, so unless `wx.Frame` has it, it > won't work. Ethan, I thought it that importing the class required methods would be made available. > My question is: should `data` actually be a `OneFrame` object, or should it > be some other namespace/object? Oops! Now I see the problem: I left the code to run that one class in when I imported it to the main file. Commenting that out helps. Now I need to clean up some other discrepancies but this one's resolved. Mea culpa! Thanks, Rich From michelle at pdxpython.org Thu Dec 8 21:50:42 2011 From: michelle at pdxpython.org (Michelle Rowley) Date: Thu, 8 Dec 2011 12:50:42 -0800 Subject: [portland] Winter Coders' Social: Tuesday, December 13, 6-10pm at Urban Airship! Message-ID: Hey Pythonistas, The 5th Annual Winter Coders' Social and Potluck is just around the corner: http://goo.gl/VZN3l. Instead of our regular meeting this Tuesday, we'll join other Portland programmers and their families to eat, drink, play games, and be merry! All are welcome, and details are below. See you there! * WHEN: Tuesday, December 13, 2011 from 6?10pm * WHERE: Urban Airship, 334 NW 11th Avenue, Portland, OR 97209 * POTLUCK: Signup at Join Portland's tech community in celebrating the end of another year. This is a fun, free annual event where members of local user groups and their families are invited to mingle, eat and play games. This is the fifth time the event's been held and it's lots of fun every time. We'll have a potluck, so you're welcome to bring something yummy to share with others. If possible, label your food and whether it meets particular dietary needs, e.g. "vegan", "vegetarian", gluten-free", etc. If you'd like, tell others what you plan to bring, or see what others are bringing at . We'll provide beverages, plates, cups, utensils and napkins. Like games? Bring your favorites and play them with others. We'll have some rooms with tables set aside. Have an activity or contest that you'd like to organize? Join the discussion at https://groups.google.com/group/pdxgroups. Please spread the word, all are welcome. See you there! THANKS! We're grateful to Urban Airship , Emma , ShopIgniter and Portland Incubator Experiment (PIE) for sponsoring this event. --- Michelle Rowley @pythonchelle michelle at pdxpython.org http://www.meetup.com/pdxpython -------------- next part -------------- An HTML attachment was scrubbed... URL: From Stabler at pbworld.com Fri Dec 9 01:27:39 2011 From: Stabler at pbworld.com (Stabler, Ben) Date: Fri, 9 Dec 2011 00:27:39 +0000 Subject: [portland] job posting Message-ID: <953C9F9C78F3604482D92FCAD6060D75DC2B@AMNYCMSX04.corp.pbwan.net> Hi fellow Python users, I work for Parsons Brinckerhoff's Systems Analysis Group, which is an international leader in the development of large-scale simulation models of transportation and land-use systems. Our Portland team is looking to add someone with excellent software development skills to work on state-of-the-art travel demand forecasting and land use models for public agencies around the world. We develop a variety of computer models, with many of the models running across multiple machines\processors and producing gigabytes of outputs. More information about the position can be found at the link below. Feel free to contact me if you are interested. Applications for this position must be made online through the Employment Opportunities page at http://www.pbworld.com (job number 14391), or directly at http://search0.smartsearchonline.com/pb/jobs/jobdetails.asp?job_number=14391. Parsons Brinckerhoff is an equal opportunity employer. Thanks! Ben Stabler Supervising Planner, Systems Analysis Parsons Brinckerhoff 400 SW Sixth Avenue, Suite 802 Portland, OR 97204 503-478-2859 (office) 503-360-5798 (cell) stabler at pbworld.com www.pbworld.com ______________________________________________________________________ NOTICE: This communication and any attachments ("this message") may contain confidential information for the sole use of the intended recipient(s). Any unauthorized use, disclosure, viewing, copying, alteration, dissemination or distribution of, or reliance on this message is strictly prohibited. If you have received this message in error, or you are not an authorized recipient, please notify the sender immediately by replying to this message, delete this message and all copies from your e-mail system and destroy any printed copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian at python.org Fri Dec 23 03:06:13 2011 From: brian at python.org (Brian Curtin) Date: Thu, 22 Dec 2011 20:06:13 -0600 Subject: [portland] PyCon 2012 News - Tutorials, Talks, and Tickets Message-ID: <4EF3E215.8030604@python.org> We are now 75 days away from PyCon 2012 in Santa Clara ? it's hard to think about how quickly time has flown since PyCon 2011! We've lined up some great keynote and plenary speakers, announced the tutorial and talk selections, opened ticket sales, and have expanded financial aid opportunities. The community and our amazing array of sponsors have helped us break several records already, so we hope you're as excited about PyCon 2012 as we are. The conference runs March 7-15 at the Santa Clara Convention Center in Santa Clara, CA. The keynote speakers include Y Combinator investor Paul Graham and Mozilla's Head of Developer Engagement, Stormy Peters. Both of them bring interesting experience to the table, and they're both captivating speakers. Speaking of captivating, Dave Beazley was announced on the plenary track, with more to be added in the coming weeks. Guido ? our Benevolent Dictator For Life ? will also be joining the line up! With 483 tutorial, talk, and poster proposals submitted this year, the program committee had their hands full paring that list down to 95 talks, 32 tutorials, and 36 posters (which we're still accepting). In the little time since we made these announcements we've heard a lot of excitement. You can see the tutorial selections at https://us.pycon.org/2012/schedule/lists/tutorials/, with talks available at https://us.pycon.org/2012/schedule/lists/talks/. Tickets are now available with early bird rates available until January 10, 2012 at https://us.pycon.org/2012/registration. Tutorial and admission prices continue unchanged; if you've been following along the last few years, these rates are the same as they have been for several years. Our team's dedication to keeping PyCon cost-effective, community driven, and grassroots continues thanks to the hard work and support of the team and sponsors (https://us.pycon.org/2012/sponsors/). If financial assistance would make PyCon a possibility for you, we encourage you to apply to this year's expanded assistance program. With a deadline of January 7, 2012 (extended from January 2) and a new web-based application, the financial aid committee aims to make the trip, lodging, and a ticket a possibility for everyone. Thanks to a new partnership with the PyLadies organization, we're able to provide grants to women in the community who are interested in experiencing the conference. For full details see https://us.pycon.org/2012/assistance. For more information about PyCon 2012, see our site at https://us.pycon.org/2012/. We also publish news on our blog: http://pycon.blogspot.com/. Jesse Noller - Chairman jnoller at python.org Brian Curtin - Publicity Coordinator brian at python.org