コード例 #1
0
ファイル: gui.py プロジェクト: rituparnamatkar/skdb
class App:
    def __init__(self):
        self.current_brick = None
        self.all_bricks = []
        self.cgraph = FakeIGraph()
        self.display = None
        
    def working_brick(self):
        working_brick = None
        if self.display.selected_shape: #should I use AIS/Context stuff instead?
            working_brick = self.find_part(self.display.selected_shape)
        if not working_brick: #find_part might not find a brick that matches, or maybe nothing was clicked
            working_brick = self.current_brick
        return working_brick

    def find_part(self, shape):
            for brick in self.all_bricks:
                if brick.shapes[0] == shape:
                    return brick
            raise Warning, "selected shape not found:" + str(shape)
            return False
            
    def delete(self, shape):
        '''erase selected shape and remove it from the connection graph if it's there'''
        done = False
        if self.display.selected_shape:
            for brick in self.all_bricks:
                if hasattr(brick, 'AIS_handle'):
                    if brick.shapes[0] == self.display.selected_shape:
                        self.display.Context.Erase(brick.AIS_handle) #should be the same as EraseSelected
                        self.cgraph.del_part(brick)
                        self.all_bricks.remove(brick)
                        done = True
        if not done: self.display.Context.EraseSelected()
コード例 #2
0
ファイル: paths.py プロジェクト: rituparnamatkar/skdb
def clear(event=None, app=app):
    app.current_brick = None
    app.all_bricks = []
    app.cgraph = FakeIGraph()
    display.EraseAll()
コード例 #3
0
ファイル: gui.py プロジェクト: rituparnamatkar/skdb
 def __init__(self):
     self.current_brick = None
     self.all_bricks = []
     self.cgraph = FakeIGraph()
     self.display = None