Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Hacksaar
Jeopardy
Commits
17a635d6
Commit
17a635d6
authored
Jul 27, 2015
by
Agrigor
Browse files
Add some basic GUI functions
parent
6c5cd8de
Changes
2
Hide whitespace changes
Inline
Side-by-side
client/GUIs/start.ui
View file @
17a635d6
...
...
@@ -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>
1
0
</x>
<x>
1
1
</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>
21
0
</x>
<y>
9
3
</y>
<x>
21
2
</x>
<y>
10
3
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
190
</x>
...
...
client/gui.py
View file @
17a635d6
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment