Пример #1
0
def town():

	prior = len(glbl.gw.items)


	gold_box = Gold_Box(glbl.player.gold)

	background = Image(Point(750, 250), glbl.MAPS / "sprites" / "village.png")
	background.draw(glbl.gw)

	#musicplays here
	#pygame.mixer.music.stop()
	
	if glbl.game_stats["town_tutorial"]:
		glbl.game_stats["town_tutorial"] = False
		town_tutorial()

	while True:
		pygame.mixer.music.stop()
		town_music = pygame.mixer.music.load("Town_Music.mp3")
		pygame.mixer.music.play(-1)
		if glbl.game_stats['orc_dead'] == "Dead":
			for i in glbl.gw.items[prior:]: i.undraw()
			return

		x = dialogue("Where would you like to go?", [
			"Inn", 
			"Wizard" if glbl.player.character_class == "Sorcerer" else "Blacksmith",
			"Shop",
			"Librarian",
			"Explore Forest"], right=True)

		if x == 0:
			pygame.mixer.music.stop()
			town_music = pygame.mixer.music.load("inn.mp3")
			pygame.mixer.music.play(-1)
			inn(gold_box)

		if x == 1:
			pygame.mixer.music.stop()
			shop_music = pygame.mixer.music.load("shop.mp3")
			pygame.mixer.music.play(-1)
			weapon_maker(gold_box)

		if x == 2:
			shop(gold_box)

		if x == 3:
			pygame.mixer.music.stop()
			librarian(gold_box)
		
		if x == 4:
			pygame.mixer.music.stop()
			town_music = pygame.mixer.music.load("Overworld_Music.mp3")
			pygame.mixer.music.play(-1)
			prep_exploration()
			if glbl.game_stats['reginald'] == 6:
				glbl.game_stats['reginald'] = 7
			if glbl.game_stats['reginald'] == 7:
				raise glbl.GameOver('Rat Invasion')
Пример #2
0
 def initialization(s):
     try:
         s.color_background = s.color_background
     except AttributeError:
         s.color_background = 0xffffff
     try:
         s.color_cursor = s.color_cursor
     except AttributeError:
         s.color_cursor = 0xcccccc
     s.icon_size_x = s.icon_size_y = s.images.size[1]
     s.abreast_x = s.layout[0][0] / s.icon_size_x
     s.abreast_layout_y = s.layout[0][1] / s.icon_size_y
     s.distribution_icons = divmod(len(s.list_s), s.abreast_x)
     if s.distribution_icons[1]:
         s.abreast_full_y = s.distribution_icons[0] + 1
     else:
         s.abreast_full_y = s.distribution_icons[0]
     s.sh_x = (s.layout[0][0] - s.abreast_x * s.icon_size_x) / 2
     s.sh_y = (s.layout[0][1] - s.abreast_layout_y * s.icon_size_y) / 2
     s.total_size = (s.abreast_x * s.icon_size_x,
                     s.icon_size_y * s.abreast_full_y)
     s.img_1 = Image.new(s.total_size)
     s.img_1.clear(s.color_background)
     s.img = Image.new(
         (s.total_size[0], min(s.layout[0][1] - s.sh_y * 2,
                               s.total_size[1])))
     x, y = 0, 0
     for i in s.list_coords:
         s.img_1.blit(s.images,
                      source=i,
                      target=(x * s.icon_size_x, y * s.icon_size_y))
         x += 1
         if x == s.abreast_x:
             x = 0
             y += 1
Пример #3
0
class p1wins:
    def __init__(self, window):
        self.image = Image(Point(600, 400), "ImagesAndSprites/MenuScreen.gif")
        self.text = Text(Point(600, 600), "Player 1 Wins!")
        self.text.setSize(36)
        self.image.draw(window)
        self.text.draw(window)
Пример #4
0
class Stage(object):
    def __init__(self, window):
        self.pos1 = Point(0, 0)
        self.pos2 = Point(0, 0)
        self.platform1 = None
        self.hb = None

    def regStage(self, window):
        background = Image(Point(600, 400), "ImagesAndSprites/StartScreen.gif")
        background.draw(window)
        self.platform1 = Image(Point(600, 675), "ImagesAndSprites/blue.gif")
        self.platform1.draw(window)
        self.pos1 = Point(400, 700)
        self.pos2 = Point(800, 700)

    def getPos1(self):
        return self.pos1

    def getPos2(self):
        return self.pos2

    def regStageCreateHB(self):
        self.hb = hitbox(self.platform1, 0)

    def getHB(self):
        return self.hb
 def prerender_text(self):
     tr = appuifw.app.body.measure_text(self.victory, font='title')[0]
     self.text_pos = ((self.x - tr[2] + tr[0]) / 2,
                      (self.y - tr[3] + tr[1]) / 2,
                      (self.x + tr[2] - tr[0]) / 2,
                      (self.y + tr[3] - tr[1]) / 2)
     self.text_img = Image.new((tr[2] - tr[0] + 2, tr[3] - tr[1] + 2))
     self.text_img.clear()
     self.text_img.text((-tr[0] + 2, -tr[1] + 2),
                        self.victory,
                        fill=(64, 64, 64),
                        font='title')
     self.text_img.text((-tr[0], -tr[1]),
                        self.victory,
                        fill=(0, 0, 255),
                        font='title')
     self.text_mask = Image.new((tr[2] - tr[0] + 2, tr[3] - tr[1] + 2),
                                mode='L')
     self.text_mask.clear(0)
     self.text_mask.text((-tr[0] + 2, -tr[1] + 2),
                         self.victory,
                         fill=(255, 255, 255),
                         font='title')
     self.text_mask.text((-tr[0], -tr[1]),
                         self.victory,
                         fill=(255, 255, 255),
                         font='title')
 def draw(self, win, center):
     if not self.image:
         rank = str(self.specials.get(self.rank, self.rank))[0].upper()
         if self.rank == 10:
             rank = str(10)
         suite = self.suit.upper()
         self.image = Image(center, f"cards_pics/{rank + suite}.png")
     self.image.draw(win)
