Whenever I want to add a new message, I will append that message to the dictionary field array.
Then due to for loop messages hbox's will be re-drawn.
But problem is that all hbox's are being drawn at a time, I want to a little pause between each hbox / message.
Below is my messages data structure :
Code: Select all
$ persons = {
0 : {'Name' : 'Person1', 'relationshipPoints' : -80, 'avatarPath' : 'contacts/person1.png', 'index' : 0,
'chatHistory' :
[
[b] {'type' : 'reply-message', 'message' : 'Got your message'},
{'type' : 'forward-message', 'message' : 'Hello'},
{'type' : 'reply-message', 'message' : 'How are you'},
{'type' : 'forward-message', 'message' : 'Good how about you'},
{'type' : 'reply-message', 'message' : 'Sending image ...'},
{'type' : 'reply-image', 'imagePath' : 'chat/1.1.jpg'},
{'type' : 'reply-message', 'message' : 'The quick brown fox jumps over the lazy dog'},
{'type' : 'forward-message', 'message' : 'Good night'},
{'type' : 'reply-image', 'imagePath' : 'chat/2.2.jpg'},
{'type' : 'forward-message', 'message' : 'Bye'},
{'type' : 'reply-image', 'imagePath' : 'chat/3.1.jpg'}[/b]
],
'greetToday' : True, 'friendlyMessagesToday' : 0, 'meanMessagesToday' : 0, 'todayChatImage' : True, 'enabled' : True
},
1 : {'Name' : 'Person2', 'relationshipPoints' : -60, 'avatarPath' : 'contacts/person2.png', 'index' : 1,
'chatHistory' :
[
[b] {'type' : 'forward-message', 'message' : 'Hello'},
{'type' : 'reply-message', 'message' : 'How are you'},
{'type' : 'forward-message', 'message' : 'Good how about you'}[/b]
],
'greetToday' : True, 'friendlyMessagesToday' : 0, 'meanMessagesToday' : 0, 'todayChatImage' : True, 'enabled' : True
}
Code: Select all
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : text})
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Fine'})
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'forward-message', 'message' : "Let's meet somewhere"})
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-message', 'message' : 'Shop or Office'})
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-image', 'imagePath' : 'Shop.png'})
persons[selectedPerson["index"]]["chatHistory"].append({'type' : 'reply-image', 'imagePath' : 'Office.jpg'})
Below, is the code for hbox's :
Code: Select all
for i in selectedPerson['chatHistory']:
frame:
xsize 1150
background "transparent.png"
hbox:
spacing 10
if i['type'] == "forward-message":
xalign 1.0
frame :
background "#ffcfd2"
$tempMessage = i['message']
text "[tempMessage]" color getChatTextColor(selectedPerson['relationshipPoints'])
imagebutton:
idle Frame("icons/user.png", 0, 0)
minimum(64, 64)
maximum(64, 64)
elif i['type'] == "reply-message":
xalign 0.0
imagebutton:
idle Frame(selectedPerson['avatarPath'], 0, 0)
minimum(64, 64)
maximum(64, 64)
frame :
background "#ffcfd2"
$tempMessage = i['message']
text "[tempMessage]" color getChatTextColor(selectedPerson['relationshipPoints'])
elif i['type'] == "reply-image":
imagebutton:
idle Frame(selectedPerson['avatarPath'], 0, 0)
minimum(64, 64)
maximum(64, 64)
imagebutton:
idle Frame(i['imagePath'])
minimum(256, 144)
maximum(256, 144)
action Call("enlargeChatImage", i['imagePath']), Return(None)
Below I have also attached video for reference :
https://drive.google.com/file/d/1ObwuWK ... sp=sharing