Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-kszkepzes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bodzsoaa
python-kszkepzes
Commits
a2e73fea
Commit
a2e73fea
authored
Mar 25, 2019
by
bodzsoaa
Browse files
Options
Downloads
Patches
Plain Diff
Connect close button, small fix in server.py
parent
b9b92b86
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
main.py
+6
-1
6 additions, 1 deletion
main.py
mainwindow.ui
+2
-2
2 additions, 2 deletions
mainwindow.ui
server.py
+4
-0
4 additions, 0 deletions
server.py
ui_mainwindow.py
+10
-10
10 additions, 10 deletions
ui_mainwindow.py
with
22 additions
and
13 deletions
main.py
+
6
−
1
View file @
a2e73fea
...
...
@@ -10,10 +10,11 @@ class MainWindow(QMainWindow):
self
.
ui
=
Ui_MainWindow
()
self
.
ui
.
setupUi
(
self
)
self
.
socket
=
QTcpSocket
()
self
.
socket
=
QTcpSocket
(
self
)
self
.
socket
.
connectToHost
(
"
localhost
"
,
33000
)
self
.
socket
.
readyRead
.
connect
(
self
.
readText
)
self
.
ui
.
lineEdit
.
returnPressed
.
connect
(
self
.
sendText
)
self
.
ui
.
sendButton
.
clicked
.
connect
(
self
.
sendText
)
def
readText
(
self
):
data
=
self
.
socket
.
readAll
()
...
...
@@ -21,6 +22,10 @@ class MainWindow(QMainWindow):
def
sendText
(
self
):
self
.
socket
.
write
(
self
.
ui
.
lineEdit
.
text
().
encode
(
'
utf-8
'
))
self
.
ui
.
lineEdit
.
clear
()
def
closeEvent
(
self
,
event
):
self
.
socket
.
write
(
"
{quit}
"
.
encode
(
'
utf-8
'
))
if
__name__
==
"
__main__
"
:
app
=
QApplication
(
sys
.
argv
)
...
...
This diff is collapsed.
Click to expand it.
mainwindow.ui
+
2
−
2
View file @
a2e73fea
...
...
@@ -23,7 +23,7 @@
</widget>
</item>
<item>
<widget
class=
"Line"
name=
"line
_2
"
>
<widget
class=
"Line"
name=
"line"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
...
...
@@ -33,7 +33,7 @@
<widget
class=
"QLineEdit"
name=
"lineEdit"
/>
</item>
<item>
<widget
class=
"QPushButton"
name=
"
push
Button"
>
<widget
class=
"QPushButton"
name=
"
send
Button"
>
<property
name=
"text"
>
<string>
Send
</string>
</property>
...
...
This diff is collapsed.
Click to expand it.
server.py
+
4
−
0
View file @
a2e73fea
...
...
@@ -18,6 +18,10 @@ def handle_client(client): # Takes client socket as argument.
"""
Handles a single client connection.
"""
name
=
client
.
recv
(
BUFSIZ
).
decode
(
"
utf8
"
)
if
(
name
==
"
{quit}
"
):
client
.
close
()
return
welcome
=
'
Welcome %s! If you ever want to quit, type {quit} to exit.
'
%
name
client
.
send
(
bytes
(
welcome
,
"
utf8
"
))
msg
=
"
%s has joined the chat!
"
%
name
...
...
This diff is collapsed.
Click to expand it.
ui_mainwindow.py
+
10
−
10
View file @
a2e73fea
...
...
@@ -3,7 +3,7 @@
# Form implementation generated from reading ui file 'mainwindow.ui',
# licensing of 'mainwindow.ui' applies.
#
# Created: Mon Mar 25
19:25:45
2019
# Created: Mon Mar 25
20:14:33
2019
# by: pyside2-uic running on PySide2 5.12.2
#
# WARNING! All changes made in this file will be lost!
...
...
@@ -22,17 +22,17 @@ class Ui_MainWindow(object):
self
.
chat
.
setReadOnly
(
True
)
self
.
chat
.
setObjectName
(
"
chat
"
)
self
.
verticalLayout
.
addWidget
(
self
.
chat
)
self
.
line
_2
=
QtWidgets
.
QFrame
(
self
.
centralwidget
)
self
.
line
_2
.
setFrameShape
(
QtWidgets
.
QFrame
.
HLine
)
self
.
line
_2
.
setFrameShadow
(
QtWidgets
.
QFrame
.
Sunken
)
self
.
line
_2
.
setObjectName
(
"
line
_2
"
)
self
.
verticalLayout
.
addWidget
(
self
.
line
_2
)
self
.
line
=
QtWidgets
.
QFrame
(
self
.
centralwidget
)
self
.
line
.
setFrameShape
(
QtWidgets
.
QFrame
.
HLine
)
self
.
line
.
setFrameShadow
(
QtWidgets
.
QFrame
.
Sunken
)
self
.
line
.
setObjectName
(
"
line
"
)
self
.
verticalLayout
.
addWidget
(
self
.
line
)
self
.
lineEdit
=
QtWidgets
.
QLineEdit
(
self
.
centralwidget
)
self
.
lineEdit
.
setObjectName
(
"
lineEdit
"
)
self
.
verticalLayout
.
addWidget
(
self
.
lineEdit
)
self
.
push
Button
=
QtWidgets
.
QPushButton
(
self
.
centralwidget
)
self
.
push
Button
.
setObjectName
(
"
push
Button
"
)
self
.
verticalLayout
.
addWidget
(
self
.
push
Button
)
self
.
send
Button
=
QtWidgets
.
QPushButton
(
self
.
centralwidget
)
self
.
send
Button
.
setObjectName
(
"
send
Button
"
)
self
.
verticalLayout
.
addWidget
(
self
.
send
Button
)
MainWindow
.
setCentralWidget
(
self
.
centralwidget
)
self
.
menubar
=
QtWidgets
.
QMenuBar
(
MainWindow
)
self
.
menubar
.
setGeometry
(
QtCore
.
QRect
(
0
,
0
,
413
,
21
))
...
...
@@ -47,5 +47,5 @@ class Ui_MainWindow(object):
def
retranslateUi
(
self
,
MainWindow
):
MainWindow
.
setWindowTitle
(
QtWidgets
.
QApplication
.
translate
(
"
MainWindow
"
,
"
MainWindow
"
,
None
,
-
1
))
self
.
push
Button
.
setText
(
QtWidgets
.
QApplication
.
translate
(
"
MainWindow
"
,
"
Send
"
,
None
,
-
1
))
self
.
send
Button
.
setText
(
QtWidgets
.
QApplication
.
translate
(
"
MainWindow
"
,
"
Send
"
,
None
,
-
1
))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment