示例#1
0
 def load_html(self, html):
     wv = ui.WebView('Markdown Preview')
     wv.scales_page_to_fit = True
     wv.load_html(html)
     w, h = scene.get_screen_size()
     wv.width = w
     wv.height = h-60
     self.add_subview(wv)
示例#2
0
 def __init__(self, *args, **kwargs):
     w = scene.get_screen_size().w * 0.8
     h = scene.get_screen_size().h * 0.25
     path = ui.Path.rounded_rect(0, 0, w, h, 10)
     path.line_width = 8
     scene.ShapeNode.__init__(self,
                              path=path,
                              fill_color='#CDC1B4',
                              stroke_color='#BBADA0',
                              *args,
                              **kwargs)
     board = self.parent.board
     box = scene.Rect(board.bbox.x, board.bbox.y + board.bbox.h,
                      board.bbox.w, self.parent.size.h - board.bbox.h)
     self.position = box.center()
     self.score = 0
     self.highscore = dict()
     self.load_highscore()
     self.score_label = self.create_score_label()
     self.highscore_label = self.create_highscore_label()
     self.create_title_label()
     self.player_label = self.create_player_label()
	def __init__(self, *args, **kwargs):
		w = scene.get_screen_size().w*0.8
		h = scene.get_screen_size().h*0.25
		path = ui.Path.rounded_rect(0, 0, w, h, 10)
		path.line_width = 8
		scene.ShapeNode.__init__(
			self, path=path,
			fill_color='#CDC1B4',
			stroke_color='#BBADA0',
			*args, **kwargs
		)
		board = self.parent.board
		box = scene.Rect(
			board.bbox.x, board.bbox.y+board.bbox.h,
			board.bbox.w, self.parent.size.h-board.bbox.h
		)
		self.position = box.center()
		self.score = 0
		self.highscore = dict()
		self.load_highscore()
		self.score_label = self.create_score_label()
		self.highscore_label = self.create_highscore_label()
		self.create_title_label()
		self.player_label = self.create_player_label()
示例#4
0
def pythonista_info():  # 2.0.1 (201000)
	plist = plistlib.readPlist(os.path.abspath(os.path.join(sys.executable, '..', 'Info.plist')))
	
	ios_ver, _, machine_model = platform.mac_ver()
	
	return dict(
	pythonista_ver_str = plist['CFBundleShortVersionString'],
	pythonista_ver_num = plist['CFBundleVersion'],
	ios_ver_str = ios_ver,
	screen_resoultion = scene.get_screen_size(),
	screen_scale = scene.get_screen_scale(),
	machine_architecture = platform.architecture()[0],
	machine_model = machine_model,
	
	)
示例#5
0
#    iPad5,4 with a screen size of (1024 x 768) * 2

#
# built on:
# https://forum.omz-software.com/topic/2444/determining-pythonista-s-version/3

import os, platform, plistlib, scene, sys  # noqa


def pythonista_version():  # 2.0.1 (201000)
    plist = plistlib.readPlist(
        os.path.abspath(os.path.join(sys.executable, "..", "Info.plist")))
    return "{CFBundleShortVersionString} ({CFBundleVersion})".format(**plist)


ios_ver, _, machine_model = platform.mac_ver()
bit = platform.architecture()[0].rstrip("bit") + "-bit"
rez = "({:.0f} x {:.0f})".format(*scene.get_screen_size())
fmt = ("Pythonista version {} running Python {} on iOS {} on a {} {} with a "
       "screen size of {} * {:.0f}")
print(
    fmt.format(
        pythonista_version(),
        platform.python_version(),
        ios_ver,
        bit,
        machine_model,
        rez,
        scene.get_screen_scale(),
    ))
示例#6
0
"""Miscellaneous utility functions and constants for the game GUI."""

import os
from typing import Optional, Tuple

import scene

from color import Color
from piece import Piece
from utils import coord_to_idx

SPRITES_DIR = os.path.join(os.path.dirname(__file__), "sprites")
WIDTH, HEIGHT = map(int, scene.get_screen_size())
SQUARE_SIZE = min(WIDTH, HEIGHT) // 8


def get_image(piece: Piece,
              piece_name: Optional[str] = None,
              taken: bool = False) -> str:
    """Return the filepath for the given piece's sprite file."""
    if not piece_name:
        piece_name = piece.__class__.__name__
    if taken and piece.color == Color.BLACK:
        taken = "taken_"
    else:
        taken = ""
    return f"{SPRITES_DIR}/{taken}{piece.color.name.lower()}_{piece_name.lower()}.png"


def coord_to_pos(coord: str) -> Tuple[int, int]:
    """Return (x, y) screen position based on the square coordinate.
示例#7
0
# Python 3

# https://github.com/cclauss/Ten-lines-or-less/blob/master/pythonista_version.py

# Output: Pythonista version 1.6 (160037) on iOS 9.2 on an iPad3,4.
# Pythonista version 2.0.1 (201000) on iOS 9.2.1 on a 64-bit iPad5,4 with a screen size of (1024 x 768) * 2
# Pythonista version 3.0 (300007) running Python 3.5.1 on iOS 9.3.1 on a 64-bit iPad5,4 with a screen size of (1024 x 768) * 2
# Pythonista version 3.0 (300007) running Python 2.7.5 on iOS 9.3.1 on a 64-bit iPad5,4 with a screen size of (1024 x 768) * 2
#
# built on https://forum.omz-software.com/topic/2444/determining-pythonista-s-version/3

import os, platform, plistlib, scene, sys


def pythonista_version():  # 2.0.1 (201000)
    plist = plistlib.readPlist(
        os.path.abspath(os.path.join(sys.executable, '..', 'Info.plist')))
    return '{CFBundleShortVersionString} ({CFBundleVersion})'.format(**plist)


ios_ver, _, machine_model = platform.mac_ver()
bit = platform.architecture()[0].rstrip('bit') + '-bit'
rez = '({:.0f} x {:.0f})'.format(*scene.get_screen_size())
fmt = 'Pythonista version {} running Python {} on iOS {} on a {} {} with a screen size of {} * {:.0f}'
print(
    fmt.format(pythonista_version(), platform.python_version(), ios_ver, bit,
               machine_model, rez, scene.get_screen_scale()))