[go: up one dir, main page]

Menu

[r29]: / main / function.py  Maximize  Restore  History

Download this file

93 lines (71 with data), 2.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import pygtk
import gtk
import os
import xmlrpclib
def create_window(window_name):
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title(window_name)
window.set_border_width(5)
return window
def init_connection(server):
print("Trying to connect to " + server)
s = xmlrpclib.ServerProxy('http://' + server + ':20211')
ping = s.ping()
if ping != "pong":
print("Error - Couldn't establish a connecting to the server.")
return False
else:
print("Connected to " + server + ':20211')
return s
def get_gamedata(s, password, name):
runs = s.running()
if runs == True:
print "Game is already running"
return "err_running"
playerid = s.connect()
print("Got assigned playerid #" + str(playerid))
auth = s.auth(playerid, password, name)
if auth == False:
print "Wrong password"
return "err_login"
players = s.get_players(playerid)
#print "Players on the server: " + str(players)
return (playerid,players)
def load_maingui(cliwindow, players, playerid): #This is the most complex GUI, the maingui...
cliwindow.maximize() #We need the complete space
clibox = gtk.VBox(False, 0)
cliwindow.add(clibox)
mapbox = gtk.VBox(False, 0)
clibox.add(mapbox)
toolbox = gtk.HBox(False, 0)
clibox.add(toolbox)
leftdnbox = gtk.VBox(False, 0)
toolbox.add(leftdnbox)
rightdnbox = gtk.VBox(False, 0)
toolbox.add(rightdnbox)
label = gtk.Label(str)
label.set_text("Mapbox")
mapbox.add(label)
label3 = gtk.Label(str)
label3.set_text("Right Toolbox")
rightdnbox.add(label3)
#The user-list
liststore = gtk.ListStore(str, str)
treeview = gtk.TreeView(liststore)
tvcolumn = gtk.TreeViewColumn('Id')
tvcolumn1 = gtk.TreeViewColumn('Name')
treeview.append_column(tvcolumn)
treeview.append_column(tvcolumn1)
for name in players:
liststore.append(i[1], i[0])
cell = gtk.CellRendererText()
cell1 = gtk.CellRendererText()
#tvcolumn.pack_start(cellpb, False)
tvcolumn.pack_start(cell, True)
tvcolumn1.pack_start(cell1, True)
tvcolumn.set_attributes(cell, text=0)
tvcolumn1.set_attributes(cell1, text=1)
treeview.set_search_column(0)
tvcolumn.set_sort_column_id(0)
leftdnbox.add(treeview)
cliwindow.show_all()