Exemplo n.º 1
0
    def __init__(self, **kwargs):
        super(Designer, self).__init__(**kwargs)
        self.root_name = ""
        self.popup = None
        self.file = ""
        
        # A count variable to give ids to generated widget
        self.count = 0

        #This variable updates to True when ctrl is pressed
        self.ctrl_pressed = False
        
        #Instantiate the WidgetTree
        self.widget_tree = WidgetTree(self)
        self.widget_tree_box.add_widget(self.widget_tree)
        
        #Instantiate MenuBar
        self.menubar = MenuBar(designer = self, pos_hint = {'x':0,'top':1}, \
                            canvas_area = self.canvas_area, size_hint = (.70,None),height = 25)
        self.add_widget(self.menubar)
        
        #Instantiate right widgets bar
        # We update the same widgets bar, and dont create new instances everytime
        self.widgetbar = NewWidgetsMenu(self)
        self.rightbox.add_widget(self.widgetbar)
        
        #Initialize the keyboard and set up handlers for key press and release
        self.canvas_area._keyboard = Window.request_keyboard(self._keyboard_closed,self)
        self.canvas_area._keyboard.bind(on_key_down=self._on_keyboard_down)
        self.canvas_area._keyboard.bind(on_key_up = self._on_keyboard_up)
        # Setup canvas for highlighting
        with self.canvas.after:
            self.gcolor = Color(1, 1, 0, .25)
            PushMatrix()
            self.gtranslate = Translate(0, 0, 0)
            self.grotate = Rotate(0, 0, 0, 1)
            self.gscale = Scale(1.)
            self.grect = Rectangle(size=(0, 0))
            PopMatrix()
        # Instantiate Statusbar
        self.status_bar = StatusBar(size_hint = (1,.05))
        self.leftbox.add_widget(self.status_bar)
        
        #Show properties binding
        # self.widget -> updated on_touch_down in 'canvas_area'
        # So, whenever we have a new self.widget, we call show_properties
        self.bind(widget = self.show_properties)
        self.bind(widget = self.widget_tree.select_highlighted)