示例#1
0
    def __init__(self, x, y, width, context, save):
        self._save          = save
        self._context       = context
        self.pcursor        = context.KT.PCURSOR
        self.serialize      = context.KT.serialize
        self.deserialize    = context.KT.deserialize

        self.font = ISTYLES[('mono',)]
        fontsize = self.font['fontsize']
        self._K = self.font['__gridfont__'].advance_pixel_width(' ') * fontsize
        self._leading = int(fontsize * 1.3)
        
        self._charlength = int((width - 30) // self._K)
        width = int(self._charlength * self._K + 30)

        palatte = {Token.Text: "#2e3436",
                        Token.Name.Attribute: "#7A6ACD",
                        Token.Literal.String: "#9a43ff",
                        Token.Name.Tag: "#6b5fef",
                        Token.Error: "1, 0.2, 0.3"}
        self._palatte = {token: interpret_rgba(color) for token, color in palatte.items()}
        
        Kookie.__init__(self, x, y, width, 0)
        
        self._read()
        
        self.is_over_hover = self.is_over
        
        # cursors
        self._i = 0
        self._j = 0
        
        self._active = False
        self._invalid = False
示例#2
0
 def __init__(self, WI, x, y, width, node, A, Z, name, refresh, no_z, override_in=None):        
     self.is_over_hover = self.is_over
     
     self._node = node
     self._A = A
     self._read_Z = Z
     self._refresh = refresh
     
     self._name = name
     
     if override_in is None:
         self._in = self._attribute_read
     else:
         self._in = override_in
         no_z = True
     
     if no_z:
         self._z_div = -inf
         self._widget_x = x
         wwidth = width
     else:
         self._z_div = x + 15
         self._widget_x = x + 25
         wwidth = width - 25
     self._z = not no_z
     
     self._WIDGET = self.__class__.widgetclass(wwidth, * WI[0], ** WI[1])
     Kookie.__init__(self, x, y, width, self._WIDGET.k)
     self._exit = self.__class__.widgetclass.exit
     self._WActive = False
     
     self.read()
示例#3
0
    def __init__(self,
                 x,
                 y,
                 width,
                 node,
                 context,
                 slot,
                 display=lambda: None,
                 lcap=0):
        self._display = display

        self._itemheight = 26
        self._node = node
        self._content = node.content
        self._context = context
        self._slot = slot

        self._LMAX = len(node.content) + lcap
        self._fonts = ISTYLES[('strong', )], ISTYLES[('emphasis', )]
        Kookie.__init__(self, x, y, width, self._itemheight * (self._LMAX + 1))

        # set hover function equal to press function
        self.is_over_hover = self.is_over

        x2 = x + width
        self._subdivisions = [x2 - 74, x2 - 50, x2 - 26]

        self.read()
示例#4
0
 def __init__(self, x, y, width, height, callback=None, name=''):
     Kookie.__init__(self, x, y, width, height)
     self._callback = callback
     
     self.is_over_hover = self.is_over
     
     self._label = text(x + width/2, self.y_bottom - self._height/2 + 5, name, ISTYLES[('strong',)], align=0)
示例#5
0
    def __init__(self, x, y, width, height, callback=None, name=''):
        Kookie.__init__(self, x, y, width, height)
        self._callback = callback

        self.is_over_hover = self.is_over

        self._label = text(x + width / 2,
                           self.y_bottom - self._height / 2 + 5,
                           name,
                           ISTYLES[('strong', )],
                           align=0)
示例#6
0
 def __init__(self, x, y, cellwidth, height, default=0, callback=None, signals=() ):
     Kookie.__init__(self, x, y, cellwidth * len(signals), height)
     self._signals = signals
     self._callback = callback
     
     self.is_over_hover = self.is_over
     
     self._active = default
     
     self._buttons = self._construct(ISTYLES[('strong',)], signals)
     self._xx = [k[0] for k in self._buttons]
示例#7
0
    def __init__(self,
                 x,
                 y,
                 width,
                 height,
                 get_text,
                 font=('title', ),
                 fontsize=None,
                 upper=False):
        Kookie.__init__(self, x, y, width, height)

        font = ISTYLES[font]
        self._typeset_text = lambda: text(
            x, y + fontsize, get_text(), font, fontsize=fontsize, upper=upper)
        self.read()
示例#8
0
    def __init__(self,
                 x,
                 y,
                 cellwidth,
                 height,
                 default=0,
                 callback=None,
                 signals=()):
        Kookie.__init__(self, x, y, cellwidth * len(signals), height)
        self._signals = signals
        self._callback = callback

        self.is_over_hover = self.is_over

        self._active = default

        self._buttons = self._construct(ISTYLES[('strong', )], signals)
        self._xx = [k[0] for k in self._buttons]
示例#9
0
    def __init__(self, x, y, width, node, context, slot, display=lambda: None, lcap=0):
        self._display = display
        
        self._itemheight = 26
        self._node = node
        self._content = node.content
        self._context = context
        self._slot = slot
        
        self._LMAX = len(node.content) + lcap
        self._fonts = ISTYLES[('strong',)], ISTYLES[('emphasis',)]
        Kookie.__init__(self, x, y, width, self._itemheight * (self._LMAX + 1))

        # set hover function equal to press function
        self.is_over_hover = self.is_over
        
        x2 = x + width
        self._subdivisions = [x2 - 74, x2 - 50, x2 - 26]
        
        self.read()
示例#10
0
    def __init__(self, x, y, width, item_height, signals=None):

        # 'centers' menu
        height = item_height * len(signals)
        k = constants.window.get_k()
        if y > k / 2:
            signals = tuple(reversed(signals))
            y -= height

        if y < 0:
            y = 0
        elif y + height > k:
            y = k - height

        Kookie.__init__(self, x, y, width, height)

        self._item_height = item_height
        self._signals = signals

        self._SF, self._labels = self._construct(ISTYLES[()])
示例#11
0
文件: menu.py 项目: kelvin13/Knockout
    def __init__(self, x, y, width, item_height, signals=None):

        # 'centers' menu
        height = item_height*len(signals)
        k = constants.window.get_k()
        if y > k/2:
            signals = tuple(reversed(signals))
            y -= height
            
        if y < 0:
            y = 0
        elif y + height > k:
            y = k - height

        Kookie.__init__(self, x, y, width, height)

        self._item_height = item_height
        self._signals = signals
        
        self._SF, self._labels = self._construct(ISTYLES[()])
示例#12
0
 def __init__(self, x, y, width, height, get_text, font=('title',), fontsize=None, upper=False):
     Kookie.__init__(self, x, y, width, height)
     
     font = ISTYLES[font]
     self._typeset_text = lambda: text(x, y + fontsize, get_text(), font, fontsize=fontsize, upper=upper)
     self.read()