Пример #1
0
 def draw(self, c, r):
     c.erase_rect(r)
     main_image_pos = (10, 10)
     src_rect = pixmap.bounds
     dst_rect = offset_rect(src_rect, main_image_pos)
     pixmap.draw(c, src_rect, dst_rect)
     src_rect = rect_sized((180, 160), (100, 100))
     c.frame_rect(offset_rect(src_rect, main_image_pos))
     dst_rect = rect_sized((10, 340), (150, 150))
     pixmap.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((200, 340), (100, 100))
     pixmap.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((340, 340), (50, 50))
     pixmap.draw(c, src_rect, dst_rect)
Пример #2
0
 def draw(self, c, r):
     c.erase_rect(r)
     main_image_pos = (10, 10)
     src_rect = pixmap.bounds
     dst_rect = offset_rect(src_rect, main_image_pos)
     pixmap.draw(c, src_rect, dst_rect)
     src_rect = rect_sized((180, 160), (100, 100))
     c.frame_rect(offset_rect(src_rect, main_image_pos))
     dst_rect = rect_sized((10, 340), (150, 150))
     pixmap.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((200, 340), (100, 100))
     pixmap.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((340, 340), (50, 50))
     pixmap.draw(c, src_rect, dst_rect)
Пример #3
0
    def invalidate_frame(self, rect):

        # Below is a logic to invalidate just the frame, not the whole rect.
        # This is to fight flicker. A better fix is to use double buffering.
        # If fixed, all of this could be just: self.invalidate_rect(rect)
        
        w, h = rect_size(rect)
        topleft = rect_topleft(rect)
        topright = add_pt(topleft, (w-1, 0))
        botleft = add_pt(topleft, (0, h-1))

        self.invalidate_rect(rect_sized(topleft, (1, h)))
        self.invalidate_rect(rect_sized(topleft, (w, 1)))
        self.invalidate_rect(rect_sized(topright, (1, h)))
        self.invalidate_rect(rect_sized(botleft, (w, 1)))
Пример #4
0
    def draw(self, c, r):
        c.erase_rect(r)
        c.fillcolor = white
        orig = (0, 0)

        src_r = room.bounds
        dst_r = rect_sized((0, 0), (340, 670))
        room.draw(c, src_r, dst_r)  #draw the monitor on left side

        src_r = p_on.bounds
        dst_r = rect_sized((450, 210), (156, 208))
        self.phone1.draw(c, src_r, dst_r)  #draw the top phone

        src_r = p_on.bounds
        dst_r = rect_sized((450, 440), (156, 208))
        self.phone2.draw(c, src_r, dst_r)  #draw the bottom phone

        src_r = rect_sized((0, 250), (1000, 500))
        dst_r = rect_sized((380, 20), (300, 150))
        self.nurse.draw(c, src_r, dst_r)  #draw the nurse sign

        src_r = m_on.bounds
        dst_r = rect_sized((800, 2), (390, 325))
        self.monitor1.draw(c, src_r, dst_r)  #draw the top monitor

        src_r = m_on.bounds
        dst_r = rect_sized((800, 350), (390, 325))
        self.monitor2.draw(c, src_r, dst_r)  #draw the bottom monitor
Пример #5
0
 def draw(self, c, r):
     c.backcolor = yellow
     c.erase_rect(r)
     main_image_pos = (10, 10)
     src_rect = image.bounds
     #say("Image bounds =", src_rect)
     dst_rect = offset_rect(src_rect, main_image_pos)
     #say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
     src_rect = rect_sized((180, 160), (100, 100))
     c.frame_rect(offset_rect(src_rect, main_image_pos))
     dst_rect = rect_sized((10, 340), (150, 150))
     #say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((200, 340), (100, 100))
     #say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((340, 340), (50, 50))
     #say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
Пример #6
0
 def draw(self, c, r):
     c.backcolor = yellow
     c.erase_rect(r)
     main_image_pos = (10, 10)
     src_rect = image.bounds
     # say("Image bounds =", src_rect)
     dst_rect = offset_rect(src_rect, main_image_pos)
     # say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
     src_rect = rect_sized((180, 160), (100, 100))
     c.frame_rect(offset_rect(src_rect, main_image_pos))
     dst_rect = rect_sized((10, 340), (150, 150))
     # say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((200, 340), (100, 100))
     # say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
     dst_rect = rect_sized((340, 340), (50, 50))
     # say("Drawing", src_rect, "in", dst_rect)
     image.draw(c, src_rect, dst_rect)
 def viewed_rect(self):
     """Return the rectangle in local coordinates bounding the currently
     visible part of the extent."""
     return rect_sized((0, 0), self.size)
Пример #8
0
	def viewed_rect(self):
		"""Return the rectangle in local coordinates bounding the currently
		visible part of the extent."""
		return rect_sized(self.scroll_offset, self.size)
Пример #9
0
 def get_bounds(self):
     return rect_sized((0, 0), self.size)
 def get_bounds(self):
     return rect_sized((0, 0), self.size)
Пример #11
0
    def key_down(self, event):
        if event.char == 'q':
            self.tags = (self.tags + 1) % 2
            if self.tags % 2 == 1:
                self.present = True
                self.nurse = n_on
            else:
                self.present = False
                self.nurse = n_off

        if event.char == 'm':
            print play1.playing
            play1.pause()
        if event.char == 'a':
            self.start = time.time()
            self.monitor1 = m_on
            self.alarm = True
            self.pstate = 1
        if event.char == 's':
            self.alarm = False
            self.pstate = 0
            self.phone1 = p_off
            self.phone2 = p_off
            self.monitor1 = m_off
            self.monitor2 = m_off
            self.invalidate_rect(rect_sized((0, 0), (1300, 700)))
            self.update()
        if event.char == 'u':
            if self.alarm == True:  #counter to play monitor sounds
                self.moncount = (self.moncount + 1) % 2
                if self.moncount == 1:
                    mwav = pyglet.media.load('monitor2.mp3')
                    mwav.play()
            txt = f.read(500)  #reading from usb
            if len(txt) > 0:
                self.tags = (self.tags + 1) % 2
                if self.tags % 2 == 1:
                    self.present = True
                    self.nurse = n_on
                else:
                    self.present = False
                    self.nurse = n_off
            self.invalidate_rect(rect_sized((0, 0), (1300, 700)))
            self.update()

            if self.alarm:
                curr = time.time()
                if (curr - self.start > 23) and (self.pstate == 3):
                    self.pstate += 1
                    if self.present == False:
                        self.phone1 = p_on
                        self.phone2 = p_off
                        pwav = pyglet.media.load('phone.mp3')
                        pwav.play()
                elif (curr - self.start > 13) and (self.pstate == 2):
                    self.pstate += 1
                    pwav = pyglet.media.load('phone.mp3')
                    pwav.play()
                    self.phone2 = p_on
                    self.phone1 = p_off
                elif (curr - self.start > 3) and (self.pstate == 1):
                    self.pstate += 1
                    if self.present == False:
                        pwav = pyglet.media.load('phone.mp3')
                        pwav.play()
                        self.phone1 = p_on