Skip to content

Commit 239b5b2

Browse files
committed
PDF analysis developed
1 parent c9aad83 commit 239b5b2

13 files changed

+347
-72
lines changed

TestDemo-2/DashboardTestDemo.ui

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ border:none;
117117
#scrollAreaWidgetContents{
118118
background: #F0F8FF;
119119
}
120+
#file_btn{
121+
border: none;
122+
border-radius: 5px;
123+
background:#0A676C;
124+
padding: 5px;
125+
}
126+
#file_btn:hover{
127+
background: #507e7a;
128+
}
120129

121130

122131

@@ -778,6 +787,32 @@ background: #F0F8FF;
778787
</property>
779788
</spacer>
780789
</item>
790+
<item>
791+
<widget class="QPushButton" name="file_btn">
792+
<property name="minimumSize">
793+
<size>
794+
<width>0</width>
795+
<height>30</height>
796+
</size>
797+
</property>
798+
<property name="cursor">
799+
<cursorShape>PointingHandCursor</cursorShape>
800+
</property>
801+
<property name="text">
802+
<string/>
803+
</property>
804+
<property name="icon">
805+
<iconset resource="Icons/rescources2.qrc">
806+
<normaloff>:/icons/paperclip.svg</normaloff>:/icons/paperclip.svg</iconset>
807+
</property>
808+
<property name="iconSize">
809+
<size>
810+
<width>20</width>
811+
<height>20</height>
812+
</size>
813+
</property>
814+
</widget>
815+
</item>
781816
<item>
782817
<widget class="QFrame" name="input_frame">
783818
<property name="frameShape">

