#!/usr/bin/env python
#Import stuff
import pygtk
pygtk.require('2.0')
import gtk
import function
import thread
import server
#Set a few needed variables
version = 0.01
name = "CatchX" #Just if we have to change the name for somewhat reason
port = 20211
#The code
print "Starting " + name + " v" + str(version)
#Now we ask the user whether he wants to connect to an exisiting server or if he wants to create one
def echo(lock):
print("Hello World");
class catchx:
def startbuttons_callback(self, widget, data=None):
print "button %s was pressed" % data
if data != "cgame":
lock = thread.allocate_lock()
lock.acquire()
thread.start_new_thread(server.open_server, (str(port),lock)) #The server runs in a new thread...
lock.release()
#thread.start_new_thread(echo, (lock,))
else:
return
def __init__(self):
cliwindow = function.create_window(name)
hbox = gtk.HBox(False, 0)
cliwindow.add(hbox)
cnbutton = gtk.Button("Zu Spiel verbinden")
crbutton = gtk.Button("Neues Spiel starten")
cnbutton.connect("clicked", self.startbuttons_callback, "cgame")
crbutton.connect("clicked", self.startbuttons_callback, "ngame")
hbox.pack_start(cnbutton, True, True, 0)
hbox.pack_start(crbutton, True, True, 0)
cliwindow.show_all()
cliwindow.connect("destroy", lambda wid: gtk.main_quit())
def main():
gtk.main()
return 0
if __name__ == "__main__":
catchx()
main()
# - to be added :D
createserver = 1 #or 0 ;)