Commit e38c0a02 authored by Agrigor's avatar Agrigor

Added some new Start_GUI functions

parent a8c6dfde
[Dolphin]
PreviewsShown=true
Timestamp=2015,11,17,0,56,35
Version=3
ViewMode=1
[Settings]
HiddenFilesShown=true
......@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>339</width>
<height>262</height>
<height>299</height>
</rect>
</property>
<property name="windowTitle">
......@@ -99,7 +99,7 @@
<item>
<widget class="QLineEdit" name="I_NamePlayer1">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="text">
<string/>
......@@ -150,7 +150,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>11</x>
......@@ -184,7 +184,7 @@
<item>
<widget class="QSlider" name="I_NumberOfPlayers">
<property name="enabled">
<bool>true</bool>
<bool>false</bool>
</property>
<property name="minimum">
<number>1</number>
......@@ -202,11 +202,55 @@
</item>
</layout>
</widget>
<widget class="QLabel" name="O_Msg">
<property name="geometry">
<rect>
<x>10</x>
<y>260</y>
<width>321</width>
<height>31</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
<widget class="KSeparator" name="kseparator">
<property name="geometry">
<rect>
<x>10</x>
<y>250</y>
<width>321</width>
<height>20</height>
</rect>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
</widget>
<zorder>splitter</zorder>
<zorder>layoutWidget</zorder>
<zorder>layoutWidget</zorder>
<zorder>I_Start</zorder>
<zorder>O_Msg</zorder>
<zorder>kseparator</zorder>
</widget>
<customwidgets>
<customwidget>
<class>KSeparator</class>
<extends>QFrame</extends>
<header>kseparator.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>I_IPAdress</tabstop>
<tabstop>I_Connect</tabstop>
......
#!/usr/bin/python
#!/usr/bin/python3
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~ IMPORT LIBRARIES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
#!/usr/bin/python
#!/usr/bin/python3
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~ IMPORT LIBRARIES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -53,6 +53,19 @@ class Player:
self.Points = 0
self.Name = name
def get_Points(self):
return self.Points
def set_Points(self, newPoints):
self.Points = newPoints
def get_Name(self):
return self.Name
def set_Name(self, newName):
self.Name = newName
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......@@ -84,26 +97,38 @@ class StartGUI:
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.connect(self.__UI_Start.I_NamePlayer1, SIGNAL("textChanged(QString)"), self.name_player_1_changed)
self.__UI_Start.connect(self.__UI_Start.I_NumberOfPlayers, SIGNAL("valueChanged(int)"), self.show_names_input_field)
self.__UI_Start.connect(self.__UI_Start.I_NamePlayer1, SIGNAL("textChanged(QString)"), self.name_player_changed)
self.__UI_Start.connect(self.__UI_Start.I_NamePlayer2, SIGNAL("textChanged(QString)"), self.name_player_changed)
self.__UI_Start.connect(self.__UI_Start.I_NamePlayer3, SIGNAL("textChanged(QString)"), self.name_player_changed)
self.__UI_Start.connect(self.__UI_Start.I_NamePlayer4, SIGNAL("textChanged(QString)"), self.name_player_changed)
self.__UI_Start.show()
def name_player_1_changed(self, name):
if int(self.__UI_Start.O_NumberOfPlayers.text()) == 1 and self.socketCreated and len(str(self.__UI_Start.I_NamePlayer1.text())) > 1:
def name_player_changed(self, name):
sender = self.__UI_Start.sender()
self.__UI_Start.O_Msg.setText(str(sender.text()))
# TODO
if len(str(sender.text())) > 1:
self.__UI_Start.I_Start.setDisabled(False)
else:
self.__UI_Start.I_Start.setDisabled(True)
def show_names_input(self, number):
def show_names_input_field(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:
if i <= number and self.socketCreated:
playerInputs[i].setDisabled(False)
else:
playerInputs[i].setDisabled(True)
if number >= 1:
self.__UI_Start.O_Msg.setText(str(number + 1) + " Players")
else:
self.__UI_Start.O_Msg.setText("1 Player")
def start(self):
namesOfPlayers = [str(self.__UI_Start.I_NamePlayer1.text()),
......@@ -115,13 +140,16 @@ class StartGUI:
def connect(self):
self.UDP = Comunication(str(self.__UI_Start.I_IPAdress.text()), PORT)
if self.UDP.check_ip():
if self.UDP.check_ip() and not self.socketCreated:
self.UDP.create_client_socket()
self.socketCreated = True
self.__UI_Start.I_Connect.setDisabled(True)
self.__UI_Start.O_Msg.setText("Connected")
self.__UI_Start.I_NumberOfPlayers.setDisabled(False)
self.__UI_Start.I_NamePlayer1.setDisabled(False)
else:
print("First argument was no valid IP-address")
self.__UI_Start.O_Msg.setText("No valid IP-address")
self.socketCreated = False
sys.exit(1)
def cleanup(self):
if self.socketCreated:
......
#!/usr/bin/python
#!/usr/bin/python3
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~ IMPORT LIBRARIES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
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