Пример #7
0
 def alphaMask(self, a=None, size=ICONSIZE):
   if a == None:               return self.alphas[(DEFALPHA[0],size)]
   if (a,size) in self.alphas: return self.alphas[(a,size)]
   aimg = Image.new(size, 'L')
   aimg.clear(a)
   self.alphas[(a, size)] = Image.new(size, 'L')
   self.alphas[(a, size)].clear(0);
   self.alphas[(a, size)].blit(self.mask.resize(size), mask=aimg)
   return self.alphas[(a, size)]
Пример #8
0
 def __init__(self, window):
     self.image = Image(Point(600, 400), "ImagesAndSprites/MenuScreen.gif")
     self.text = Text(Point(600, 600), "Press Any Key To Start")
     self.text.setFace("arial")
     self.text.setSize(36)
     self.text.setStyle("normal")
     self.text.setTextColor(color_rgb(0, 0, 0))
     self.image.draw(window)
     self.text.draw(window)
     self.run(window)
Пример #9
0
    def imagensCasas(self):
	imagens = {}
	for x in range(len(CASAS)):
		imagens[CASAS[x]] = Image.open(self.getPathFigura(CASAS[x]))
		imagens["u"+ str(CASAS[x])] = Image.open(self.getPathFigura(CASAS[x], 'u'))

	for x in range(len(DEMARCADORES)):
		imagens[DEMARCADORES[x]] = Image.open(self.getPathFigura(DEMARCADORES[x]))

	for x in range(len(MASCARAS)):
		imagens[MASCARAS[x]] = Image.open(self.getPathFigura(MASCARAS[x]))
	
	return imagens
class Card():

    specials = {
            1: "Ace",
            11: "Jack",
            12: "Queen",
            13: "King",
            'c': "Clubs",
            'd': "Diamonds",
            'h': "Hearts",
            's': "Spades",
            }

    def __init__(self, rank, suit):
        self.rank = rank
        self.suit = suit
        self.image = None

    def __str__(self):
        rank = self.specials.get(self.rank, self.rank)
        if not rank:
            rank = self.rank
        return f"{rank} of {self.getSuite()}"

    def BJValue(self):
        if self.rank < 10:
            return self.rank
        else:
            return 10

    def draw(self, win, center):
        if not self.image:
            rank = str(self.specials.get(self.rank, self.rank))[0].upper()
            if self.rank == 10:
                rank = str(10)
            suite = self.suit.upper()
            self.image = Image(center, f"cards_pics/{rank + suite}.png")
        self.image.draw(win)

    def getRank(self):
        rank = self.specials(self.rank)
        if rank:
            return rank
        else:
            return self.rank

    def getSuite(self):
        return self.specials.get(self.suit)
Пример #11
0
def addIconModule(ico):

  if hasattr(ico, "ICONFILE") and hasattr(ico, "ICONDEF"):
    icopath = os.path.dirname(ico.__file__)
    img = Image.open(os.path.join(icopath, ico.ICONFILE))
    assert len(ico.ICONDEF) <= img.size[1] / ICONSIZE[1] * ICONS_PER_ROW, \
           "Not enough icons in image file"

    for idx in range(len(ico.ICONDEF)):
      icodef = ico.ICONDEF[idx]
      if type(icodef) in [list, tuple]:
        if len(icodef) < 3: icodef = icodef + (None,)
      else:
        icodef = (icodef, None, None)
      iconame, mifidx, mifmask = icodef
      if iconame in ICONS: del ICONS[iconame]
      if hasattr(ico, "ICONMIF") and os.path.exists(os.path.join(icopath, ico.ICONMIF)):
        miffile = os.path.abspath(os.path.join(icopath, ico.ICONMIF))
        if mifidx  == None: mifidx  = idx * 2
        if mifmask == None: mifmask = mifidx + 1
      else:
        miffile, mifidx, mifmask = [None]*3

      ICONS[iconame] = GpsIcon(img, idx, miffile, mifidx, mifmask)
    del img

  if hasattr(ico, "MARKERS"):
    global MARKERS, MARKERCAT
    MARKERS = ico.MARKERS[:]
    assert len(MARKERS) == 6, "MARKERS must have exactly 6 elements"
    if hasattr(ico, "MARKERCAT"):
      MARKERCAT = ico.MARKERCAT
    for m in MARKERS + [MARKERCAT]:
      if not m in ICONS:
        ICONS[m] = ICONS["Default"]
