From 1ba50389bff517512e417500f4c52ceeafdb06a5 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 13 Jun 2011 00:40:31 +0200 Subject: host/simu: randomize team color --- host/simu/robots/robospierre/model/bag.py | 3 +++ host/simu/view/switch.py | 2 ++ 2 files changed, 5 insertions(+) (limited to 'host/simu') diff --git a/host/simu/robots/robospierre/model/bag.py b/host/simu/robots/robospierre/model/bag.py index b9d3bc3f..cedb3805 100644 --- a/host/simu/robots/robospierre/model/bag.py +++ b/host/simu/robots/robospierre/model/bag.py @@ -28,11 +28,14 @@ from simu.model.motor_basic import MotorBasic from simu.model.distance_sensor_sensopart import DistanceSensorSensopart from simu.robots.robospierre.model.clamp import Clamp from math import pi +import random class Bag: def __init__ (self, scheduler, table, link_bag): self.color_switch = Switch (link_bag.io_hub.contact[0], invert = True) + self.color_switch.state = random.choice ((False, True)) + self.color_switch.notify () self.jack = Switch (link_bag.io_hub.contact[1], invert = True) self.strat_switch = Switch (link_bag.io_hub.contact[9], invert = True) self.contact = [ Switch (contact) diff --git a/host/simu/view/switch.py b/host/simu/view/switch.py index c0ec2d58..445cbd02 100644 --- a/host/simu/view/switch.py +++ b/host/simu/view/switch.py @@ -28,6 +28,8 @@ class Switch: def __init__ (self, frame, model, text): self.var = IntVar () + if model.state is not None: + self.var.set ((0, 1)[model.state]) self.button = Checkbutton (frame, variable = self.var, command = self.__update, text = text, indicatoron = False) self.button.pack () -- cgit v1.2.3