def __init__(self): # get a logger self.log = logging.getLogger("GTK_Main") # save init values self.fullscreen = False # this is technicaly not consistant as it is not chnaged on system uests self.robot = Robot(self.BT_ADDRESS) self.feed_radio = "real" self.fix_colour = False self.half_time = False # do some jazz to see if we are on dice and or video pc self.hostname = gethostname() self.are_in_inf = False self.are_on_vision_pc = False if self.hostname.endswith("inf.ed.ac.uk"): self.are_in_inf = True if self.hostname.split(".")[0] in [ "lappy", "mitsubishi", "lexus", "honda" ]: self.are_on_vision_pc = True # setup the window builder = gtk.Builder() builder.add_from_file("main_ui.xml") self.window = builder.get_object("window_main") # change out the image with are video widget video_holder_box = builder.get_object("box_videoHolder") video_holder_img = builder.get_object("image_videoHolder") self.gst = GstDrawingArea() video_holder_box.remove(video_holder_img) video_holder_box.add(self.gst) # connect to GUI events self.window.set_events(gtk.gdk.KEY_PRESS_MASK | gtk.gdk.KEY_RELEASE_MASK) self.window.connect("key_press_event", self.on_key_press) self.window.connect("key_release_event", self.on_key_release) self.window.connect("destroy", self.clean_quit) builder.connect_signals(self) # get all wigets that are needed later self.table_manualControl = builder.get_object("table_manualControl") # show the GUI self.gst.show() self.window.show() self.log.debug("GTK windows complete")
def __connect(self): self.button_connect["text"] = "Connecting" try: # first try to find are know robot self.robot = Robot(host=self.BT_ADDRESS) except RobotNotFoundError: # TODO # try to find any robot self.robot = Robot() except Exception as error: print "Robot Error" # + str(error) self.button_connect["text"] = "Connect" self.button_connect["state"] = "active" raise error self.scale_power.set(self.robot.get_power()) self.button_up["state"] = "active" self.button_dn["state"] = "active" self.button_le["state"] = "active" self.button_ri["state"] = "active" self.button_st["state"] = "active" self.button_bz["state"] = "active" self.scale_power["state"] = "active" self.button_connect["state"] = "disabled" self.button_connect["text"] = "Connected"
def __connect(self, widget=None, data=None): if not self.button_connect.get_active(): self.button_connect.set_active(True) # keep it active return # ingnor button when not acctive if self.robot != None: self.log.warning("Tryed to connect to a already connected brick") return self.button_connect.set_label("Connecting") try: # first try to find are know robot self.robot = Robot(host=self.BT_ADDRESS) self.button_connect.set_label("Conected") self.button_connect.set_active(True) except Exception as error: self.log.error(error) self.button_connect.set_label("Connect") self.button_connect.set_active(False) self.robot = None