home *** CD-ROM | disk | FTP | other *** search
- import trueSpace
-
- import win32ui
- import win32api
- import dialog
- import win32con
-
- def MakeDlgTemplate(title):
- style = win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT
- cs = win32con.WS_CHILD | win32con.WS_VISIBLE
-
- # Window frame and title
- dlg = [ [title, (0, 0, 184, 40), style, None, (8, "MS Sans Serif")], ]
-
- # ID label and text box
- dlg.append([130, "User ID:", -1, (7, 9, 69, 9), cs | win32con.SS_LEFT])
- s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
- dlg.append(['EDIT', None, win32ui.IDC_EDIT1, (50, 7, 60, 12), s])
-
- # Password label and text box
- dlg.append([130, "Password:", -1, (7, 22, 69, 9), cs | win32con.SS_LEFT])
- s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
- dlg.append(['EDIT', None, win32ui.IDC_EDIT2, (50, 20, 60, 12), s | win32con.ES_PASSWORD])
-
- # OK/Cancel Buttons
- s = cs | win32con.WS_TABSTOP
- dlg.append([128, "OK", win32con.IDOK, (124, 5, 50, 14), s | win32con.BS_DEFPUSHBUTTON])
- s = win32con.BS_PUSHBUTTON | s
- dlg.append([128, "Cancel", win32con.IDCANCEL, (124, 20, 50, 14), s])
- return dlg
-
- class LoginDlg(dialog.Dialog):
- Cancel = 0
- def __init__(self, title):
- dialog.Dialog.__init__(self, MakeDlgTemplate(title) )
- self.AddDDX(win32ui.IDC_EDIT1,'userid')
- self.AddDDX(win32ui.IDC_EDIT2,'password')
- def OnCancel(self):
- self.Cancel = 1
- self._obj_.OnCancel()
-
- def GetLogin(title='Login', userid=''):
- d = LoginDlg(title)
- d['userid'] = userid
- d.DoModal()
- if d.Cancel:
- return (None, None)
- else:
- return (d['userid'], d['password'])
-
- title = "FTP Login"
- def_user = "fred"
-
- userid, password = GetLogin(title, def_user)
-
- if userid == password == None:
- print "User pressed Cancel"
- else:
- print "User ID: ", userid
- print ", Password: ", password
- print "\n"
-
- print "trueSpace version: ", trueSpace.GetVersion(), "\n"
-