[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnuef/src GFForm.py GFInstance.py UIwxpyth...
From: |
Jason Cater |
Subject: |
gnue/gnuef/src GFForm.py GFInstance.py UIwxpyth... |
Date: |
Thu, 31 May 2001 21:29:21 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/05/31 21:29:21
Modified files:
gnuef/src : GFForm.py GFInstance.py UIwxpython.py
Log message:
Added new login method in anticipation of multi-forms and new datasource
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFForm.py.diff?cvsroot=OldCVS&tr1=1.94&tr2=1.95&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/GFInstance.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnuef/src/UIwxpython.py.diff?cvsroot=OldCVS&tr1=1.87&tr2=1.88&r1=text&r2=text
Patches:
Index: gnue/gnuef/src/GFForm.py
diff -u gnue/gnuef/src/GFForm.py:1.94 gnue/gnuef/src/GFForm.py:1.95
--- gnue/gnuef/src/GFForm.py:1.94 Tue May 15 08:13:21 2001
+++ gnue/gnuef/src/GFForm.py Thu May 31 21:29:21 2001
@@ -69,7 +69,7 @@
#self._textPercentage = 7.5
self._app = app
-
+
def initializeTree(self):
# set the initial focus
Index: gnue/gnuef/src/GFInstance.py
diff -u gnue/gnuef/src/GFInstance.py:1.1 gnue/gnuef/src/GFInstance.py:1.2
--- gnue/gnuef/src/GFInstance.py:1.1 Thu May 31 14:52:57 2001
+++ gnue/gnuef/src/GFInstance.py Thu May 31 21:29:21 2001
@@ -34,7 +34,7 @@
#
# Copyright (c) 2000 Free Software Foundation
#
-# $Id: GFInstance.py,v 1.1 2001/05/31 21:52:57 jcater Exp $
+# $Id: GFInstance.py,v 1.2 2001/06/01 04:29:21 jcater Exp $
#
import pstats
@@ -484,25 +484,34 @@
while 1:
try:
#Login
- authcode = ["", "", object]
- self.dispatchEvent( GFEvent('getLogin', authcode) )
- user = authcode[0]
- passwd = authcode[1]
+ loginData = ["gnue", "Test Database",
+ [["user", "Username", 0],
+ ["passwd", "Password", 1]]]
+
+ # Returned data is in format of [ Completed, {dict of values} ]
+ self.dispatchEvent( GFEvent('getLogin', loginData) )
+ results = loginData[3] # Set by the login manager
+ if not results[0]:
+ print "\n\nUser cancelled login process. Exiting...\n"
+ sys.exit()
+
+ user = results[1]['user']
+ passwd = results[1]['passwd']
object.initialize(user,passwd)
except DBError:
message = GFMsgBox(self,"Database initialization error:\n%s\n%s " %
(sys.exc_info()[0], sys.exc_info()[1]))
message.show()
- except TypeError:
+# except TypeError:
# For some bizarre reason, the Oracle driver
# returns a TypeError for an invalid login????
- print "Invalid Login"
+# print "Invalid Login"
except:
+ # All other errors: make tty sane and re-raise error
if sys.platform != 'win32':
os.system("stty sane")
- print "Unexpected error:", sys.exc_info()[0], sys.exc_info()[1]
- sys.exit()
+ raise
else:
break
self._form.initializeDatasources()
Index: gnue/gnuef/src/UIwxpython.py
diff -u gnue/gnuef/src/UIwxpython.py:1.87 gnue/gnuef/src/UIwxpython.py:1.88
--- gnue/gnuef/src/UIwxpython.py:1.87 Tue May 15 08:13:22 2001
+++ gnue/gnuef/src/UIwxpython.py Thu May 31 21:29:21 2001
@@ -46,6 +46,30 @@
if GFOptions.fixedWidthFont:
widget.SetFont(wxFont(GFOptions.pointSize,wxMODERN,wxNORMAL,wxNORMAL))
+# Helps out with layout
+def getLargest(val1, val2):
+ if val1 > val2:
+ return val1
+ else:
+ return val2
+
+
+# Used by the login handler
+# enables the user to press return and have it jump to the next box
+class LoginFieldHandler:
+ def __init__(self, app, seq):
+ self.app = app
+ self.seq = seq
+
+ def loginFieldEventTrap(self, event):
+ if event.KeyCode() == WXK_RETURN:
+ if self.seq < len(self.app.textctrlList) - 1:
+ self.app.textctrlList[self.seq+1].SetFocus()
+ else:
+ self.app.loginCompleted(1)
+ else:
+ event.Skip()
+
#
# GFUserInterface
#
@@ -544,53 +568,146 @@
# creates the login dialog and displays it modal
#
def getLogin(self, event):
- self.logindata = event.data
- self.dlg = wxDialog(NULL, -1, "Login Required for %s" %
str(event.data[2].dbname),wxPoint(-1,-1),wxSize(250,150))
- self.dlg.SetBackgroundColour(wxWHITE)
+ self.loginData = event.data
+
+
+ if len(self.loginData[1]):
+ loginMesg = 'Login required for "%s" (%s)' % (self.loginData[1],
self.loginData[0])
+ else:
+ loginMesg = 'Login required for %s' % (self.loginData[0])
+
+ self.dlg = wxDialog(NULL, -1, "GNU Enterprise: Login")
+# self.dlg.SetBackgroundColour(wxWHITE)
self.dlg.SetAutoLayout(true)
bmp = wxImage(GFOptions.smallPNG, wxBITMAP_TYPE_PNG).ConvertToBitmap()
- dlgWidth, dlgHeight = self.dlg.GetSizeTuple()
-
- wxStaticBitmap(self.dlg,-1, bmp, wxPoint((dlgWidth-bmp.GetWidth())/2,
10),wxSize(bmp.GetWidth(), bmp.GetHeight()))
- wxStaticText(self.dlg, 1010, "Username",wxPoint(5, 25+ bmp.GetHeight()),
wxSize(75, 20))
- self.usernameEntry = wxTextCtrl(self.dlg, 1020,"",wxPoint(80, 25+
bmp.GetHeight()), wxSize(150, 20))
- wxStaticText(self.dlg, 1010, "Password",wxPoint(5, 50+ bmp.GetHeight()),
wxSize(75, 20))
- self.passwordEntry = wxTextCtrl(self.dlg, 1030,"", wxPoint(80, 50+
bmp.GetHeight()), wxSize(150, 20), wxTE_PASSWORD|wxTE_PROCESS_ENTER)
-
+
+
+ self.textctrlList = []
+ messageField = wxStaticText(self.dlg, 1010, loginMesg)
+ labelList = []
+
+ dlgWidth = getLargest(bmp.GetWidth(), messageField.GetSize().GetWidth()+20)
+
+ dlgHeight = bmp.GetHeight() + messageField.GetSize().GetHeight() + 80
+
+ xSpacing = 0
+ ySpacing = 0
+ fieldLabelWidth = 0
+
+ for prompt in self.loginData[2]:
+ s = wxStaticText(self.dlg, 1010, prompt[1])
+ labelList.append(s)
+
+ t = wxTextCtrl(self.dlg, -1,"",wxPoint(1, 1), wxSize(150, 20))
+ myID = len(self.textctrlList)
+ self.textctrlList.append(t)
+ EVT_CHAR(t, LoginFieldHandler(self, myID).loginFieldEventTrap)
+
+ fieldLabelWidth = getLargest(fieldLabelWidth, \
+ s.GetSize().GetWidth() + t.GetSize().GetWidth() + 6)
+
+ dlgWidth = getLargest(dlgWidth, \
+ s.GetSize().GetWidth() + t.GetSize().GetWidth() + 6)
+
+ xSpacing = getLargest(xSpacing, s.GetSize().GetWidth())
+ ySpacing = getLargest(ySpacing, s.GetSize().GetHeight())
+ ySpacing = getLargest(ySpacing, t.GetSize().GetHeight())
+
+
+ loginButton = wxButton(self.dlg,19998,'Login')
+ cancelButton = wxButton(self.dlg,19999,'Cancel')
+
+ EVT_BUTTON(self.dlg, 19998, self.loginButtonEventTrap)
+ EVT_BUTTON(self.dlg, 19999, self.loginCancelEventTrap)
+
+ dlgWidth = getLargest(dlgWidth, loginButton.GetSize().GetWidth() +
+ cancelButton.GetSize().GetWidth() + 6) + 20
+ dlgHeight = dlgHeight + \
+ getLargest(loginButton.GetSize().GetHeight(),
+ cancelButton.GetSize().GetHeight()) - 6
+
+ firstY = bmp.GetHeight() + messageField.GetSize().GetHeight() + 50
+ lastY = firstY
+ xSpacing = xSpacing + 10 # Add whitespace between widgets
+ ySpacing = ySpacing + 6 # Add whitespace between widgets
+ xPos = dlgWidth/2 - fieldLabelWidth/2 + 10
+
+
+ # Move the fields and labels into position
+ for i in range(0, len(self.textctrlList)):
+ dlgHeight = dlgHeight + ySpacing
+ labelList[i].SetPosition(wxPoint(xPos, lastY))
+ self.textctrlList[i].SetPosition(wxPoint(xPos + xSpacing, lastY))
+ lastY = lastY + ySpacing
+
- EVT_CHAR(self.usernameEntry, self.usernameEventTrap)
- EVT_CHAR(self.passwordEntry, self.passwordEventTrap)
+ # Create and position the logo
+ wxStaticBitmap(self.dlg,-1, bmp,
+ wxPoint((dlgWidth-bmp.GetWidth())/2, 10),
+ wxSize(bmp.GetWidth(), bmp.GetHeight()))
+
+ # Move the various widgets into position
+ messageField.SetPosition(
+ wxPoint(dlgWidth/2 - messageField.GetSize().GetWidth()/2,
+ 30 + bmp.GetHeight()))
+
+
+ cancelButton.SetPosition(
+ wxPoint(dlgWidth - 10 - cancelButton.GetSize().GetWidth(),
+ dlgHeight - 10 - getLargest(loginButton.GetSize().GetHeight(),
+ cancelButton.GetSize().GetHeight())))
+
+ loginButton.SetPosition(
+ wxPoint(dlgWidth - 16 - cancelButton.GetSize().GetWidth() - \
+ loginButton.GetSize().GetWidth(),
+ dlgHeight - 10 - getLargest(loginButton.GetSize().GetHeight(),
+ cancelButton.GetSize().GetHeight())))
+
+
+ self.dlg.SetSize(wxSize(dlgWidth, dlgHeight))
+
+ self.dlg.Refresh()
+
+ # If user cancels, this will be set to 0
+ self._completed = 0
+
self.dlg.Raise()
self.dlg.CenterOnScreen()
- self.dlg.ShowModal()
- self.dlg.Destroy()
-
+ self.dlg.ShowModal()
+ self.dlg.Destroy()
+
+ rv = {}
+ for i in range(0, len(self.loginData[2])):
+ rv[self.loginData[2][i][0]] = self.textctrlList[i].GetValue()
+
+ self.loginData.append([self._completed, rv])
+
+# event.data = [self._completed, rv]
+
+
#
- # usernameEventTrap
+ # Login is completed, for whatever reason
#
- # enables the user to press return and have it jump to the password box
+ def loginCompleted(self, successful):
+ self._completed = successful
+ self.dlg.EndModal(1)
+
#
- def usernameEventTrap(self, event):
- if event.KeyCode() == WXK_RETURN:
- self.passwordEntry.SetFocus()
- else:
- event.Skip()
+ # Called when user clicks "login"
+ #
+ def loginButtonEventTrap(self, event):
+ self.loginCompleted(1)
#
- # passwordEventTrap
+ # Called when user clicks "login"
#
- # catches the return key on the password box
- #
- def passwordEventTrap(self, event):
- if event.KeyCode() == WXK_RETURN:
- self.logindata[0] = self.usernameEntry.GetValue()
- self.logindata[1] = self.passwordEntry.GetValue()
- self.dlg.EndModal(1)
- else:
- event.Skip()
+ def loginCancelEventTrap(self, event):
+ self.loginCompleted(0)
+
+
#############################################################################
#
# UI Objects
@@ -825,6 +942,7 @@
class wxLoginHandler(GLoginHandler.LoginHandler):
# Obviously, this needs to be replaced with a dialog implementation :)
def getLogin(self, loginData):
+
try:
print "*"*60
print 'Attempting to log into "%s":' % (loginData[1] or loginData[0])
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/gnuef/src GFForm.py GFInstance.py UIwxpyth...,
Jason Cater <=