Exemplo n.º 1
0
    def __init__(self, x, y, w, h, topmost=0):
        Window.__init__(self, x, y, w, h, topmost)
        self.setLayout(pyui.layouts.BorderLayoutManager())

        fields = [('string', 'user', 'Name:', 24, 5),
                  ('password', 'pass', 'Password:'******'checkbox', 'guest', '', 24, 'Login as a guest?')]

        self.form = FormPanel(fields)
        self.form.widget_user.handler = self.doLogin
        self.form.widget_pass.handler = self.doLogin

        self.registerEvent(pyui.locals.KEYDOWN, self._pyuiKeyDown)

        self.login = Button('Login', self.doLogin)
        self.create = Button('Create Account', self.doLogin)

        self.botPanel = Panel()
        self.botPanel.addChild(self.login)
        self.botPanel.addChild(self.create)

        self.addChild(self.form, pyui.locals.CENTER)
        self.addChild(self.botPanel, pyui.locals.SOUTH)
        self.pack()

        self.form.widget_user.getFocus()
Exemplo n.º 2
0
    def __init__(self, x, y, w, h, topmost = 0):
        Window.__init__(self, x, y, w, h, topmost)
        self.setLayout(pyui.layouts.BorderLayoutManager())

        fields = [
            ('string', 'user', 'Name:', 24, 5),
            ('password', 'pass', 'Password:'******'checkbox', 'guest', '', 24, 'Login as a guest?')
            ]

        self.form = FormPanel(fields)
        self.form.widget_user.handler = self.doLogin
        self.form.widget_pass.handler = self.doLogin

        self.registerEvent(pyui.locals.KEYDOWN, self._pyuiKeyDown)
        
        self.login = Button('Login', self.doLogin)
        self.create = Button('Create Account', self.doLogin)
        
        self.botPanel = Panel()
        self.botPanel.addChild(self.login)
        self.botPanel.addChild(self.create)
        
        self.addChild(self.form, pyui.locals.CENTER)
        self.addChild(self.botPanel, pyui.locals.SOUTH)
        self.pack()

        self.form.widget_user.getFocus()
Exemplo n.º 3
0
class LoginWindow(Window):
    def __init__(self, x, y, w, h, topmost = 0):
        Window.__init__(self, x, y, w, h, topmost)
        self.setLayout(pyui.layouts.BorderLayoutManager())

        fields = [
            ('string', 'user', 'Name:', 24, 5),
            ('password', 'pass', 'Password:'******'checkbox', 'guest', '', 24, 'Login as a guest?')
            ]

        self.form = FormPanel(fields)
        self.form.widget_user.handler = self.doLogin
        self.form.widget_pass.handler = self.doLogin

        self.registerEvent(pyui.locals.KEYDOWN, self._pyuiKeyDown)
        
        self.login = Button('Login', self.doLogin)
        self.create = Button('Create Account', self.doLogin)
        
        self.botPanel = Panel()
        self.botPanel.addChild(self.login)
        self.botPanel.addChild(self.create)
        
        self.addChild(self.form, pyui.locals.CENTER)
        self.addChild(self.botPanel, pyui.locals.SOUTH)
        self.pack()

        self.form.widget_user.getFocus()

    def _pyuiKeyDown(self, event):
        if event.key == pyui.locals.K_TAB:
            if event.mods & pyui.locals.MOD_SHIFT:
                self.form.nextTab(-1)
            else:
                self.form.nextTab(+1)
            return 1
        return 0

    def doLogin(self, widget):
        name = self.form.widget_user.text
        pwd = self.form.widget_pass.text

        Events.do('showConsole')

        print "Opening stream socket..."
        tcp = Network.TCPSocket()
        try:
            tcp.connect(Network.serverAddress)
        except:
            print "Could not connect to server."
            print "The server could be down.  Try again later."
            tcp.close()
            return 1
        
        print "Opening datagram socket..."
        udp = Network.UDPSocket()
        tcp.write('bindUDP %i\n' % udp.getsockname()[1])
        
        newUser = User.User(tcp, udp)
        newUser.name = name
        newUser.pwd = pwd
        if(widget == self.create):
            newUser.isNewUser = True
        if(self.form.widget_guest.checkState == 1):
            newUser.isGuest = True

        self.destroy()
        return 1
Exemplo n.º 4
0
class LoginWindow(Window):
    def __init__(self, x, y, w, h, topmost=0):
        Window.__init__(self, x, y, w, h, topmost)
        self.setLayout(pyui.layouts.BorderLayoutManager())

        fields = [('string', 'user', 'Name:', 24, 5),
                  ('password', 'pass', 'Password:'******'checkbox', 'guest', '', 24, 'Login as a guest?')]

        self.form = FormPanel(fields)
        self.form.widget_user.handler = self.doLogin
        self.form.widget_pass.handler = self.doLogin

        self.registerEvent(pyui.locals.KEYDOWN, self._pyuiKeyDown)

        self.login = Button('Login', self.doLogin)
        self.create = Button('Create Account', self.doLogin)

        self.botPanel = Panel()
        self.botPanel.addChild(self.login)
        self.botPanel.addChild(self.create)

        self.addChild(self.form, pyui.locals.CENTER)
        self.addChild(self.botPanel, pyui.locals.SOUTH)
        self.pack()

        self.form.widget_user.getFocus()

    def _pyuiKeyDown(self, event):
        if event.key == pyui.locals.K_TAB:
            if event.mods & pyui.locals.MOD_SHIFT:
                self.form.nextTab(-1)
            else:
                self.form.nextTab(+1)
            return 1
        return 0

    def doLogin(self, widget):
        name = self.form.widget_user.text
        pwd = self.form.widget_pass.text

        Events.do('showConsole')

        print "Opening stream socket..."
        tcp = Network.TCPSocket()
        try:
            tcp.connect(Network.serverAddress)
        except:
            print "Could not connect to server."
            print "The server could be down.  Try again later."
            tcp.close()
            return 1

        print "Opening datagram socket..."
        udp = Network.UDPSocket()
        tcp.write('bindUDP %i\n' % udp.getsockname()[1])

        newUser = User.User(tcp, udp)
        newUser.name = name
        newUser.pwd = pwd
        if (widget == self.create):
            newUser.isNewUser = True
        if (self.form.widget_guest.checkState == 1):
            newUser.isGuest = True

        self.destroy()
        return 1