Commit 6c5cd8de authored by Agrigor's avatar Agrigor

First GUI implementation

parent e4fd944b
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="Input_IPAddress"> <layout class="QVBoxLayout" name="Input_IPAddress">
<item> <item>
<widget class="QLabel" name="O_Name_IPAddress_Edit"> <widget class="QLabel" name="O_Name_IPAddress_Edit">
...@@ -56,10 +56,10 @@ ...@@ -56,10 +56,10 @@
<string>IPv4-Adresse</string> <string>IPv4-Adresse</string>
</property> </property>
<property name="inputMask"> <property name="inputMask">
<string>000.000.000.000;0</string> <string/>
</property> </property>
<property name="text"> <property name="text">
<string>...</string> <string/>
</property> </property>
<property name="maxLength"> <property name="maxLength">
<number>15</number> <number>15</number>
...@@ -67,11 +67,8 @@ ...@@ -67,11 +67,8 @@
<property name="cursorPosition"> <property name="cursorPosition">
<number>0</number> <number>0</number>
</property> </property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText"> <property name="placeholderText">
<string>000000000000</string> <string/>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -83,13 +80,13 @@ ...@@ -83,13 +80,13 @@
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>110</y> <y>110</y>
<width>321</width> <width>321</width>
<height>101</height> <height>102</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="Input_PlayerNames"> <layout class="QVBoxLayout" name="Input_PlayerNames">
...@@ -135,13 +132,13 @@ ...@@ -135,13 +132,13 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>10</x> <x>10</x>
<y>60</y> <y>60</y>
<width>321</width> <width>321</width>
<height>44</height> <height>45</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="Input_NumberOfPlayers"> <layout class="QVBoxLayout" name="Input_NumberOfPlayers">
...@@ -167,7 +164,7 @@ ...@@ -167,7 +164,7 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QSlider" name="I_AnzahlSpieler"> <widget class="QSlider" name="I_NumberOfPlayers">
<property name="minimum"> <property name="minimum">
<number>1</number> <number>1</number>
</property> </property>
...@@ -184,24 +181,15 @@ ...@@ -184,24 +181,15 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<zorder>I_IPAdress</zorder> <zorder>splitter</zorder>
<zorder>I_Connect</zorder> <zorder>layoutWidget</zorder>
<zorder>I_AnzahlSpieler</zorder> <zorder>layoutWidget</zorder>
<zorder>O_NumberOfPlayers</zorder>
<zorder>O_Name_IPAddress_Edit</zorder>
<zorder>O_Name_NumberOfPlayers_Edit</zorder>
<zorder>I_AnzahlSpieler</zorder>
<zorder>I_AnzahlSpieler</zorder>
<zorder>I_NamePlayer1</zorder>
<zorder>I_NamePlayer2</zorder>
<zorder>I_NamePlayer3</zorder>
<zorder>I_NamePlayer4</zorder>
<zorder>I_OK_Button</zorder> <zorder>I_OK_Button</zorder>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>I_IPAdress</tabstop> <tabstop>I_IPAdress</tabstop>
<tabstop>I_Connect</tabstop> <tabstop>I_Connect</tabstop>
<tabstop>I_AnzahlSpieler</tabstop> <tabstop>I_NumberOfPlayers</tabstop>
<tabstop>I_NamePlayer1</tabstop> <tabstop>I_NamePlayer1</tabstop>
<tabstop>I_NamePlayer2</tabstop> <tabstop>I_NamePlayer2</tabstop>
<tabstop>I_NamePlayer3</tabstop> <tabstop>I_NamePlayer3</tabstop>
...@@ -210,7 +198,7 @@ ...@@ -210,7 +198,7 @@
<resources/> <resources/>
<connections> <connections>
<connection> <connection>
<sender>I_AnzahlSpieler</sender> <sender>I_NumberOfPlayers</sender>
<signal>valueChanged(int)</signal> <signal>valueChanged(int)</signal>
<receiver>O_NumberOfPlayers</receiver> <receiver>O_NumberOfPlayers</receiver>
<slot>setNum(int)</slot> <slot>setNum(int)</slot>
......
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
import sys import sys
import threading import threading
import socket import socket
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.uic import *
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...@@ -51,20 +54,34 @@ class Comunication: ...@@ -51,20 +54,34 @@ class Comunication:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Client: class GUI:
def __init__(self, ip, port): def __init__(self):
self.UDP = Comunication(ip, port) self.app = QApplication(sys.argv)
self.UDP.create_client_socket() self.UI_Start = loadUi("GUIs/start.ui")
def main(self): self.socketCreated = False
try:
threading.Event().wait() self.UI_Start.connect(self.UI_Start.I_Connect, SIGNAL("clicked()"), self.connect)
finally:
self.cleanup() self.UI_Start.show()
self.app.exec_()
self.app.aboutToQuit(self.cleanup())
def connect(self):
self.ip = str(self.UI_Start.I_IPAdress.text())
self.UDP = Comunication(self.ip, PORT)
if self.UDP.check_ip():
self.UDP.create_client_socket()
self.socketCreated = True
else:
print("First argument was no valid IP-address")
self.socketCreated = False
sys.exit(1)
def cleanup(self): def cleanup(self):
self.UDP.cleanup() if self.socketCreated:
print("\n Bye Bye") self.UDP.cleanup()
print("Bye Bye")
sys.exit(0) sys.exit(0)
...@@ -74,9 +91,7 @@ class Client: ...@@ -74,9 +91,7 @@ class Client:
# Start Client # Start Client
client = Client(IP, PORT) client = GUI()
client.main()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment