一切都按照应有的方式运作,只是结果被打印成一个新的页脚,当我希望它在空白的div中开始说"点击一个链接到开始。"在正确的方向上任何帮助都是正义的,提前谢谢。
class Page(object):
def __init__(self):
self.title = "My Top Fives"
self.css = "css/boilerplate.css"
self.css = "css/style.css"
self._head = '''<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Top Fives</title>
<link rel="stylesheet" href="css/boilerplate.css" type="text/css" />
<link rel="stylesheet" href="css/style.css" type="text/css" />
<script src="js/respond.min.js"></script>
</head>
<body>
'''
self._body = '''
<div class="gridContainer clearfix">
<div id="LayoutDiv1">
<div id="header">
<img src="images/top_5_logo.png" width="200" height="200"></div>
<div id="nav">
<ul>
<li><a href="?link=rush">RUSH</a></li>
<li><a href="?link=between">Between the Buried & Me</a></li>
<li><a href="?link=coheed">Coheed & Cambria</a></li>
<li><a href="?link=deftones">Deftones</a></li>
<li><a class="active" href="?link=tool">TOOL</a></li>
</ul>
</div>
#<!-- blank div here -->
<div id="blank"><h2>Click a link to get started.</h2>
</div>
#<!-- footer div here -->
<div id="footer">
<p>© 2014 Top Fives</p></div>
</div>
</div>'''
self._close = '''
</body>
</html>'''
#=========================================== Don't forget getters/setters & polymorphism =================#
def print_out(self):
return self._head + self._body + self._close #overridden by the polymorphism
class ContentPage(Page): #inheritance function (subclass?)
def __init__(self): #constructor function
super(ContentPage, self).__init__() #or it can be Page.__init__()
self._list_inputs = []
self._list_inputs = ''
self.num = 0
#==================== getter ========================#
@property #how we access our inputs
def inputs(self):
return self._list_inputs
#==================== setter ========================#
@inputs.setter
def inputs(self, arr): #sorts through the "Mega Array" and creates HTML
self.__inputs = arr #changes private inputs
for item in arr: #for each item in the array (held in data.py)
self._list_inputs += item[self.num] # (+= means in addition to)
#============================ polymorphism (from videos) ========================#
def results(self):
return self._head + self._body + "<br/ >" + "<div id='blank'><b>Name:</b> " +self.data.name + "<br>" + "<b>Members:</b> " + self.data.members + "<br>" + "<b>First Release Date:</b> " + self.data.first_release + "<br>" + "<b>Albums:</b> " + self.data.albums + "<br>" + "<b>Genres:</b> " + self.data.genres + "<br>" + "<b>Record Label:</b> " + self.data.label + self._list_inputs + self._close + "</div>"