Commit 17a635d6 authored by Agrigor's avatar Agrigor

Add some basic GUI functions

parent 6c5cd8de
......@@ -16,7 +16,10 @@
<property name="windowTitle">
<string>Hacker Jeopardy</string>
</property>
<widget class="QPushButton" name="I_OK_Button">
<widget class="QPushButton" name="I_Start">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>10</x>
......@@ -67,6 +70,9 @@
<property name="cursorPosition">
<number>0</number>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="placeholderText">
<string/>
</property>
......@@ -92,6 +98,9 @@
<layout class="QVBoxLayout" name="Input_PlayerNames">
<item>
<widget class="QLineEdit" name="I_NamePlayer1">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string/>
</property>
......@@ -102,6 +111,9 @@
</item>
<item>
<widget class="QLineEdit" name="I_NamePlayer2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
......@@ -112,6 +124,9 @@
</item>
<item>
<widget class="QLineEdit" name="I_NamePlayer3">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
......@@ -122,6 +137,9 @@
</item>
<item>
<widget class="QLineEdit" name="I_NamePlayer4">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
......@@ -132,16 +150,16 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="layoutWidget">
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<x>11</x>
<y>60</y>
<width>321</width>
<height>45</height>
</rect>
</property>
<layout class="QVBoxLayout" name="Input_NumberOfPlayers">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
......@@ -165,6 +183,9 @@
</item>
<item>
<widget class="QSlider" name="I_NumberOfPlayers">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimum">
<number>1</number>
</property>
......@@ -184,7 +205,7 @@
<zorder>splitter</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>I_OK_Button</zorder>
<zorder>I_Start</zorder>
</widget>
<tabstops>
<tabstop>I_IPAdress</tabstop>
......@@ -194,6 +215,7 @@
<tabstop>I_NamePlayer2</tabstop>
<tabstop>I_NamePlayer3</tabstop>
<tabstop>I_NamePlayer4</tabstop>
<tabstop>I_Start</tabstop>
</tabstops>
<resources/>
<connections>
......@@ -204,8 +226,8 @@
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>210</x>
<y>93</y>
<x>212</x>
<y>103</y>
</hint>
<hint type="destinationlabel">
<x>190</x>
......
......@@ -48,6 +48,10 @@ class Comunication:
def cleanup(self):
self.__socket.close()
class Player:
def __init__(self, Name):
self.Points = 0
self.Name = Name
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -60,19 +64,43 @@ class GUI:
self.UI_Start = loadUi("GUIs/start.ui")
self.socketCreated = False
self.players = []
self.UI_Start.connect(self.UI_Start.I_Connect, SIGNAL("clicked()"), self.connect)
self.UI_Start.connect(self.UI_Start.I_Start, SIGNAL("clicked()"), self.start)
self.UI_Start.connect(self.UI_Start.I_NumberOfPlayers, SIGNAL("valueChanged(int)"), self.show_names_input)
self.UI_Start.show()
self.app.exec_()
self.app.aboutToQuit(self.cleanup())
def show_names_input(self, number):
number -= 1
playerInputs = [self.UI_Start.I_NamePlayer1,
self.UI_Start.I_NamePlayer2,
self.UI_Start.I_NamePlayer3,
self.UI_Start.I_NamePlayer4]
for i in range (len(playerInputs)):
if i <= number:
playerInputs[i].setDisabled(False)
else:
playerInputs[i].setDisabled(True)
def start(self):
namesOfPlayers = [str(self.UI_Start.I_NamePlayer1.text()),
str(self.UI_Start.I_NamePlayer2.text()),
str(self.UI_Start.I_NamePlayer3.text()),
str(self.UI_Start.I_NamePlayer4.text())]
for i in range (0, int(self.UI_Start.O_NumberOfPlayers.text())):
self.players.append(Player(namesOfPlayers[i]))
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
self.UI_Start.I_Start.setDisabled(False)
else:
print("First argument was no valid IP-address")
self.socketCreated = False
......
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