def __init__(self, array_deref_proxy):
        self.array_deref = array_deref_proxy.get()

        HBox.__init__(self, List([
            NormalWidgetMaker.make(self.array_deref.expr),
            make_label(style.bracket, "["),
            NormalWidgetMaker.make(self.array_deref.index),
            make_label(style.bracket, "]"),
        ]))
示例#2
0
    def __init__(self, node_proxy):
        self.node = node_proxy.get()

        left, right = self.operand_attrs
        HBox.__init__(self, List([
            NormalWidgetMaker.make(getattr(self.node, left)),
            make_label(style.operator, ' ' + self.op_string + ' '),
            NormalWidgetMaker.make(getattr(self.node, right)),
        ]))
        self.is_centered = True
示例#3
0
 def _make(cls, proxy, value):
     if value is None:
         return cls._spacer
     return VBox(List([
         make_label(style.else_, 'else'),
         NormalWidgetMaker._make(proxy, value),
     ]), relay_focus=True)
示例#4
0
    def __init__(self, function_proxy):
        self.function_proxy = function_proxy
        self.function = function_proxy.get()

        VBox.__init__(self, List([
            TypeWidgetMaker.make(self.function.type, self.function_proxy),
            NormalWidgetMaker.make(self.function.block),
        ]))
示例#5
0
    def __init__(self, define_proxy):
        self.define = define_proxy.get()

        HBox.__init__(self, List([
            make_label(style.define, '#define'),
            make_label(style.space, ' '),
            TextEdit(style.define_value, partial(loop.namer.get_name, self.define)),
            make_label(style.space, ' '),
            NormalWidgetMaker.make(self.define.expr),
        ]), relay_focus=True)
    def __init__(self, _type_proxy, variable_proxy):
        self.type = _type_proxy.get()

        HBox.__init__(self, List([
            make_label(style.paren, '('),
            PostTypeWidgetMaker.make(self.type.element_type, variable_proxy),
            make_label(style.bracket, '['),
            NormalWidgetMaker.make(self.type.size),
            make_label(style.bracket, ']'),
            make_label(style.paren, ')'),
        ]))
        self.is_centered = True
示例#7
0
    def __init__(self, node_proxy):
        self.node_proxy = node_proxy
        self.node = node_proxy.get()

        cond_part = HBox(List([
            make_label(style.while_, 'while'),
            make_label(style.paren, '('),
            NormalWidgetMaker.make(self.node.expr),
            make_label(style.paren, ')'),
        ]), relay_focus=True)
        cond_part.is_centered = True

        VBox.__init__(self, List([
            cond_part,
            NormalWidgetMaker.make(self.node.block),
        ]))

        self.focus_keymap.register_key(
            self.convert_to_if_key,
            Keymap.keydown_noarg(self._convert_to_if)
        )
示例#8
0
    def __init__(self, call_proxy):
        self.call = call_proxy.get()

        comma = make_label(style.comma, ', ')
        args_box = HBox(CacheMap(NormalWidgetMaker.make, self.call.args), relay_focus=True)
        args_box.padding_widget = comma
        HBox.__init__(self, List([
            NormalWidgetMaker.make(self.call.func),
            make_label(style.paren, "("),
            args_box,
            make_label(style.paren, ")"),
        ]))
示例#9
0
 def _value_widget(self, value_proxy, with_comma, emphasize_value):
     value = value_proxy.get()
     s = style.enum_value
     if value is emphasize_value:
         s = style.emphasize(s)
     l = [
         TextEdit(s, partial(loop.namer.get_name, value)),
         make_label(style.operator, ' = '),
         NormalWidgetMaker.make(value.value),
     ]
     if with_comma:
         l.append(self._comma)
     return HBox(List(l))
示例#10
0
    def __init__(self, return_proxy):
        self.return_ = return_proxy.get()

        HBox.__init__(
            self,
            List(
                [
                    make_label(style.return_, "return "),
                    NormalWidgetMaker.make(self.return_.expr),
                    make_label(style.semicolon, ";"),
                ]
            ),
        )
示例#11
0
    def __init__(self, node_proxy):
        self.node = node_proxy.get()

        left, right = self.operand_attrs
        HBox.__init__(self, List([
            NormalWidgetMaker.make(getattr(self.node, left)),
            make_label(style.operator, ' ' + self.op_string + ' '),
            NormalWidgetMaker.make(getattr(self.node, right)),
        ]))
        self.is_centered = True
        

class EqualsWidget(BinaryOpWidget):
    op_string = '=='
    operand_attrs = 'a', 'b'
NormalWidgetMaker.register(nodes.Equals, EqualsWidget)

class NotEqualsWidget(BinaryOpWidget):
    op_string = '!='
    operand_attrs = 'a', 'b'
NormalWidgetMaker.register(nodes.NotEquals, NotEqualsWidget)

class AssignWidget(BinaryOpWidget):
    op_string = '='
    operand_attrs = 'lvalue', 'rvalue'
NormalWidgetMaker.register(nodes.Assign, AssignWidget)

class SubtractWidget(BinaryOpWidget):
    op_string = '-'
    operand_attrs = 'lexpr', 'rexpr'