Пример #12
0
    def __init__(
        self,
        title=None,
        screen_mode=None,
        fps=None,
        color_mode=None,
        bg_color=None,
    ):
        app.screen = screen_mode or "full"
        app.title = title or u"PyS60 Game"

        self._game_obj = None
        self._is_running = 0
        if fps is None:
            self.fps = FPS_DEFAULT
        else:
            assert isinstance(fps, int) or isinstance(fps, float)
            self.fps = fps

        self.color_mode = color_mode or COLOR_MODE
        self.bg_color = bg_color or BG_COLOR

        self.canvas = Canvas(redraw_callback=self.handle_redraw(),
                             event_callback=self.handle_event())
        app.body = self.canvas
        app.exit_key_handler = self.handle_exit()

        self.buffer = Image.new(self.canvas.size, mode=self.color_mode)
        self.buffer.clear(self.bg_color)
        self.handle_redraw()(None)

        self.key_click = None
        self._key_click_release = 1
        self.key_down = None
        self._key_down_release = 1
Пример #13
0
def help():
    global w, img1
    explain = [
        cn("欢迎使用短信签名测试版"), u"================",
        cn("功能说明:"),
        cn("1.可设置自动回复"),
        cn("2.可设置定时回复"),
        cn("3.可发送闪信"),
        cn("4.签名功能可选"),
        cn("5.具有短信转E功能"), u"================",
        cn("@小布开发版权所有@")
    ]
    w = TopWindow.TopWindow()
    img1 = Image.new((176, 208))
    img1.clear(0)
    for i in range(10):
        img1.text((10, 15 + i * 12), explain[i], fill=0x0000ff)
    w.add_image(img1, (0, 0))
    w.size = (160, 135)
    w.position = (5, 45)
    w.shadow = 5
    w.corner_type = "corner5"
    w.show()
    e32.ao_sleep(10)
    w.hide()
Пример #14
0
 def start(s,
           resource,
           callback=lambda: None,
           func_delete=lambda: None,
           stop_callback=lambda: None,
           func_vector=lambda: None):
     s.y, s.z = 0, 0
     y = 0
     s.resource = resource
     s.callback = callback
     s.func_delete = func_delete
     s.stop_callback = stop_callback
     s.func_vector = func_vector
     if not s.resource:
         return None
     s.list = akntextutils.wrap_text_to_array(s.resource, 'annotation',
                                              s.size[0] - 25)
     s.lenlist = len(s.list)
     s.max_str_display = s.size[1] / 20
     s.imgsize = (s.size[0] - 10, min(s.max_str_display * 20,
                                      s.lenlist * 20))
     try:
         del s.img
     except AttributeError:
         pass
     s.img = Image.new(s.imgsize)
     s.capture.keys = [
         63495, 63496, 63497, 63498, 63557, 63554, 63555, 35, 42, 63586, 8
     ] + range(48, 58)
     s.capture.forwarding = 0
     aw.app.focus = s.focus
     s.capture.start()
     s.picture()
Пример #15
0
def show_total(amount):
    totalWin = GraphWin("Transaction", 250,250)
    totalWin.setBackground("Yellow")

    amountText = Text(Point(125,50), amount)
    amountText.setStyle("bold")
    amountText.draw(totalWin)
    amountLabel = Text(Point(50,50), "Total:")
    amountLabel.draw(totalWin)

    tenderedBox = Entry(Point(125,100), 5)
    tenderedBox.setText("0")
    tenderedBox.setFill("white")
    tenderedBox.draw(totalWin)
    label = Text(Point(50,100), "Given: ")
    label.draw(totalWin)

    button = Image(Point(125, 200), "icons/button.png")
    button.draw(totalWin)
    buttonRect = Rectangle(Point(50,184), Point(203,218))

    calcFlag = False
    while True:
        errorFlag = False
        try:
            click = totalWin.getMouse()
        except:
            totalWin.close()
            break
        if(isPtInRect(buttonRect, click)):
            if(calcFlag):
                    change.undraw()
            try:
                tendered = tenderedBox.getText()
            except:
                errorFlag = True
                tenderedBox.setText("0")
            if(float(tendered) < amount):
                errorFlag = True
                tenderedBox.setText(str(amount))
            if(not errorFlag):
                change = Text(Point(125, 150), "Change:    "
                              + str(float(tendered) - amount))
                change.setStyle("bold")
                change.draw(totalWin)
                calcFlag = True
    return
Пример #16
0
 def __init__(self, image, idx, miffile=None, mifidx=None, mifmask=None):
   self.img  = Image.new(ICONSIZE)
   self.mask = Image.new(ICONSIZE,"L")
   sx, sy = ICONSIZE[0], ICONSIZE[1]
   x1, y1 = idx*2*sx % (2*ICONS_PER_ROW*sx) + sx, idx / 2 * sy
   x2, y2 = x1+sx, y1+sy
   self.img. blit(image, source=((x1,   y1),(x2,   y2)))
   self.mask.blit(image, source=((x1-64,y1),(x2-64,y2)))
   self.alphas = {}
   self.resized = {}
   # Pre-Cache standard sizes and alpha
   # for a in DEFALPHA:
   #   for sz in [ ICONSIZE, (ICONSIZE[0]/2,ICONSIZE[1]/2), (ICONSIZE[0]/4,ICONSIZE[1]/4) ]:
   #     self.draw(None, (0,0), sz, a)
   self.miffile = miffile
   self.mifidx  = mifidx
   self.mifmask = mifmask
Пример #17
0
 def getMapImage(self, centerLatLon, zoom, markerPositions):
         
         lat, lon = centerLatLon
         url = (GMAPS_URL % (lat, lon, zoom, self.width, self.height,
                            self.mapType, self.makeMarkerString(markerPositions)))
         
         file, ignoredHeaders = urllib.urlretrieve(url, TEMP_FILE)
         
         return Image.open(file)     
Пример #18
0
 def start(self):
     app.screen = 'full'
     self._oldScreen = app.body
     app.body = self()
     ao_yield()
     self._image = Image.new(self._screen.size)
     self.width = self._screen.size[0]
     self.height = self._screen.size[1]
     self.redraw()
Пример #19
0
def reveal_card(card_images, back_of_card):

    # Card images is a list of the relative directorys on all 52 cards.
    rand_card_dir = random.choice(card_images)

    # Deletes the card once revealed, this simulates a real deck much better.
    card_images.remove(rand_card_dir)

    rand_card = Image(back_of_card.getAnchor(), rand_card_dir)

    # Replaces back of deck image with the random card picked
    back_of_card.undraw()
    rand_card.draw(WIN)

    # Reads the string on the card name to obtain the value
    val = get_card_val(rand_card_dir)

    return rand_card, val
Пример #20
0
 def picture(self):
     try:
         self.window_main.remove_image(self.img, (0, 0))
         del self.img
     except Exception:
         pass
     size = (self.width, len(self.items) * 20 + 20)
     self.img = Image.new(size)
     self.window_main.size = size
     self.window_main.position = (self.x_pos, self.y_pos)
     self.img.rectangle((0, 0, size[0], size[1]), 0x0,
                        self.color_background)
     self.img.rectangle((1, 1, size[0] - 1, 20),
                        fill=self.color_background_upper)
     self.img.rectangle(
         (2, self.y * 20 + 22, size[0] - 2, self.y * 20 + 38),
         fill=self.color_cursor)
     a = self.img.measure_text(self.title,
                               'annotation',
                               maxwidth=self.width - 15)
     if len(self.title) > a[2]:
         self.img.text(((self.width - a[0][2]) / 2, 14),
                       self.title[:a[2] - 1] + u'...',
                       self.color_text_upper, 'annotation')
     else:
         self.img.text(((self.width - a[0][2]) / 2, 14), self.title,
                       self.color_text_upper, 'annotation')
     d, n = 20, 0
     for t in self.items:
         n += 1
         if n - 1 is not self.y:
             color_text = self.color_text
         else:
             color_text = self.color_text_cursor
         if n < 10:
             i = unicode(n)
         elif n == 10:
             i = u'0'
         else:
             i = u''
         a = self.img.measure_text(i + u' ' + t[0],
                                   'annotation',
                                   maxwidth=self.width - 23)
         if len(i + u' ' + t[0]) > a[2]:
             self.img.text((4, 14 + d), i + u' ' + t[0][:a[2] - 2] + u'...',
                           color_text, 'annotation')
         else:
             self.img.text((4, 14 + d), i + u' ' + t[0], color_text,
                           'annotation')
         if t[1] is '1':
             self.img.polygon((self.width - 9, 16 + d, self.width - 9,
                               4 + d, self.width - 3, 10 + d),
                              fill=color_text)
         d += 20
     self.window_main.add_image(self.img, (0, 0))
     self.window_main.show()
Пример #21
0
def lab3():#画布界面
    from graphics import Image
    appuifw.app.body=canvas=appuifw.Canvas()
    img=Image.new((240,320))
    img.clear(0x0000ff)
    def redraw():
        canvas.blit(img)
    while True:
        redraw()#借循环语句使redraw函数不断执行,比米饭的简单吧
        e32.Ao_yield()#监控退出命令,使程序能退出
Пример #22
0
 def __init__(self):
     self.old_func_focus = appuifw.app.focus
     appuifw.app.focus = self.focus
     self.focusflag = 1
     if e32.s60_version_info >= (2, 8):
         self.scr = appuifw.app.layout(appuifw.EScreen)[0]
     else:
         self.scr = (176, 208)
     img_none = Image.new((1, 1))
     h = img_none.measure_text(u'by', 'annotation')[0]
     self.__h_text = h[3] - h[1]
     self.__dislocation_text = h[3]
     h2 = img_none.measure_text(u'by', 'dense')[0]
     h_text2 = h2[3] - h2[1]
     self.__dislocation_text2 = h2[3]
     self.__sizeW = 6 + h_text2
     self.__sizeY = self.__sizeW + self.__h_text * 2 + 6
     self.img = Image.new((self.scr[0] - 10, self.__sizeY))
     self.top_shadow = TopWindow()
     x = max(self.scr)
     self.top_shadow.position = (-x, -x)
     self.top_shadow.shadow = x / 2
     self.window = TopWindow()
     self.window.size = (self.scr[0] - 10, self.__sizeY)
     self.window.position = (5, self.scr[1] / 2 - self.__sizeY / 2)
     self.color_background = 0x555500
     self.color_text = 0xffffff
     self.color_background2 = 0xffffff
     self.color_text2 = 0x707070
     self.img1 = Image.new((self.scr[0] - 22, self.__sizeW), mode = 'RGB')
     self.img2 = Image.new((self.scr[0] - 22, self.__sizeW - 2), mode = 'RGB')
     self.img_gradient = Image.new((self.scr[0] - 22, self.__sizeW - 2), mode = 'RGB')
     r = 255 / ((self.scr[0] - 22) / 4.0)
     for i in xrange(self.scr[0] - 22):
         if i <= (self.scr[0] - 22) / 4.0:
             self.img_gradient.line((i, 0, i, self.__sizeW - 2), (255, int(i * r), 0))
         elif (self.scr[0] - 22) / 4.0 < i <= (self.scr[0] - 22) / 2.0:
             self.img_gradient.line((i, 0, i, self.__sizeW - 2), (int(255 - (i - (self.scr[0] - 22) / 4.0) * r), 255, 0))
         elif (self.scr[0] - 22) / 2.0 < i <= (self.scr[0] - 22) * 3 / 4.0:
             self.img_gradient.line((i, 0, i, self.__sizeW - 2), (0, 255, int((i - (self.scr[0] - 22) / 2.0) * r)))
         else:
             self.img_gradient.line((i, 0, i, self.__sizeW - 2), (0, int(255 - (i - (self.scr[0] - 22) * 3 /4.0) * r), 255))
     e32.ao_yield()
Пример #23
0
    def __init__(self, window, player1, player2):
        self.window = window
        self.p1 = Player(player1, None)
        self.p2 = Player(player2, None)
        background = Image(Point(600, 400), "ImagesAndSprites/StartScreen.gif")
        background.draw(window)
        self.createHealthBars(window)
        self.startGame(window)
        self.countDown = Text(
            Point(window.getWidth() / 2,
                  window.getHeight() / 2), '')
        self.countdown(window)
        self.plyJumpRender = Image(Point(300, 50),
                                   "ImagesAndSprites/Apple.gif")
        self.plyJumpRender.draw(window)

        self.plyJumpRender2 = Image(Point(900, 50),
                                    "ImagesAndSprites/Apple.gif")
        self.plyJumpRender2.draw(window)
        # plyJumpRender2.move(150, 0)

        self.worldRenderer = Image(Point(800, 3), "ImagesAndSprites/blue.gif")
        self.worldRenderer.draw(window)
        self.worldRenderer.move(-200, 400)

        # Hitbox defines as
        # Obj, width, height, weight, pos, ignored
        self.plyJump = hitbox(self.plyJumpRender, 1)
        self.plyJump2 = hitbox(self.plyJumpRender2, 1)
        self.platform = hitbox(self.worldRenderer, 0)
        self.time1 = 0
        self.time2 = 0
        while True:
            self.update(window)
            if (self.getWinner() == 1):
                p1wins(window)
                time.sleep(2)
                break
            if (self.getWinner() == 2):
                p2wins(window)
                time.sleep(2)
                break
Пример #24
0
 def __init__(q):
     q.mfo = (mf + 'CosmoTech\\FScreen\\')
     q.st = ini.read((q.mfo + 'position'))
     q.name = u'F-Screen'
     q.w1 = m.image((q.mfo + 'watermark'), 0)
     q.w2 = m.image((q.mfo + 'watermark'), 1)
     q.hc = q.sc = 0
     sz = q.w1.size
     q.im, q.ss = (IG.new(sz), IG.new(dpx()))
     q.cap = KCR(q.key)
     q.lo = (mg + 'fdrive.dat')
     q.cap.keys = (q.load(q.lo)[1], )
     q.cap.start()
     if q.load(q.lo)[0] == u'':
         q.b = 'None'
     else:
         q.b = q.load(q.lo)[0]
     if q.load(q.lo)[2] == u'':
         q.w = 'None'
     else:
         q.w = q.load(q.lo)[2]
     if q.load(q.lo)[1] == 8:
         ke = u'C (Delete)'
     else:
         ke = u'Green Key/Call'
     q.list = [(u'Status', u'Active'), (u'Shot Button', ke),
               (u'Watermark & Background',
                unicode(q.w[:-4] + ' | ' + path.split(q.b)[1])),
               (u'About', q.un('\xc2\xa9 2018, Cosmo TechZone'))]
     q.lb = LB(q.list, q.sel)
     AP.body = q.lb
     AP.title = u'F-Screen'
     AP.exit_key_handler = q.mi
     AP.menu_key_text = u'Options'
     AP.exit_key_text = u'Minimize'
     AP.menu = [(u'Change Watermark', q.cwm), (u'Change Background', q.cbg),
                (u'Clear Background', q.clr), (u'Exit', q.ex)]
     try:
         sw = q.load(q.lo)[0]
         q.bg = IG.open(sw).resize(sz)
     except:
         pass
Пример #25
0
 def start(s, resousce):
     try:
         y = aw.app.body.pos2xy(aw.app.body.get_pos())[1]
     except AttributeError:
         return None
     s.y, s.z = 0, 0
     s.resousce = resousce
     if not s.resousce:
         return None
     elif type(s.resousce) == type([]) or type(s.resousce) == type(()):
         s.mode = 'list'
         s.list = []
         for t in s.resousce:
             a = s.imgnone.measure_text(t[0],
                                        'dense',
                                        maxwidth=s.size[0] - 25)[2]
             if a < len(t[0]):
                 t[0] = '%s%s' % (t[0][:a - 1], u'...')
             s.list.append(t[0])
     elif type(s.resousce) == type(u''):
         s.list = akntextutils.wrap_text_to_array(s.resousce, 'dense',
                                                  s.size[0] - 25)
         s.mode = 'text'
     else:
         return None
     s.lenlist = len(s.list)
     center = s.size[1] / 2
     if aw.app.screen == 'normal':
         y += s.layout[1][1]
     if y > center + 8:
         s.max_str_display = (y - 17) / 16
         s.imgsize = (s.size[0] - 10,
                      min(s.max_str_display * 16, s.lenlist * 16))
         s.window_position = 5, 5
     else:
         s.max_str_display = (s.size[1] - y - 8) / 16
         s.imgsize = (s.size[0] - 10,
                      min(s.max_str_display * 16, s.lenlist * 16))
         s.window_position = 5, max(y + 2, s.size[1] - s.imgsize[1] - 5)
     try:
         del s.img
     except AttributeError:
         pass
     s.img = Image.new(s.imgsize)
     if s.mode == 'list':
         s.capture.keys = [63497, 63498, 63557, 63554, 63555]
     elif s.mode == 'text':
         s.capture.keys = [
             63495, 63496, 63497, 63498, 63557, 63554, 63555, 35, 42, 63586
         ] + range(48, 58)
     s.capture.forwarding = 0
     aw.app.focus = s.focus
     s.capture.start()
     s.picture()
Пример #26
0
def confirmation():
    window0 = GraphWin("Success!", 200,100)
    window0.setBackground("white")
    text = Text(Point(100,20), "Success!")
    text.setFace("courier")
    text.draw(window0)

    exitImage = Image(Point(100,65), "icons/exit.png")
    exitImage.draw(window0)
    exitButton = Rectangle(Point(60,48), Point(140,80))
    while True:
        try:
            click = window0.getMouse()
        except:
            window0.close()
            break
        if(isPtInRect(exitButton, click)):
            window0.close()
            break
    return
Пример #27
0
 def favourites(self):
         def handle_redraw(rect):
                 canvas.blit(img)
         try:
             selector = FileSelector("e:\\myPlaces",".jpg")
             index = appuifw.selection_list(selector.GetKeys())
         except:
             appuifw.note(u"File does not exist", "info")
         img=Image.open(selector.GetFile(index))
         canvas=appuifw.Canvas(redraw_callback=handle_redraw)
         appuifw.app.body=canvas
         appuifw.app.menu = [(u"Back",self.back),(u"Exit", self.quit)]
Пример #28
0
 def __init__(s):
     s.capture = KeyCapturer(s.keys_answer)
     s.window = FGImage()
     try:
         s.layout = aw.app.layout(aw.EMainPane)
     except AttributeError:
         s.layout = ((176, 144), (0, 44))
     s.size = (s.layout[0][0], s.layout[0][1] + s.layout[1][1])
     s.imgnone = Image.new((1, 1))
     s.focusflag = 0
     s.resousce = None
     s.initialization()
 def __init__(self):
     s = appuifw.app.layout(appuifw.EMainPane)[0]  # drawing area size
     self.x = s[0]
     self.y = s[1]
     self.frame = Image.new((self.x, self.y))  # for double buffering
     #DEBUG self.frames = 0
     self.victory = u'Congratulations!'
     self.entropy_num = 3
     self.entropy_den = 4
     self.SELECTED_TILE_COLOR = (255, 0, 0)
     self.EMPTY_TILE_COLOR = (255, 255, 128)
     self.new_game(16)
Пример #30
0
 def regStage(self, window):
     background = Image(Point(600, 400), "ImagesAndSprites/StartScreen.gif")
     background.draw(window)
     self.platform1 = Image(Point(600, 675), "ImagesAndSprites/blue.gif")
     self.platform1.draw(window)
     self.pos1 = Point(400, 700)
     self.pos2 = Point(800, 700)
Пример #31
0
 def genImage(self):
     img = Image.new((cardWidth, cardHeight))
     img.rectangle((0, 0, cardWidth, cardHeight), self.borderColour,
                   self.bgColour)
     if self.visible:
         txtimg = Image.new((cardWidth - 2, cardHeight / 2 - 1))
         txtimg.rectangle((0, 0, cardWidth - 2, cardHeight / 2 - 1),
                          self.bgColour, self.bgColour)
         txtimg.text((1, 8), unicode(self.name()), self.colour(),
                     u'fixed6x10')
         img.blit(txtimg, target=(1, 1))
         img.blit(txtimg.transpose(ROTATE_180),
                  target=(1, cardHeight / 2 + 1))
     else:
         repeat = 4
         for top in range(0, repeat):
             img.ellipse([(cardWidth / 3, cardHeight * (top * 2 + 1) /
                           (repeat * 2 + 2)),
                          (cardWidth * 2 / 3, cardHeight * (top * 2 + 3) /
                           (repeat * 2 + 2))], self.patternColour1,
                         self.patternColour2)
     return img
Пример #32
0
def tile(tx, ty, left, top):
    t = (tx, ty, z)
    rect = (left, top, left+256, top+256)
    # here we use 2 level cache
    if t in cache[mode]:
        im = cache[mode][t]
    else:
        f = fmt_file % t + ext[mode]
        if not exists(f):
            c.rectangle(rect, fill=0xffffff)
            c.text((left+5, top+20), u'Loading')
            urlretrieve(tile_url(t), f)   # url cache
        cache[mode][t] = im = Image.open(f)   # object cache
    c.blit(im, target=rect)
Пример #33
0
class StartScreen:
    def __init__(self, window):
        self.image = Image(Point(600, 400), "ImagesAndSprites/MenuScreen.gif")
        self.text = Text(Point(600, 600), "Press Any Key To Start")
        self.text.setFace("arial")
        self.text.setSize(36)
        self.text.setStyle("normal")
        self.text.setTextColor(color_rgb(0, 0, 0))
        self.image.draw(window)
        self.text.draw(window)
        self.run(window)

    def run(self, window):
        r = 1
        b = 2
        g = 3
        while (window.checkKey() == ''):
            self.text.setTextColor(color_rgb(r, b, g))
            r += 1
            b += 2
            g += 3
            r = r % 256
            b = b % 256
            g = g % 256
Пример #34
0
def move_card_down():

    border = 190

    back_of_card = Image(Point(WIN.getWidth() / 2,
                               WIN.getHeight() / 4), "images/deck.png")
    back_of_card.draw(WIN)

    # Moves card down
    while back_of_card.getAnchor().getY() < WIN.getHeight() - border:
        back_of_card.move(0, MOVEMENT_SPEED)
        update()

    return back_of_card
Пример #35
0
 def __init__(self):
     self.keyboard = SymbianKeyboard()
     self.appuifw = appuifw
     self.app = appuifw.app
     self.app.title = u"Boxee Remote"
     # self.app.screen = 'large'
     self.body = appuifw.Canvas(event_callback=self.keyboard.handle_event, 
                                redraw_callback=None)
     self.app.body = self.body
     self.app.exit_key_handler = self.quit
     self.running = True
     self.get_accesspoint()
     host, port = self.get_host()
     self.remote = BoxeeRemote(host, port)
     self.body.blit(Image.open('e:\\Python\\gui_background.jpg'))
     self.menu()
Пример #36
0
 def __init__(s):
     s.capture = KeyCapturer(s.keys_answer)
     s.window = FGImage()
     try:
         s.layout = aw.app.layout(aw.EMainPane)
     except AttributeError:
         s.layout = ((176, 144), (0, 44))
     s.size = s.layout[0]
     s.imgnone = Image.new((1, 1))
     s.focusflag = 0
     s.resource = None
     s.color_window = 0xffffbb
     s.color_outline = 0xaa9050
     s.color_text = 0
     s.color_indicator = 0xff8000
     s.y, s.z = 0, 0
Пример #37
0
 def picture1(self):
     try:
         self.window_add1.remove_image(self.img_add1, (0, 0))
         del self.img_add1
     except Exception:
         pass
     size = (self.width_add1, len(self.items[self.y][2]) * 20)
     self.img_add1 = Image.new(size)
     self.window_add1.size = size
     self.window_add1.position = (self.x_pos_add1, self.y_pos_add1)
     self.img_add1.rectangle((0, 0, size[0], size[1]), 0x0,
                             self.color_background_add1)
     self.img_add1.rectangle(
         (2, self.y1 * 20 + 2, size[0] - 2, self.y1 * 20 + 18),
         fill=self.color_cursor_add1)
     d, n = 0, 0
     for t in self.items[self.y][2]:
         n += 1
         if n - 1 is not self.y1:
             color_text = self.color_text_add1
         else:
             color_text = self.color_text_cursor_add1
         if n < 10:
             i = unicode(n)
         elif n == 10:
             i = u'0'
         else:
             i = u''
         a = self.img_add1.measure_text(i + u' ' + t[0],
                                        'annotation',
                                        maxwidth=self.width_add1 - 23)
         if len(i + u' ' + t[0]) > a[2]:
             self.img_add1.text((4, 14 + d),
                                i + u' ' + t[0][:a[2] - 2] + u'...',
                                color_text, 'annotation')
         else:
             self.img_add1.text((4, 14 + d), i + u' ' + t[0], color_text,
                                'annotation')
         if t[1] is '2':
             self.img_add1.polygon(
                 (self.width_add1 - 9, 16 + d, self.width_add1 - 9, 4 + d,
                  self.width_add1 - 3, 10 + d),
                 fill=color_text)
         d += 20
     self.window_add1.add_image(self.img_add1, (0, 0))
     self.window_add1.show()
Пример #38
0
class Drawable(object):
    _window = None

    @staticmethod
    def recreateWindow():
        if Drawable._window:
            Drawable._window.close()
        Drawable._window = GraphWin("LodeRunner", Config.WINDOW_WIDTH+20, Config.WINDOW_HEIGHT+20)
        Drawable._window.setBackground('white')

    @staticmethod
    def lost():
        t = Text(Point(Config.WINDOW_WIDTH/2+10, Config.WINDOW_HEIGHT/2+10), 'YOU LOST!')
        t.setSize(36)
        t.setTextColor('red')
        t.draw(Drawable._window)
        Drawable._window.getKey()
        exit(0)

    @staticmethod
    def won():
        t = Text(Point(Config.WINDOW_WIDTH/2+10, Config.WINDOW_HEIGHT/2+10), 'YOU WON!')
        t.setSize(36)
        t.setTextColor('red')
        t.draw(Drawable._window)
        time.sleep(2)

    def __init__(self, coords, img_path=None):
        if img_path:
            self._img = Image(Point((coords[0]+1)*Config.CELL_SIZE-1, (coords[1]+1)*Config.CELL_SIZE-1), os.path.join('graphics', img_path))
        else:
            self._img = None

    def draw(self):
        if self._img:
            self._img.draw(Drawable._window)

    def move_img(self, dx, dy):
        if self._img:
            self._img.move(dx * Config.CELL_SIZE, dy * Config.CELL_SIZE)

    def undraw(self):
        if self._img:
            self._img.undraw()
Пример #39
0
def viewit(top, tro):
    img=Image.new((176, 200))
    img.clear((180, 180, 180))
    img.polygon(((50, 15), (80, 15), (85, 8), (95, 8), (100, 15), (130, 15), (130, 40), (105, 35), (110, 70), (70, 70), (75, 35), (50, 40)), outline=0, fill=top)
    def tr():
        while 1:
            can.text((110, 55), u'short or long')
            e32.ao_sleep(0.5)
            hand(1)
            e32.ao_sleep(0.5)
    img.polygon((95, 8, 90, 18, 85, 8), (25, 25, 25))
    img.line((90, 18, 90, 70), (25, 25, 25))
    img.polygon(((105, 70), (120, 140), (95, 140), (90, 90), (85, 140), (60, 140), (75, 70)), outline=0, fill=tro)
    if tro==1:
        img.text((120, 100), u'striped...')
    def hand(rect):
        can.blit(img)
    lock=e32.Ao_lock()
    can=ui.Canvas(redraw_callback=hand)
    ui.app.screen='full'
    ui.app.body=can
    #thread.start_new_thread(tr, ())
    ui.app.exit_key_handler=lock.signal
    lock.wait()
Пример #40
0
__version__='0.96'
__site__='http://code.google.com/p/still-rainbow'
__author__='Serhiy Zagoriya (int_ua)'
__copyright__ = "Copyright 2009-2010, Serhiy Zagoriya"
__license__ = "GPLv3"
__email__ = "*****@*****.**"
# todo: i18n, scenario linking to other scenario, bookmark color

import appuifw
try:
 import e32,sysinfo,os
 from graphics import Image
except:
 appuifw.note(u'failed to\n import e32,sysinfo,os,graphics','error')

img=Image.new(sysinfo.display_pixels(),'RGB')
appuifw.app.screen='full'
appuifw.app.orientation='portrait'

#home=u'e:\\Python\\sr_files\\'
home=os.path.splitdrive(appuifw.app.full_name())[0]+u'\\private\\e6c858ac\\'
homecsv=home+u'csv\\'

color=[0,255,0]
velocity=10
custom_accuracy=24
showing_info=1
running=0
paused=0
color_channel=0
to_white=0
Пример #41
0
 def __init__(self, coords, img_path=None):
     if img_path:
         self._img = Image(Point((coords[0]+1)*Config.CELL_SIZE-1, (coords[1]+1)*Config.CELL_SIZE-1), os.path.join('graphics', img_path))
     else:
         self._img = None
Пример #42
0
lock=e32.Ao_lock()
b='None'
def rec(arg):
    global b
    red(1)
    a=unicode(arg['scancode'])
    b=unicode(arg['keycode'])
    can.text((10, 50), a, font='legend')
    can.text((35, 50), u'('+hex(int(a))+u')', font='symbol')
    can.text((10, 115), b, font='legend')
    can.text((45, 115), u'('+hex(int(b))+u')', font='symbol')
    if arg['type']==ui.EEventKeyUp:
        red(1)
        
def red(rect):
    global a
    if  b!='0':
        a=b
    can.blit(img)
    can.text((5, 165), u'last keycode is %s' %a, font='title')
    
img=Image.new((176, 144))
img.clear(0xb08080)
img.text((5, 20), u'scancode of pressed keys', font='title')
img.text((5, 67), u'keycode of pressed keys', font='title')
img=img.resize((176, 208))
can=ui.Canvas(redraw_callback=red, event_callback=rec)
ui.app.screen='full'
ui.app.body=can
ui.app.exit_key_handler=lock.signal
lock.wait()
Пример #43
0
import sys, os, e32
from graphics import Image

ALLICONS = "gpsloglm.jpg"

def findImages(): # really: Install icons ;-)
  for d in [".", os.path.dirname(__file__), r"E:\Python", r"C:\Python"]:
    global thisdir
    thisdir = os.path.normcase(os.path.abspath(d))
    if os.path.exists(os.path.join(thisdir, ALLICONS)): break
findImages()

ICONSIZE      = (64,64)
ICONS_PER_ROW = 2
ALLICONS      = Image.open(os.path.join(thisdir, ALLICONS))
DEFALPHA      = [ 0x7f7f7f, 0x1f1f1f ]
ICONCAT       = [ "Default",  "Speed 30", "Speed 50", "Speed 60", "Speed 70",
                  "Speed 80", "Speed 100" ]
ICONS         = [ (ICONCAT[idx], idx) for idx in range(len(ICONCAT)) ]
MARKERS       = ICONCAT[1:]
MARKERCAT     = "Speed"

assert len(ICONS) <= ALLICONS.size[1] / ICONSIZE[1] * ICONS_PER_ROW, \
       "Not enough icons in image file"


class GpsIcon(object):

  def __init__(self, image, idx, miffile=None, mifidx=None, mifmask=None):
    self.img  = Image.new(ICONSIZE)
    self.mask = Image.new(ICONSIZE,"L")