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 <module>
    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 [email protected]
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()
_______________________________________________
Portland mailing list
[email protected]
http://mail.python.org/mailman/listinfo/portland

Reply via email to