def __init__(self): self.app_name = "DB Designer" self.state = None self.selected_table = None self.editing_column = None self.connecting_column = None self.connecting_connector = None self.wheel = None self.panX = 0 self.panY = 0 self.mousePX = 0 self.mousePY = 0 self.scaleXY = 1 self.oldPanY = 0 self.oldPanX = 0 self.oldScaleXY = 1 self.mousePressedX = 0 self.mousePressedY = 0 self.lastKeyCode = 0 self.debug = False self.tables = [] self.modules = [] self.api = None self.generate = None self.directory = None self.mouse_pointer = None self.active_widgets = [] self.active_widgets.append(Button(x=0, y=0, label="Save", call_back=self.save)) self.active_widgets.append(Button(x=0, y=0, label="Load", call_back=self.load)) self.active_widgets.append(Button(x=0, y=0, label="Generate", call_back=self.generate_button)) self.button_bar = ButtonBar(self.active_widgets, 10, 10)
class Application(object): def __init__(self): self.app_name = "DB Designer" self.state = None self.selected_table = None self.editing_column = None self.connecting_column = None self.connecting_connector = None self.wheel = None self.panX = 0 self.panY = 0 self.mousePX = 0 self.mousePY = 0 self.scaleXY = 1 self.oldPanY = 0 self.oldPanX = 0 self.oldScaleXY = 1 self.mousePressedX = 0 self.mousePressedY = 0 self.lastKeyCode = 0 self.debug = False self.tables = [] self.modules = [] self.api = None self.generate = None self.directory = None self.mouse_pointer = None self.active_widgets = [] self.active_widgets.append(Button(x=0, y=0, label="Save", call_back=self.save)) self.active_widgets.append(Button(x=0, y=0, label="Load", call_back=self.load)) self.active_widgets.append(Button(x=0, y=0, label="Generate", call_back=self.generate_button)) self.button_bar = ButtonBar(self.active_widgets, 10, 10) def save(self, button): from db_designer_fsm import Save self.changeState(Save) def load(self, button): from db_designer_fsm import Load self.changeState(Load) def generate_button(self, button): p = Popen(self.generate, shell=True, cwd=self.directory, stdout=PIPE) stdout, stderr = p.communicate() print stderr print stdout def changeState(self, state): if self.state: self.state.end(self) self.state = state if self.state: self.state.start(self) def draw(self, controller): if self.debug: fill(my_settings.COLOR) textSize(my_settings.TEXT_SIZE) text(self.state.name(), width - 100 - textWidth(self.state.name()), height - 100) fps = "fps: {0}".format(int(frameRate)) text(fps, width - 100 - textWidth(fps), height - 50) try: key_t = "" key_t = "key: {0} keyCode: {1}".format(str(key).strip(), keyCode) except Exception: pass text(key_t, width - 100 - textWidth(key_t), height - 70) mouseButton_t = "mouseButton: {0}".format(mouseButton) text(mouseButton_t, width - 100 - textWidth(mouseButton_t), height - 90) if self.wheel: self.wheel.draw(controller) self.button_bar.draw() if self.mouse_pointer: self.mouse_pointer.draw()