-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI_reference-v2.py
More file actions
178 lines (151 loc) · 5.69 KB
/
Copy pathUI_reference-v2.py
File metadata and controls
178 lines (151 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import sys
from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout,
QTextEdit, QLineEdit, QPushButton, QLabel, QComboBox,
QFrame, QListWidget, QMessageBox)
from PyQt5.QtGui import QFont
from PyQt5.QtCore import Qt
class ElegantChatApp(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
# Main window configuration
self.setWindowTitle("Thunderbird AI - Elegant UI")
self.setWindowFlags(Qt.FramelessWindowHint)
self.setStyleSheet("""
QWidget {
background-color: #f5f5f5;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
""")
# Main layout
main_layout = QHBoxLayout(self)
main_layout.setContentsMargins(0, 0, 0, 0)
main_layout.setSpacing(0)
# Sidebar with elegant design
sidebar = QFrame()
sidebar.setStyleSheet("""
QFrame {
background-color: #ffffff;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
padding: 20px;
}
""")
sidebar.setFixedWidth(240)
sidebar_layout = QVBoxLayout(sidebar)
sidebar_layout.setSpacing(15)
# Logo/title
logo = QLabel("Thunderbird AI")
logo.setFont(QFont("SF Pro Display", 18, QFont.Bold))
logo.setStyleSheet("color: #2c3e50;")
sidebar_layout.addWidget(logo, alignment=Qt.AlignTop)
# Navigation buttons
nav_buttons = [
("🏠 Home", "#007AFF"),
("⚙ Settings", "#3498db"),
("🚪 Logout", "#e74c3c")
]
for text, color in nav_buttons:
btn = QPushButton(text)
btn.setStyleSheet(f"""
QPushButton {{
background-color: {color};
color: white;
border-radius: 8px;
padding: 12px;
font-size: 14px;
}}
QPushButton:hover {{
background-color: {self.darken_color(color, 0.8)};
}}
""")
sidebar_layout.addWidget(btn)
# Chat area
chat_area = QFrame()
chat_area.setStyleSheet("""
QFrame {
background-color: #ffffff;
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
padding: 20px;
}
""")
chat_layout = QVBoxLayout(chat_area)
chat_layout.setSpacing(15)
# Chat messages
self.chat_display = QTextEdit()
self.chat_display.setReadOnly(True)
self.chat_display.setStyleSheet("""
QTextEdit {
background-color: #f9f9f9;
border: 1px solid #e0e0e0;
border-radius: 12px;
padding: 15px;
font-size: 14px;
}
""")
chat_layout.addWidget(self.chat_display)
# Input area
input_frame = QFrame()
input_frame.setStyleSheet("QFrame { background-color: #ffffff; border-radius: 12px; }")
input_layout = QHBoxLayout(input_frame)
self.input_field = QLineEdit()
self.input_field.setPlaceholderText("Type your message...")
self.input_field.setStyleSheet("""
QLineEdit {
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 12px;
font-size: 14px;
}
""")
input_layout.addWidget(self.input_field, 3)
send_btn = QPushButton("Send")
send_btn.setStyleSheet("""
QPushButton {
background-color: #007AFF;
color: white;
border-radius: 8px;
padding: 12px;
font-size: 14px;
}
QPushButton:hover {
background-color: #005fa3;
}
""")
input_layout.addWidget(send_btn, 1)
chat_layout.addWidget(input_frame)
# Add components to main layout
main_layout.addWidget(sidebar)
main_layout.addWidget(chat_area)
# Connect signals
send_btn.clicked.connect(self.send_message)
def darken_color(self, hex_color, factor):
"""Darken a hex color by a given factor"""
if hex_color.startswith("#"):
hex_color = hex_color[1:]
r = int(hex_color[0:2], 16)
g = int(hex_color[2:4], 16)
b = int(hex_color[4:6], 16)
r = int(r * factor)
g = int(g * factor)
b = int(b * factor)
return f"#{r:02x}{g:02x}{b:02x}"
def send_message(self):
message = self.input_field.text().strip()
if not message:
return
# Add message to chat
self.chat_display.append(f"<div style='margin-bottom: 10px;'><strong>You:</strong> {message}</div>")
self.input_field.clear()
# Simulate bot response
self.chat_display.append(f"<div style='margin-bottom: 10px;'><strong>Bot:</strong> This is a simulated response to your message: '{message}'</div>")
# Scroll to bottom
self.chat_display.verticalScrollBar().setValue(self.chat_display.verticalScrollBar().maximum())
if __name__ == '__main__':
app = QApplication(sys.argv)
window = ElegantChatApp()
window.resize(1000, 600)
window.show()
sys.exit(app.exec_())