Beispiel #1
0
def figure8():
    print 'Figure 17.6'

    g = Gui()
    options = dict(side=TOP, fill=X)

    # create the widgets
    g.fr()
    la = g.la(side=TOP, text='List of colors:')
    lb = g.lb(side=LEFT)
    sb = g.sb(side=RIGHT, fill=Y)
    g.endfr()

    bu = g.bu(side=BOTTOM, text='OK', command=g.quit)

    # fill the listbox with color names
    colors = []
    for line in open('/etc/X11/rgb.txt'):
        t = line.split('\t')
        name = t[-1].strip()
        colors.append(name)

    for color in colors:
        lb.insert(END, color)

    # tell the listbox and the scrollbar about each other
    lb.configure(yscrollcommand=sb.set)
    sb.configure(command=lb.yview)

    g.mainloop()
    g.destroy()
Beispiel #2
0
def figure8():
    print 'Figure 17.6'

    g = Gui()
    options = dict(side=TOP, fill=X)

    # create the widgets
    g.fr()
    la = g.la(side=TOP, text='List of colors:')
    lb = g.lb(side=LEFT)
    sb = g.sb(side=RIGHT, fill=Y)
    g.endfr()

    bu = g.bu(side=BOTTOM, text='OK', command=g.quit)

    # fill the listbox with color names
    colors = []
    for line in open('/etc/X11/rgb.txt'):
        t = line.split('\t')
        name = t[-1].strip()
        colors.append(name)

    for color in colors:
        lb.insert(END, color)

    # tell the listbox and the scrollbar about each other
    lb.configure(yscrollcommand=sb.set)
    sb.configure(command=lb.yview)

    g.mainloop()
    g.destroy()
Beispiel #3
0
class Hwindow():
	"""Creates host/join menu."""
	def __init__(self):
		self.h = Gui() # make h window
		self.h.title('Othello!')
		self.h.la(text='Game Name (no spaces)')
		self.entryField = self.h.en()
		self.h.gr(cols=2)
		hostButton = self.h.bu(text='Host Game', command=self.host)
		joinButton = self.h.bu(text='Join Game',command=self.join)
		self.h.mainloop()

	def host(self):
		"""Creates a game w/ 2 players and 2 computers."""
		name = self.entryField.get()
		data = {
				'gameName': name
		}

		req = urllib2.Request('http://othello.herokuapp.com/createGame')
		req.add_header('Content-Type', 'application/json')

		response = urllib2.urlopen(req, json.dumps(data))
		self.h.destroy() # close h window
		os.system('python board_piece_final_tweaked1.py ' + name + ' black')

	def join(self):
		"""Joins an existing game w/ 2 players and 2 computers."""

		name = self.entryField.get()
		self.h.destroy() # close h window
		os.system('python board_piece_final_tweaked1.py ' + name + ' white')
Beispiel #4
0
def figure7():
    print 'Figure 17.5'

    g = Gui()
    options = dict(side=TOP, fill=X)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel Command', **options)
    b3 = g.bu(text='Help', **options)

    g.mainloop()
    g.destroy()
Beispiel #5
0
def figure7():
    print 'Figure 17.5'

    g = Gui()
    options = dict(side=TOP, fill=X)
    b1 = g.bu(text='OK', command=g.quit, **options)
    b2 = g.bu(text='Cancel Command', **options)
    b3 = g.bu(text='Help', **options)

    g.mainloop()
    g.destroy()
Beispiel #6
0
class Gwindow(): 
	"""Creates local/internet menu."""
	def __init__(self):
		self.g = Gui() # make g window
		self.g.title('Othello!')
		self.g.gr(cols=2)
		localButton = self.g.bu(text='Local Game', command=self.local)
		internetButton = self.g.bu(text='Internet Game', command=self.internet)
		self.g.mainloop()

	def local(self):
		"""Creates a game w/ 2 players on 1 computer."""
		self.g.destroy() # close g window
		os.system('python board_piece_final_tweaked.py') # start local game

	def internet(self):
		"""Leads to next menu."""
		self.g.destroy() # close g window
		Hwindow()