diff options
author | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-06-16 18:28:26 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-06-16 18:28:26 (GMT) |
commit | 5da2f00e12120ad8da99e2c51517cff884754026 (patch) | |
tree | 22baba8946af0601fa223d0e4242ee6746597374 | |
parent | 351ced843ead1dee29fb59f805815a60f3e203a6 (diff) |
Revert "Интерфейс полностью изменилась в покое Флавио"
This reverts commit 351ced843ead1dee29fb59f805815a60f3e203a6.
-rwxr-xr-x | LegoJAM.py | 69 |
1 files changed, 43 insertions, 26 deletions
@@ -12,7 +12,7 @@ sys.path.append("nxt_plugin") # Import the API functions # Importamos las funciones de la API import nxt -from nxt import * +from nxt import Motor from interface.window import Window @@ -37,33 +37,50 @@ class LegoJAM(Window): def set_layout(self): canvas = gtk.VBox() - box = gtk.HBox() + store = gtk.ListStore(str, int) + combobox = gtk.ComboBox(store) + cell = gtk.CellRendererText() + combobox.pack_start(cell) + combobox.add_attribute(cell, 'text', 0) + canvas.pack_start(combobox, True, False) + combobox.show() num = 0 for i in ['A', 'B', 'C']: - motor_button = gtk.ToggleButton("Motor %s" % i) - motor_button.id = num - motor_button.show() - motor_button.connect("clicked", self.change_status) - box.pack_start(motor_button) - num += 1 - canvas.pack_start(box, True, True) + store.append(['Motor %s' % i, num]) + combobox.set_active(0) + + vbox = gtk.VBox() + run_button = gtk.Button("Encender") + run_button.show() + run_button.connect_object("clicked", self.run_motor, combobox) + vbox.pack_start(run_button) + stop_button = gtk.Button("Apagar") + stop_button.show() + stop_button.connect_object("clicked", self.stop_motor, combobox) + vbox.pack_start(stop_button) + vbox.show() + num += 1 + + canvas.pack_start(vbox, True, True) self.set_canvas(canvas) - def change_status(self, widget): - if widget.get_active(): - function = self.robot.run_motor - - elif not widget.get_active(): - function = self.robot.stop_motor - - if widget.id == 0: - function("A") - elif widget.id == 1: - function("B") - elif widget.id == 2: - function("C") + def run_motor(self, combobox): + if combobox.get_active() == 0: + self.robot.run_motor("A") + elif combobox.get_active() == 1: + self.robot.run_motor("B") + elif combobox.get_active() == 2: + self.robot.run_motor("C") + + def stop_motor(self, combobox): + if combobox.get_active() == 0: + self.robot.stop_motor("A") + elif combobox.get_active() == 1: + self.robot.stop_motor("B") + elif combobox.get_active() == 2: + self.robot.stop_motor("C") def delete_event(self, widget, event): self.salir() @@ -91,7 +108,7 @@ class Pancho(): def set_up(self): try: - self.robot = nxt.locator.find_one_brick(debug=True) + self.robot = nxt.locator.find_one_brick() for funcion in dir(self.robot): self.funciones.append(funcion) print funcion @@ -99,9 +116,9 @@ class Pancho(): except: print "El Robot se Encuentra Desconectado o Apagado" sys.exit(0) - self.motorA = Mimotor("A", self.robot, PORT_A) - self.motorB = Mimotor("B", self.robot, PORT_B) - self.motorC = Mimotor("C", self.robot, PORT_C) + self.motorA = Mimotor("A", self.robot, nxt.PORT_A) + self.motorB = Mimotor("B", self.robot, nxt.PORT_B) + self.motorC = Mimotor("C", self.robot, nxt.PORT_C) def run_motor(self, motor): if motor == "A": |