NormalWidgetMaker.register(nodes.Subtract, SubtractWidget)
示例#12
0
    convert_to_if_key = Keymap.Key(pygame.KMOD_CTRL, pygame.K_w)
    def __init__(self, node_proxy):
        self.node_proxy = node_proxy
        self.node = node_proxy.get()

        cond_part = HBox(List([
            make_label(style.while_, 'while'),
            make_label(style.paren, '('),
            NormalWidgetMaker.make(self.node.expr),
            make_label(style.paren, ')'),
        ]), relay_focus=True)
        cond_part.is_centered = True

        VBox.__init__(self, List([
            cond_part,
            NormalWidgetMaker.make(self.node.block),
        ]))

        self.focus_keymap.register_key(
            self.convert_to_if_key,
            Keymap.keydown_noarg(self._convert_to_if)
        )

    def _convert_to_if(self):
        """Convert this while to an if"""
        if_node = nodes.If(expr=self.node.expr,
                           if_true=self.node.block,
                           meta=self.node.meta)
        self.node_proxy.set(if_node)
NormalWidgetMaker.register(nodes.While, WhileWidget)
示例#13
0
# Copyright (c) 2007 Enough Project.
# See LICENSE for details.

from gui.Box import HBox
from gui.TextEdit import make_label
from codegui.widget_for import NormalWidgetMaker

from lib.observable.List import List

import style

class ArrayDerefWidget(HBox):
    def __init__(self, array_deref_proxy):
        self.array_deref = array_deref_proxy.get()

        HBox.__init__(self, List([
            NormalWidgetMaker.make(self.array_deref.expr),
            make_label(style.bracket, "["),
            NormalWidgetMaker.make(self.array_deref.index),
            make_label(style.bracket, "]"),
        ]))
import nodes
NormalWidgetMaker.register(nodes.ArrayDeref, ArrayDerefWidget)
示例#14
0
# Copyright (c) 2007 Enough Project.
# See LICENSE for details.

from gui.Box import HBox
from gui.TextEdit import make_label
from codegui.widget_for import NormalWidgetMaker

from lib.observable.List import List
from lib.observable.CacheMap import CacheMap

import style

class CallWidget(HBox):
    def __init__(self, call_proxy):
        self.call = call_proxy.get()

        comma = make_label(style.comma, ', ')
        args_box = HBox(CacheMap(NormalWidgetMaker.make, self.call.args), relay_focus=True)
        args_box.padding_widget = comma
        HBox.__init__(self, List([
            NormalWidgetMaker.make(self.call.func),
            make_label(style.paren, "("),
            args_box,
            make_label(style.paren, ")"),
        ]))
import nodes
NormalWidgetMaker.register(nodes.Call, CallWidget)
示例#15
0
# Copyright (c) 2007 Enough Project.
# See LICENSE for details.

from gui.Box import VBox, HBox
from gui.TextEdit import make_label
from codegui.widget_for import NormalWidgetMaker, TypeWidgetMaker

from lib.observable.List import List
        
class FunctionWidget(VBox):
    def __init__(self, function_proxy):
        self.function_proxy = function_proxy
        self.function = function_proxy.get()

        VBox.__init__(self, List([
            TypeWidgetMaker.make(self.function.type, self.function_proxy),
            NormalWidgetMaker.make(self.function.block),
        ]))
import nodes
NormalWidgetMaker.register(nodes.Function, FunctionWidget)
示例#16
0
        self.node = node_proxy.get()

        cond_part = HBox(List([
            make_label(style.if_, 'if'),
            make_label(style.paren, '('),
            NormalWidgetMaker.make(self.node.expr),
            make_label(style.paren, ')'),
        ]), relay_focus=True)
        cond_part.is_centered = True

        VBox.__init__(self, List([
            cond_part,
            NormalWidgetMaker.make(self.node.if_true),
            ElseWidgetMaker.make(self.node.if_false),
        ]))

        self.focus_keymap.register_key(
            self.convert_to_while_key,
            Keymap.keydown_noarg(self._convert_to_while)
        )

    def _convert_to_while(self):
        """Convert this if to a while"""
        if self.node.if_false.get() is not None:
            return
        while_node = nodes.While(expr=self.node.expr,
                                 block=self.node.if_true,
                                 meta=self.node.meta)
        self.node_proxy.set(while_node)
NormalWidgetMaker.register(nodes.If, IfWidget)
示例#17
0
    p = Profile() #clock)
    print "Profiling to", profile_filename
    p.runcall(func, *args, **kw)

    from pytools import lsprofcalltree
    k = lsprofcalltree.KCacheGrind(p)
    pdump_filename = profile_filename+'.pstats'
    p.dump_stats(pdump_filename)
    print "Profile dumped to", pdump_filename
    kcache_grind_filename = profile_filename+'.kcachegrind'
    with open(kcache_grind_filename, 'w+b') as f:
        k.output(f)
    print "Profile results written to", kcache_grind_filename

with pygame_display((1024, 768), pygame.DOUBLEBUF) as display:
    from codegui.loop import loop
    from codegui.BrowserWidget import BrowserWidget

    from codegui.Namer import Namer
    from codegui.widget_for import NormalWidgetMaker
    loop.namer = Namer()
    
    from example import example
    loop.browser = BrowserWidget(NormalWidgetMaker.make(example))

    import pygame
    pygame.key.set_repeat(250,10)

    loop.loop(display, loop.browser)
#    profile_call(loop.loop, display, loop.browser)
示例#18
0
# See LICENSE for details.

from gui.Box import HBox
from gui.TextEdit import make_label
from codegui.widget_for import NormalWidgetMaker

from lib.observable.List import List

import style


class ReturnWidget(HBox):
    def __init__(self, return_proxy):
        self.return_ = return_proxy.get()

        HBox.__init__(
            self,
            List(
                [
                    make_label(style.return_, "return "),
                    NormalWidgetMaker.make(self.return_.expr),
                    make_label(style.semicolon, ";"),
                ]
            ),
        )


import nodes

NormalWidgetMaker.register(nodes.Return, ReturnWidget)