Skip to content
Snippets Groups Projects
Commit 41c0557b authored by bodzsoaa's avatar bodzsoaa
Browse files

More in depth tutorial

parent a2e73fea
No related branches found
No related tags found
No related merge requests found
Showing
with 82 additions and 1 deletion
import sys
from PySide2.QtWidgets import QApplication, QMainWindow
from PySide2.QtCore import QFile, QByteArray
from PySide2.QtNetwork import QTcpSocket
from ui_mainwindow import Ui_MainWindow
......
main2.py 0 → 100644
import sys
from PySide2.QtWidgets import *
from PySide2.QtNetwork import QTcpSocket
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
# Add components
self.layout = QVBoxLayout(self)
self.chat = QTextEdit(self)
self.chat.setReadOnly(True)
self.lineEdit = QLineEdit(self)
self.sendButton = QPushButton(self)
self.sendButton.setText("Send")
# Connect to sendText
self.lineEdit.returnPressed.connect(self.sendText)
self.sendButton.clicked.connect(self.sendText)
# Conect TCP
self.socket = QTcpSocket(self)
self.socket.connectToHost("localhost", 33000)
self.socket.readyRead.connect(self.readText)
# Set layout
self.layout.addWidget(self.chat)
self.layout.addWidget(self.lineEdit)
self.layout.addWidget(self.sendButton)
# Set window settings
self.setWindowTitle("kszképzés chat")
self.setLayout(self.layout)
self.resize(350, 350)
# Read text over TCP
def readText(self):
data = self.socket.readAll()
self.chat.append(str(data, 'utf-8'))
# Write text text over TCP
def sendText(self):
self.socket.write(self.lineEdit.text().encode('utf-8'))
self.lineEdit.clear()
# Send quit when the window is closed
def closeEvent(self, event):
self.socket.write("{quit}".encode('utf-8'))
if __name__ == "__main__":
app = QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())
\ No newline at end of file
{
"app_name": "chat",
"author": "Bodnár Zsombor",
"main_module": "src/main/python/main.py",
"version": "1"
}
\ No newline at end of file
{
"categories": "Utility;",
"description": "",
"author_email": "",
"url": ""
}
\ No newline at end of file
{
"mac_bundle_identifier": ""
}
\ No newline at end of file
src/main/icons/Icon.ico

164 KiB

![Sample app icon](linux/128.png)
This directory contains the icons that are displayed for your app. Feel free to
change them.
The difference between the icons on Mac and the other platforms is that on Mac,
they contain a ~5% transparent margin. This is because otherwise they look too
big (eg. in the Dock or in the app switcher).
You can create Icon.ico from the .png files with
[an online tool](http://icoconvert.com/Multi_Image_to_one_icon/).
\ No newline at end of file
src/main/icons/base/16.png

544 B

src/main/icons/base/24.png

783 B

src/main/icons/base/32.png

912 B

src/main/icons/base/48.png

1.46 KiB

src/main/icons/base/64.png

1.62 KiB

src/main/icons/linux/1024.png

26.2 KiB

src/main/icons/linux/128.png

3.1 KiB

src/main/icons/linux/256.png

5.51 KiB

src/main/icons/linux/512.png

11.4 KiB

src/main/icons/mac/1024.png

46.2 KiB

src/main/icons/mac/128.png

4.86 KiB

src/main/icons/mac/128@2x.png

10 KiB

src/main/icons/mac/16@2x.png

912 B

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment