Allow Aux_windows to have layouts and some cleanup.

This commit is contained in:
Ray 2009-03-06 21:46:34 -05:00
parent baa8d145ae
commit 753754c924

View File

@ -32,14 +32,35 @@ import shutil
import xml.dom.minidom import xml.dom.minidom
from xml.dom.minidom import Node from xml.dom.minidom import Node
#class Layout:
# def __init__(self, max):
# self.max = int(max)
# self.location = []
# for i in range(self.max + 1): self.location.append(None)
class Layout: class Layout:
def __init__(self, max): def __init__(self, node):
self.max = int(max)
self.max = int( node.getAttribute('max') )
if node.hasAttribute('fav_seat'): self.fav_seat = int( node.getAttribute('fav_seat') )
self.width = int( node.getAttribute('width') )
self.height = int( node.getAttribute('height') )
self.location = [] self.location = []
for i in range(self.max + 1): self.location.append(None) for i in range(self.max + 1): self.location.append(None)
for location_node in node.getElementsByTagName('location'):
if location_node.getAttribute('seat') != "":
self.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
elif location_node.getAttribute('common') != "":
self.common = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
def __str__(self): def __str__(self):
temp = " Layout = %d max, width= %d, height = %d, fav_seat = %d\n" % (self.max, self.width, self.height, self.fav_seat) temp = " Layout = %d max, width= %d, height = %d" % (self.max, self.width, self.height)
if hasattr(self, 'fav_seat'): temp = temp + ", fav_seat = %d\n" % self.fav_seat
else: temp = temp + "\n"
if hasattr(self, "common"):
temp = temp + " Common = (%d, %d)\n" % (self.common[0], self.common[1])
temp = temp + " Locations = " temp = temp + " Locations = "
for i in range(1, len(self.location)): for i in range(1, len(self.location)):
temp = temp + "(%d,%d)" % self.location[i] temp = temp + "(%d,%d)" % self.location[i]
@ -66,15 +87,7 @@ class Site:
self.layout = {} self.layout = {}
for layout_node in node.getElementsByTagName('layout'): for layout_node in node.getElementsByTagName('layout'):
max = int( layout_node.getAttribute('max') ) lo = Layout(layout_node)
lo = Layout(max)
lo.fav_seat = int( layout_node.getAttribute('fav_seat') )
lo.width = int( layout_node.getAttribute('width') )
lo.height = int( layout_node.getAttribute('height') )
for location_node in layout_node.getElementsByTagName('location'):
lo.location[int( location_node.getAttribute('seat') )] = (int( location_node.getAttribute('x') ), int( location_node.getAttribute('y')))
self.layout[lo.max] = lo self.layout[lo.max] = lo
def __str__(self): def __str__(self):
@ -161,21 +174,23 @@ class Aux_window:
def __init__(self, node): def __init__(self, node):
for (name, value) in node.attributes.items(): for (name, value) in node.attributes.items():
setattr(self, name, value) setattr(self, name, value)
# self.name = node.getAttribute("mw_name")
# self.cards = node.getAttribute("deck") self.layout = {}
# self.card_wd = node.getAttribute("card_wd") for layout_node in node.getElementsByTagName('layout'):
# self.card_ht = node.getAttribute("card_ht") lo = Layout(layout_node)
# self.rows = node.getAttribute("rows") self.layout[lo.max] = lo
# self.cols = node.getAttribute("cols")
# self.format = node.getAttribute("stud")
def __str__(self): def __str__(self):
temp = 'Aux = ' + self.name + "\n" temp = 'Aux = ' + self.name + "\n"
for key in dir(self): for key in dir(self):
if key.startswith('__'): continue if key.startswith('__'): continue
if key == 'layout': continue
value = getattr(self, key) value = getattr(self, key)
if callable(value): continue if callable(value): continue
temp = temp + ' ' + key + " = " + value + "\n" temp = temp + ' ' + key + " = " + value + "\n"
for layout in self.layout:
temp = temp + "%s" % self.layout[layout]
return temp return temp
class Popup: class Popup: