当前位置: 首页>>代码示例>>Python>>正文


Python __pyjamas__.JS类代码示例

本文整理汇总了Python中__pyjamas__.JS的典型用法代码示例。如果您正苦于以下问题:Python JS类的具体用法?Python JS怎么用?Python JS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, options):
     if options:
         self.renderer = \
             JS("""new $wnd.google.maps.DirectionsRenderer(@{{options}})""")
     else:
         self.renderer = \
             JS("""new $wnd.google.maps.DirectionsRenderer()""")
开发者ID:anandology,项目名称:pyjamas,代码行数:7,代码来源:DirectionsRenderer.py

示例2: __init__

 def __init__(self, year, month, day, d=None):
     if d is None:
         d = JS("""new Date(@{{year}}, @{{month}} - 1, @{{day}}, 0, 0, 0, 0)""")
     self._d = d
     self.year = d.getFullYear()
     self.month = d.getMonth() + 1.0
     self.day = d.getDate()
开发者ID:simbha,项目名称:pyjamas,代码行数:7,代码来源:datetime.py

示例3: __init__

 def __init__(self, options):
     if options:
         self.renderer = \
             JS("""new $wnd['google']['maps']['DirectionsRenderer'](@{{options}})""")
     else:
         self.renderer = \
             JS("""new $wnd['google']['maps']['DirectionsRenderer']()""")
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:DirectionsRenderer.py

示例4: time

 def time(self):
     """
     **pyjsdl.time.time**
     
     Return current computer time (in ms).
     """
     ctime = JS("new Date()")
     return ctime.getTime()
开发者ID:jggatc,项目名称:pyjsdl,代码行数:8,代码来源:time.py

示例5: __init__

class DirectionsService:

    def __init__(self):
        self.ds = JS("""new $wnd.google.maps.DirectionsService()""")

    def route(self, request, callback):
        self.ds.route(request,
           lambda jsResults, status:
               callback(translateDirectionsResults(jsResults), status))
开发者ID:anandology,项目名称:pyjamas,代码行数:9,代码来源:DirectionsService.py

示例6: __init__

class Geocoder:

    def __init__(self):
        self.geocoder = JS("new $wnd.google.maps.Geocoder()")

    def geocode(self, request, callback):

        self.geocoder.geocode(request,
            lambda jsResults, status:
            callback(translateGeocoderResults(jsResults), status))
开发者ID:anthonyrisinger,项目名称:translate-pyjs-org.appspot.com,代码行数:10,代码来源:Geocoder.py

示例7: __init__

class DirectionsRenderer:
    def __init__(self, options):
        if options:
            self.renderer = JS("""new $wnd.google.maps.DirectionsRenderer(options);""")
        else:
            self.renderer = JS("""new $wnd.google.maps.DirectionsRenderer();""")

    def setDirections(self, results):
        self.renderer.setDirections(translateDirectionsResults(results, True))

    def setMap(self, map):
        self.renderer.setMap(map)
开发者ID:emk,项目名称:pyjamas,代码行数:12,代码来源:DirectionsRenderer.py

示例8: __init__

 def __init__(self, data=None, offset=None, length=None, typedarray=None):
     """
     The PyTypedArray is instantiated with either the array size, an array of the TypedArray or Python type, or an existing ArrayBuffer to view, which creates a new TypedArray of size and included data as the specified type. Optional arguments include offset index at which ArrayBuffer data is inserted and length of an ArrayBuffer.
     """
     if data:
         if isinstance(data, int):
             if pyjs_mode.optimized:
                 self.__data = JS("""new @{{typedarray}}(@{{data}})""")
             else:
                 self.__data = JS("""new @{{typedarray}}(@{{data}}['valueOf']())""")
         elif isinstance(data, (list,tuple)):
             if pyjs_mode.optimized:
                 self.__data = JS("""new @{{typedarray}}(@{{data}}['getArray']())""")
             else:
                 data = [dat.valueOf() for dat in data]
                 self.__data = JS("""new @{{typedarray}}(@{{data}}['getArray']())""")
         elif isinstance(data, PyTypedArray):
             self.__data = JS("""new @{{typedarray}}(@{{data}}['__data'])""")
         else:   #TypedArray or ArrayBuffer
             if offset is None and length is None:
                 self.__data = JS("""new @{{typedarray}}(@{{data}})""")
             else:
                 if offset is None:
                     offset = 0
                 if length is None:
                     self.__data = JS("""new @{{typedarray}}(@{{data}}, @{{offset}})""")
                 else:
                     self.__data = JS("""new @{{typedarray}}(@{{data}}, @{{offset}}, @{{length}})""")
     else:
         self.__data = None
开发者ID:Lucytheanimefan,项目名称:Center-for-Advanced-HindSight-Games,代码行数:30,代码来源:pyjsarray.py

示例9: gmtime

def gmtime(t=None):
    if t is None:
        t = time()
    date = JS("new Date(@{{t}}*1000)")
    tm = struct_time()
    tm_year = tm.tm_year = int(date.getUTCFullYear())
    tm.tm_mon = int(date.getUTCMonth()) + 1
    tm.tm_mday = int(date.getUTCDate())
    tm.tm_hour = int(date.getUTCHours())
    tm.tm_min = int(date.getUTCMinutes())
    tm.tm_sec = int(date.getUTCSeconds())
    tm.tm_wday = (int(date.getUTCDay()) + 6) % 7
    tm.tm_isdst = 0
    startOfYear = JS("new Date('Jan 1 '+ @{{tm_year}} +' GMT+0000')")
    tm.tm_yday = 1 + int((t - startOfYear.getTime()/1000)/86400)
    return tm
开发者ID:audreyr,项目名称:pyjs,代码行数:16,代码来源:time.py

示例10: mktime

def mktime(t):
    """mktime(tuple) -> floating point number
    Convert a time tuple in local time to seconds since the Epoch."""
    tm_year = t[0]
    tm_mon = t[1] - 1
    tm_mday = t[2]
    tm_hour = t[3]
    tm_min = t[4]
    tm_sec = t[5]
    date = JS("new Date(@{{tm_year}}, @{{tm_mon}}, @{{tm_mday}}, @{{tm_hour}}, @{{tm_min}}, @{{tm_sec}})") # local time
    utc = JS("Date.UTC(@{{tm_year}}, @{{tm_mon}}, @{{tm_mday}}, @{{tm_hour}}, @{{tm_min}}, @{{tm_sec}})")/1000
    ts = date.getTime() / 1000
    if t[8] == 0:
        if ts - utc == timezone:
            return ts
        return ts + _dst
    return ts
开发者ID:audreyr,项目名称:pyjs,代码行数:17,代码来源:time.py

示例11: localtime

def localtime(t=None):
    if t == None:
        t = time()
    date = JS("new Date(t*1000)")
    tm = struct_time()
    tm.tm_year = date.getFullYear()
    tm.tm_mon = date.getMonth() + 1
    tm.tm_mday = date.getDate()
    tm.tm_hour = date.getHours()
    tm.tm_min = date.getMinutes()
    tm.tm_sec = date.getSeconds()
    tm.tm_wday = (date.getDay() + 6) % 7
    startOfYear = int((JS("new Date(tm.tm_year,0,1)").getTime()) / 1000)
    tm.tm_yday = 1 + int((t - startOfYear) / 86400)
    tm.tm_isdst = date.getTimezoneOffset()
    return tm
开发者ID:andreyvit,项目名称:pyjamas,代码行数:16,代码来源:time.py

示例12: gmtime

def gmtime(t=None):
    if t == None:
        t = time()
    date = JS("new Date(t*1000)")
    tm = struct_time()
    tm.tm_year = date.getUTCFullYear()
    tm.tm_mon = date.getUTCMonth() + 1
    tm.tm_mday = date.getUTCDate()
    tm.tm_hour = date.getUTCHours()
    tm.tm_min = date.getUTCMinutes()
    tm.tm_sec = date.getUTCSeconds()
    tm.tm_wday = (date.getUTCDay() + 6) % 7
    startOfYear = int((JS("new Date(tm.tm_year,0,1)").getTime()) / 1000)
    tm.tm_yday = 1 + int((t - startOfYear) / 86400)
    tm.tm_isdst = 0
    return tm
开发者ID:andreyvit,项目名称:pyjamas,代码行数:16,代码来源:time.py

示例13: __init__

class md5:
    def __init__(self, s=''):
        self.finished = False
        self.md5 = JS("new @{{!_md5}}()")
        self.md5.init()
        self.update(s)

    def update(self, s):
        for c in str(s):
            b = ord(c)
            self.md5.update(b)

    def hexdigest(self):
        if not self.finished:
            self.finished = True
            self.md5.finish()
        res = self.md5.getdigestBits()
        return hexstr(res)

    def digest(self):
        if not self.finished:
            self.finished = True
            self.md5.finish()
        return self.md5.getdigestBits()
开发者ID:Afey,项目名称:pyjs,代码行数:24,代码来源:md5.py

示例14: fromtimestamp

 def fromtimestamp(self, timestamp, tz=None):
     if tz != None:
         raise NotImplementedError("tz")
     d = JS("""new Date()""")
     d.setTime(timestamp * 1000.0)
     return datetime(0, 0, 0, d=d)
开发者ID:simbha,项目名称:pyjamas,代码行数:6,代码来源:datetime.py

示例15: localtime

def localtime(t=None):
    if t is None:
        t = time()
    date = JS("new Date(@{{t}}*1000)")
    dateOffset = date.getTimezoneOffset()
    tm = struct_time()
    tm_year = tm.tm_year = int(date.getFullYear())
    tm_mon = tm.tm_mon = int(date.getMonth()) + 1
    tm_mday = tm.tm_mday = int(date.getDate())
    tm.tm_hour = int(date.getHours())
    tm.tm_min = int(date.getMinutes())
    tm.tm_sec = int(date.getSeconds())
    tm.tm_wday = (int(date.getDay()) + 6) % 7
    tm.tm_isdst = 0 if timezone == 60*date.getTimezoneOffset() else 1
    startOfYear = JS("new Date(@{{tm_year}},0,1)") # local time
    startOfYearOffset = startOfYear.getTimezoneOffset()
    startOfDay = JS("new Date(@{{tm_year}},@{{tm_mon}}-1,@{{tm_mday}})")
    dt = float(startOfDay.getTime() - startOfYear.getTime())/1000
    dt = dt + 60 * (startOfYearOffset - dateOffset)
    tm.tm_yday = 1 + int(dt/86400.0)
    return tm
开发者ID:audreyr,项目名称:pyjs,代码行数:21,代码来源:time.py


注:本文中的__pyjamas__.JS类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。