Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-06-16 18:00:38 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-06-16 18:00:38 (GMT)
commit351ced843ead1dee29fb59f805815a60f3e203a6 (patch)
tree8dd71b95fd5140cc2b474c236a57f518b8a39c5e
parent5e5f59bbc1db569727b97c9e603ea630fa6fdcfb (diff)
Интерфейс полностью изменилась в покое Флавио
-rwxr-xr-xLegoJAM.py69
1 files changed, 26 insertions, 43 deletions
diff --git a/LegoJAM.py b/LegoJAM.py
index 7a49ea7..868a39a 100755
--- a/LegoJAM.py
+++ b/LegoJAM.py
@@ -12,7 +12,7 @@ sys.path.append("nxt_plugin")
# Import the API functions
# Importamos las funciones de la API
import nxt
-from nxt import Motor
+from nxt import *
from interface.window import Window
@@ -37,50 +37,33 @@ class LegoJAM(Window):
def set_layout(self):
canvas = gtk.VBox()
- 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()
+ box = gtk.HBox()
num = 0
for i in ['A', 'B', 'C']:
- 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)
+ 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)
self.set_canvas(canvas)
- 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 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 delete_event(self, widget, event):
self.salir()
@@ -108,7 +91,7 @@ class Pancho():
def set_up(self):
try:
- self.robot = nxt.locator.find_one_brick()
+ self.robot = nxt.locator.find_one_brick(debug=True)
for funcion in dir(self.robot):
self.funciones.append(funcion)
print funcion
@@ -116,9 +99,9 @@ class Pancho():
except:
print "El Robot se Encuentra Desconectado o Apagado"
sys.exit(0)
- 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)
+ self.motorA = Mimotor("A", self.robot, PORT_A)
+ self.motorB = Mimotor("B", self.robot, PORT_B)
+ self.motorC = Mimotor("C", self.robot, PORT_C)
def run_motor(self, motor):
if motor == "A":