TestDemo-2/DashboardTestDemo_ui.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Form implementation generated from reading ui file 'c:\Users\MD. SHAMIM\Documents\GitHub\Python-GUI-PyQt6\TestDemo-2\DashboardTestDemo.ui'
22
#
3-
# Created by: PyQt6 UI code generator 6.4.2
3+
# Created by: PyQt6 UI code generator 6.5.2
44
#
55
# WARNING: Any manual changes made to this file will be lost when pyuic6 is
66
# run again. Do not edit this file unless you know what you are doing.
@@ -116,6 +116,15 @@ def setupUi(self, MainWindow):
116116
"#scrollAreaWidgetContents{\n"
117117
"background: #F0F8FF;\n"
118118
"}\n"
119+
"#file_btn{\n"
120+
"border: none;\n"
121+
"border-radius: 5px;\n"
122+
"background:#0A676C;\n"
123+
"padding: 5px;\n"
124+
"}\n"
125+
"#file_btn:hover{\n"
126+
"background: #507e7a;\n"
127+
"}\n"
119128
"\n"
120129
"\n"
121130
"\n"
@@ -379,6 +388,16 @@ def setupUi(self, MainWindow):
379388
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
380389
spacerItem4 = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Minimum)
381390
self.horizontalLayout_3.addItem(spacerItem4)
391+
self.file_btn = QtWidgets.QPushButton(parent=self.frame_10)
392+
self.file_btn.setMinimumSize(QtCore.QSize(0, 30))
393+
self.file_btn.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
394+
self.file_btn.setText("")
395+
icon2 = QtGui.QIcon()
396+
icon2.addPixmap(QtGui.QPixmap(":/icons/paperclip.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
397+
self.file_btn.setIcon(icon2)
398+
self.file_btn.setIconSize(QtCore.QSize(20, 20))
399+
self.file_btn.setObjectName("file_btn")
400+
self.horizontalLayout_3.addWidget(self.file_btn)
382401
self.input_frame = QtWidgets.QFrame(parent=self.frame_10)
383402
self.input_frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
384403
self.input_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
@@ -399,9 +418,9 @@ def setupUi(self, MainWindow):
399418
self.send_btn.setMaximumSize(QtCore.QSize(16777215, 16777215))
400419
self.send_btn.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
401420
self.send_btn.setText("")
402-
icon2 = QtGui.QIcon()
403-
icon2.addPixmap(QtGui.QPixmap(":/icons/send-message (2).png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
404-
self.send_btn.setIcon(icon2)
421+
icon3 = QtGui.QIcon()
422+
icon3.addPixmap(QtGui.QPixmap(":/icons/send-message (2).png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
423+
self.send_btn.setIcon(icon3)
405424
self.send_btn.setIconSize(QtCore.QSize(18, 18))
406425
self.send_btn.setObjectName("send_btn")
407426
self.horizontalLayout_8.addWidget(self.send_btn)

TestDemo-2/Icons/paperclip.svg

Lines changed: 1 addition & 0 deletions
Loading
0 Bytes
Binary file not shown.
84 Bytes
Binary file not shown.
347 Bytes
Binary file not shown.
1.26 KB
Binary file not shown.

TestDemo-2/ai_chat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#---------------Open Ai--------------------
22

33
# import openai
4-
# api_key = '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'
4+
# api_key = 'key'
55
# openai.api_key = api_key
66

77
# def get_response(input_str, system_message=""):

TestDemo-2/chat_window.py

Lines changed: 93 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ def __init__(self, parent=None, chat_obj=None, chat_data=None):
5151
QWidget {
5252
background: transparent;
5353
}
54-
5554
"""
5655

5756
self.setStyleSheet(self.style_str)
5857

59-
self.chats_data = { # Initialize chats_data as an empty dictionary
58+
self.chats_data = {
6059
"title": "",
6160
"chatlist": []
6261
}
@@ -66,36 +65,101 @@ def __init__(self, parent=None, chat_obj=None, chat_data=None):
6665
self.chats_data["chatlist"] += self.chat_data["chatlist"]
6766

6867
self.show_chats()
68+
6969
def show_chats(self):
70-
# chat_title = self.chats_data.get("title")
71-
chat_list = self.chats_data.get("chatlist")
72-
for chat in chat_list:
73-
input_str = chat.get("input_str")
74-
input_widget = InputWidget(chat_obj=self.chat_object)
75-
input_widget.set_input_text(input_str)
76-
self.main_verticalLayout.addWidget(input_widget)
77-
78-
out_str = chat.get("output_str")
79-
out_widget = OutWidget()
80-
# markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.tables'])
70+
chat_list = self.chats_data.get("chatlist")
71+
for chat in chat_list:
72+
input_str = chat.get("input_str")
73+
input_widget = InputWidget(chat_obj=self.chat_object)
74+
input_widget.set_input_text(input_str)
75+
self.main_verticalLayout.addWidget(input_widget)
76+
77+
out_str = chat.get("output_str")
78+
out_widget = OutWidget()
79+
80+
markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.attr_list'])
81+
markdown_text = markdown_text.replace('<table>', '<table style="border: 1px solid white; padding: 10px; border-collapse: collapse;">')
82+
markdown_text = markdown_text.replace('<th>', '<th style="border: 1px solid white; padding: 10px;">')
83+
markdown_text = markdown_text.replace('<td>', '<td style="border: 1px solid white; padding: 10px;">')
84+
out_widget.set_output_text(markdown_text)
85+
self.main_verticalLayout.addWidget(out_widget)
86+
87+
attached_pdf_info = chat.get("pdf_info")
88+
if attached_pdf_info:
89+
pdf_widget = OutWidget()
90+
pdf_widget.set_output_text(attached_pdf_info)
91+
self.main_verticalLayout.addWidget(pdf_widget)
92+
93+
spacerItem = QSpacerItem(20, 300, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
94+
self.main_verticalLayout.addItem(spacerItem)
95+
self.setLayout(self.main_verticalLayout)
96+
97+
# class ChatWindow(QWidget):
98+
# def __init__(self, parent=None, chat_obj=None, chat_data=None):
99+
# super().__init__(parent)
100+
# self.chat_object = chat_obj
101+
# self.chat_data = chat_data
102+
103+
# self.main_verticalLayout = QVBoxLayout(self)
104+
# self.main_verticalLayout.setContentsMargins(0, 0, 0, 0)
105+
# self.main_verticalLayout.setSpacing(0)
106+
# self.main_verticalLayout.setObjectName("main_verticalLayout")
107+
108+
# self.style_str = """
109+
# QPushButton,
110+
# QLabel {
111+
# border: none;
112+
# padding: 5px;
113+
# }
114+
115+
# QWidget {
116+
# background: transparent;
117+
# }
118+
119+
# """
120+
121+
# self.setStyleSheet(self.style_str)
122+
123+
# self.chats_data = { # Initialize chats_data as an empty dictionary
124+
# "title": "",
125+
# "chatlist": []
126+
# }
127+
128+
# if self.chat_data:
129+
# self.chats_data["title"] = self.chat_data["title"]
130+
# self.chats_data["chatlist"] += self.chat_data["chatlist"]
131+
132+
# self.show_chats()
133+
# def show_chats(self):
134+
# # chat_title = self.chats_data.get("title")
135+
# chat_list = self.chats_data.get("chatlist")
136+
# for chat in chat_list:
137+
# input_str = chat.get("input_str")
138+
# input_widget = InputWidget(chat_obj=self.chat_object)
139+
# input_widget.set_input_text(input_str)
140+
# self.main_verticalLayout.addWidget(input_widget)
141+
142+
# out_str = chat.get("output_str")
143+
# out_widget = OutWidget()
144+
# # markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.tables'])
81145

82-
markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.attr_list'])
146+
# markdown_text = markdown(out_str, extensions=['markdown.extensions.extra', 'markdown.extensions.attr_list'])
83147

84-
# Add the custom attributes for the table, th, and td elements
85-
markdown_text = markdown_text.replace('<table>', '<table style="border: 1px solid white; padding: 10px; border-collapse: collapse;">')
86-
markdown_text = markdown_text.replace('<th>', '<th style="border: 1px solid white; padding: 10px;">')
87-
markdown_text = markdown_text.replace('<td>', '<td style="border: 1px solid white; padding: 10px;">')
88-
out_widget.set_output_text(markdown_text)
89-
self.main_verticalLayout.addWidget(out_widget)
90-
91-
# out_str = chat.get("output_str")
92-
# out_widget = OutWidget()
93-
# out_widget.set_output_text(out_str)
94-
# self.main_verticalLayout.addWidget(out_widget)
95-
96-
spacerItem = QSpacerItem(20, 300, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
97-
self.main_verticalLayout.addItem(spacerItem)
98-
self.setLayout(self.main_verticalLayout)
148+
# # Add the custom attributes for the table, th, and td elements
149+
# markdown_text = markdown_text.replace('<table>', '<table style="border: 1px solid white; padding: 10px; border-collapse: collapse;">')
150+
# markdown_text = markdown_text.replace('<th>', '<th style="border: 1px solid white; padding: 10px;">')
151+
# markdown_text = markdown_text.replace('<td>', '<td style="border: 1px solid white; padding: 10px;">')
152+
# out_widget.set_output_text(markdown_text)
153+
# self.main_verticalLayout.addWidget(out_widget)
154+
155+
# # out_str = chat.get("output_str")
156+
# # out_widget = OutWidget()
157+
# # out_widget.set_output_text(out_str)
158+
# # self.main_verticalLayout.addWidget(out_widget)
159+
160+
# spacerItem = QSpacerItem(20, 300, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)
161+
# self.main_verticalLayout.addItem(spacerItem)
162+
# self.setLayout(self.main_verticalLayout)
99163

100164
# def show_chats(self):
101165
# chat_list = self.chats_data.get("chatlist")

TestDemo-2/datas/data.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

TestDemo-2/home_widget.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ def setupUi(self, MainWindow):
114114
"#right_main_widget,\n"
115115
"#scrollAreaWidgetContents{\n"
116116
"background: #F0F8FF;\n"
117+
"}\n""#file_btn{\n"
118+
"border: none;\n"
119+
"border-radius: 5px;\n"
120+
"background:#0A676C;\n"
121+
"padding: 5px;\n"
122+
"}\n"
123+
"#file_btn:hover{\n"
124+
"background: #507e7a;\n"
117125
"}\n"
118126
"\n"
119127
"\n"
@@ -395,6 +403,16 @@ def setupUi(self, MainWindow):
395403
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
396404
spacerItem4 = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Policy.Preferred, QtWidgets.QSizePolicy.Policy.Minimum)
397405
self.horizontalLayout_3.addItem(spacerItem4)
406+
self.file_btn = QtWidgets.QPushButton(parent=self.frame_10)
407+
self.file_btn.setMinimumSize(QtCore.QSize(0, 30))
408+
self.file_btn.setCursor(QtGui.QCursor(QtCore.Qt.CursorShape.PointingHandCursor))
409+
self.file_btn.setText("")
410+
icon2 = QtGui.QIcon()
411+
icon2.addPixmap(QtGui.QPixmap("icons/paperclip.svg"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
412+
self.file_btn.setIcon(icon2)
413+
self.file_btn.setIconSize(QtCore.QSize(20, 20))
414+
self.file_btn.setObjectName("file_btn")
415+
self.horizontalLayout_3.addWidget(self.file_btn)
398416
self.input_frame = QtWidgets.QFrame(parent=self.frame_10)
399417
self.input_frame.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
400418
self.input_frame.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)

0 commit comments

Comments
 (0)