Commit 17a635d6 authored by Agrigor's avatar Agrigor

Add some basic GUI functions

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