示例#1
0
 def __init__(self, shell, filename, **kwds):
     text = get_text(filename)
     text_pages = text.split("\nPAGE\n")
     pages = []
     page_size = (0, 0)
     for text_page in text_pages:
         lines = text_page.strip().split("\n")
         page = Page(self, lines[0], lines[1:])
         pages.append(page)
         page_size = maximum(page_size, page.size)
     self.pages = pages
     bf = self.button_font
     b1 = Button("Prev Page", font=bf, action=self.prev_page)
     b2 = Button("Menu", font=bf, action=self.go_back)
     b3 = Button("Next Page", font=bf, action=self.next_page)
     b = self.margin
     page_rect = Rect((b, b), page_size)
     gap = (0, 18)
     b1.topleft = add(page_rect.bottomleft, gap)
     b2.midtop = add(page_rect.midbottom, gap)
     b3.topright = add(page_rect.bottomright, gap)
     Screen.__init__(self, shell, **kwds)
     self.size = add(b3.bottomright, (b, b))
     self.add(b1)
     self.add(b2)
     self.add(b3)
     self.prev_button = b1
     self.next_button = b3
     self.set_current_page(0)
示例#2
0
 def __init__(self, shell, filename, **kwds):
     text = get_text(filename)
     text_pages = text.split("\nPAGE\n")
     pages = []
     page_size = (0, 0)
     for text_page in text_pages:
         lines = text_page.strip().split("\n")
         page = Page(self, lines[0], lines[1:])
         pages.append(page)
         page_size = maximum(page_size, page.size)
     self.pages = pages
     bf = self.button_font
     b1 = Button("Prev Page", font=bf, action=self.prev_page)
     b2 = Button("Menu", font=bf, action=self.go_back)
     b3 = Button("Next Page", font=bf, action=self.next_page)
     b = self.margin
     page_rect = Rect((b, b), page_size)
     gap = (0, 18)
     b1.topleft = add(page_rect.bottomleft, gap)
     b2.midtop = add(page_rect.midbottom, gap)
     b3.topright = add(page_rect.bottomright, gap)
     Screen.__init__(self, shell, **kwds)
     self.size = add(b3.bottomright, (b, b))
     self.add(b1)
     self.add(b2)
     self.add(b3)
     self.prev_button = b1
     self.next_button = b3
     self.set_current_page(0)
示例#3
0
	def adjust (self, prototype, pattern, learning) :
		distance = vectors.euclidean_distance (prototype, pattern)
		prototype_ = prototype + (learning * math.exp (- distance ** 2)) * (pattern - prototype)
		prototype_ = vectors.maximum (prototype_, 0.0)
		prototype_ /= vectors.magnitude (prototype_)
		return prototype_
示例#4
0
def adjust_a (prototype, pattern, distance, beta) :
	prototype_ = prototype + (beta * math.exp (- distance ** 2)) * (pattern - prototype)
	prototype_ = vectors.maximum (prototype_, 0.0)
	prototype_ /= vectors.magnitude (prototype_)
	return prototype_
示例#5
0
	def adjust (self, prototype, pattern, learning) :
		prototype_ = prototype + learning * (pattern - prototype)
		prototype_ = vectors.maximum (prototype_, 0.0)
		prototype_ /= vectors.magnitude (prototype_)
		return prototype_