コード例 #1
0
ファイル: chat.py プロジェクト: neoel/towel
    def __init__(self):
        super(Chat, self).__init__()

        self.username = None
        
        self.messages = ListView()
        chat_input = LineEdit('Type Here')
        n_input = LineEdit("You can't here")
        
        self.users = ListView()
        user  = LineEdit("Name")
        
        n_input.disabled = True
        
        chat_input.textEntered.connect(self.on_input)
        chat_input.textEntered.connect(chat_input.clear)
        
        chat_input.valueChanged.connect(n_input.setValue)
        
        user.textEntered.connect(self.name_change)
        
        chat_layout = VLayout(self.messages, chat_input, n_input)
        user_layout = VLayout(self.users, user)
        
        self.layout = HLayout(chat_layout, user_layout)
        
        print "Connecting to server"
        self.chatServer = Connection('Chat', self)
コード例 #2
0
ファイル: __init__.py プロジェクト: neoel/towel
class LoL(App):
    def __init__(self):
        self.server = Connection("LoLAPI", self)

        self.user         = LineEdit("Username")
        self.status       = ListView()
        self.user_stats   = ListView()
        self.recent_games = ListView()

        self.user.textEntered.connect(self.server.set_user)
        
        
        self.layout = VLayout(
            HLayout(self.status, self.user),
            HLayout(self.user_stats, self.recent_games)
        )
        self.server.status()
        
            
    def update_status(self, status):
        status = py(status)
        l = []
        for k in status:
            l.append(k + ": " + str(status[k]))
        self.status.replace(l)
        #print "Update status", status
        
    def update_games(self, data):
        self.recent_games.replace(data)
コード例 #3
0
ファイル: chat.py プロジェクト: neoel/towel
class Chat(App):
    def __init__(self):
        super(Chat, self).__init__()

        self.username = None
        
        self.messages = ListView()
        chat_input = LineEdit('Type Here')
        n_input = LineEdit("You can't here")
        
        self.users = ListView()
        user  = LineEdit("Name")
        
        n_input.disabled = True
        
        chat_input.textEntered.connect(self.on_input)
        chat_input.textEntered.connect(chat_input.clear)
        
        chat_input.valueChanged.connect(n_input.setValue)
        
        user.textEntered.connect(self.name_change)
        
        chat_layout = VLayout(self.messages, chat_input, n_input)
        user_layout = VLayout(self.users, user)
        
        self.layout = HLayout(chat_layout, user_layout)
        
        print "Connecting to server"
        self.chatServer = Connection('Chat', self)

    def name_change(self, name):
        name = py(name)
#        if not self.username: 
#            lineAdded("welcome: " + py(name))
#        else:
#            lineAdded(self.username + " changed name to: " + py(name))
        self.chatServer.name_changed(name)
        self.username = name
        
    def update_users(self, users):
        self.users.replace(users)
        
    def on_message(self, line):
        self.messages.addItem(line)

    def on_input(self, line):
        line = py(line)
        if line and self.username:
            self.chatServer.on_message(self.username + ": " + line)
コード例 #4
0
ファイル: __init__.py プロジェクト: neoel/towel
    def __init__(self):
        self.server = Connection("LoLAPI", self)

        self.user         = LineEdit("Username")
        self.status       = ListView()
        self.user_stats   = ListView()
        self.recent_games = ListView()

        self.user.textEntered.connect(self.server.set_user)
        
        
        self.layout = VLayout(
            HLayout(self.status, self.user),
            HLayout(self.user_stats, self.recent_games)
        )
        self.server.status()