Commit 6c5cd8de authored by Agrigor's avatar Agrigor

First GUI implementation

parent e4fd944b
......@@ -41,7 +41,7 @@
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="Input_IPAddress">
<item>
<widget class="QLabel" name="O_Name_IPAddress_Edit">
......@@ -56,10 +56,10 @@
<string>IPv4-Adresse</string>
</property>
<property name="inputMask">
<string>000.000.000.000;0</string>
<string/>
</property>
<property name="text">
<string>...</string>
<string/>
</property>
<property name="maxLength">
<number>15</number>
......@@ -67,11 +67,8 @@
<property name="cursorPosition">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string>000000000000</string>
<string/>
</property>
</widget>
</item>
......@@ -83,13 +80,13 @@
</property>
</widget>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>110</y>
<width>321</width>
<height>101</height>
<height>102</height>
</rect>
</property>
<layout class="QVBoxLayout" name="Input_PlayerNames">
......@@ -135,13 +132,13 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>321</width>
<height>44</height>
<height>45</height>
</rect>
</property>
<layout class="QVBoxLayout" name="Input_NumberOfPlayers">
......@@ -167,7 +164,7 @@
</layout>
</item>
<item>
<widget class="QSlider" name="I_AnzahlSpieler">
<widget class="QSlider" name="I_NumberOfPlayers">
<property name="minimum">
<number>1</number>
</property>
......@@ -184,24 +181,15 @@
</item>
</layout>
</widget>
<zorder>I_IPAdress</zorder>
<zorder>I_Connect</zorder>
<zorder>I_AnzahlSpieler</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>splitter</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>I_OK_Button</zorder>
</widget>
<tabstops>
<tabstop>I_IPAdress</tabstop>
<tabstop>I_Connect</tabstop>
<tabstop>I_AnzahlSpieler</tabstop>
<tabstop>I_NumberOfPlayers</tabstop>
<tabstop>I_NamePlayer1</tabstop>
<tabstop>I_NamePlayer2</tabstop>
<tabstop>I_NamePlayer3</tabstop>
......@@ -210,7 +198,7 @@
<resources/>
<connections>
<connection>
<sender>I_AnzahlSpieler</sender>
<sender>I_NumberOfPlayers</sender>
<signal>valueChanged(int)</signal>
<receiver>O_NumberOfPlayers</receiver>
<slot>setNum(int)</slot>
......
......@@ -8,6 +8,9 @@
import sys
import threading
import socket
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.uic import *
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -51,20 +54,34 @@ class Comunication:
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Client:
def __init__(self, ip, port):
self.UDP = Comunication(ip, port)
self.UDP.create_client_socket()
class GUI:
def __init__(self):
self.app = QApplication(sys.argv)
self.UI_Start = loadUi("GUIs/start.ui")
def main(self):
try:
threading.Event().wait()
finally:
self.cleanup()
self.socketCreated = False
self.UI_Start.connect(self.UI_Start.I_Connect, SIGNAL("clicked()"), self.connect)
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):
self.UDP.cleanup()
print("\n Bye Bye")
if self.socketCreated:
self.UDP.cleanup()
print("Bye Bye")
sys.exit(0)
......@@ -74,9 +91,7 @@ class Client:
# Start Client
client = Client(IP, PORT)
client.main()
client = GUI()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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