def __init__(self, NetworkTable): util.initialize_from_xml(self) self.dead = False self.plots = [] self.count = 0 self.netTable = NetworkTable self.netTable.PutBoolean('EnableTuning', True) self.figure = Figure(figsize=(5, 4), dpi=100) self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) # a gtk.DrawingArea self.graphImage = util.replace_widget(self.graphImage, self.canvas) self.toolbar = util.replace_widget( self.toolbar, NavigationToolbar(self.canvas, self.window)) self.window.show_all() # listen to network tables variables network_tables.attach_fn(self.netTable, "Catapult Values", self.on_update_CatapultValues, self.window) network_tables.attach_fn(self.netTable, "EnableTuning", self.on_update_EnableTuning, self.window)
def __init__(self, NetworkTable, frontProcessor, backProcessor): self.netTable = NetworkTable util.initialize_from_xml(self) # ----- Begin Cameras ----- self.BackCameraImage = util.replace_widget(self.BackCameraImage, target_widget.TargetWidget((320,240), self.netTable)) # ----- End Cameras ----- backProcessor.set_camera_widget(self.BackCameraImage) self.imageProcessors = [backProcessor] self.tuning_widget = util.replace_widget(self.tuning_widget, detector_tuning_widget.DetectorTuningWidget(backProcessor)) self.tuning_widget.initialize() # get notified when the robot switches modes network_tables.attach_fn(self.netTable, 'RobotMode', self.on_robot_mode_update, self.window) # show the window AND all of its child widgets. If you don't call show_all, the # children may not show up self.window.show_all() # make sure the UI kills itself when the UI window exits self.window.connect('destroy', self.on_destroy)
def __init__(self, NetworkTable): util.initialize_from_xml(self) self.dead = False self.plots = [] self.count = 0 self.netTable = NetworkTable self.netTable.PutBoolean('EnableTuning',True) self.figure = Figure(figsize=(5,4), dpi=100) self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self.figure) # a gtk.DrawingArea self.graphImage = util.replace_widget(self.graphImage, self.canvas) self.toolbar = util.replace_widget(self.toolbar, NavigationToolbar(self.canvas, self.window)) self.window.show_all() # listen to network tables variables network_tables.attach_fn(self.netTable, "Catapult Values", self.on_update_CatapultValues, self.window) network_tables.attach_fn(self.netTable, "EnableTuning", self.on_update_EnableTuning, self.window)
def __init__(self, NetworkTable, frontProcessor, backProcessor): self.netTable = NetworkTable util.initialize_from_xml(self) # ----- Begin Cameras ----- self.BackCameraImage = util.replace_widget( self.BackCameraImage, target_widget.TargetWidget((320, 240), self.netTable)) # ----- End Cameras ----- backProcessor.set_camera_widget(self.BackCameraImage) self.imageProcessors = [backProcessor] self.tuning_widget = util.replace_widget( self.tuning_widget, detector_tuning_widget.DetectorTuningWidget(backProcessor)) self.tuning_widget.initialize() # get notified when the robot switches modes network_tables.attach_fn(self.netTable, 'RobotMode', self.on_robot_mode_update, self.window) # show the window AND all of its child widgets. If you don't call show_all, the # children may not show up self.window.show_all() # make sure the UI kills itself when the UI window exits self.window.connect('destroy', self.on_destroy)
def __init__(self, NetworkTable, frontProcessor, backProcessor, competition): self.netTable = NetworkTable util.initialize_from_xml(self) self.shootPower = [10, 30, 50, 70, 90] self.currentShootPower = 4 # starts the timer self.starttime = None # self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#aaaaaa')) import pango self.font = pango.FontDescription("bold 18") self.fontMono = pango.FontDescription("Monospace 14") self.fontDistanceBig = pango.FontDescription("bold 100") # from wpilib import DriverStation # DriverStation.GetInstance() """# demo: load the images into pixbufs so that Gtk can use them active = util.pixbuf_from_file('toggle-on.png') inactive = util.pixbuf_from_file('toggle-off.png') # demo: create a ToggleButton widget. There are lots of widgets you can create real_widget = toggle_button.ToggleButton(active, inactive, clickable=True) # demo: replace a fake widget in the glade file with a 'real' widget util.replace_widget(self.toggleButton, real_widget) # demo: connect to the toggled event of the real widget, so that our # function gets called when the button state is changed real_widget.connect('toggled', self.on_toggleButton_toggled) """ # ----- Begin Position Set ----- self.netTable.PutNumber("position", 0) # ----- End Position Set----- # ----- Begin Fire Button ----- self.netTable.PutBoolean("BallLoaded", False) self.FireButton = self.image_button( "fire_good.png", "fire_bad.png", False, self.FireButton, "clicked", self.on_fire_clicked ) network_tables.attach_fn(self.netTable, "BallLoaded", self.on_ball_loaded, self.FireButton) # ----- End Fire Button ----- # ------ Begin Compressor Label ----- network_tables.attach_fn(self.netTable, "Compressor", self.update_compressor_image, self.compressoronoff) self.on = util.pixbuf_from_file("compressoron.jpg") self.off = util.pixbuf_from_file("compressoroff.jpg") # ------ End Compressor Label ----- # ----- Begin AutoWinch Toggle ----- active = util.pixbuf_from_file("booleanT.png") inactive = util.pixbuf_from_file("booleanF.png") real_widget = toggle_button.ToggleButton(active, inactive, clickable=True) util.replace_widget(self.autoWinchToggle, real_widget) real_widget.connect("toggled", self.on_autoWinch_toggled) # ----- End AutoWinch Toggle ----- # ----- Begin Cameras ----- self.BackCameraImage = util.replace_widget( self.BackCameraImage, target_widget.TargetWidget((320, 240), self.netTable) ) # ----- End Cameras ----- # ----- Begin Distance Bar ----- self.distanceBar.modify_font(self.fontMono) self.distanceBar.configure(2.5, 0, 2.5) self.netTable.PutNumber("Distance", 0) self.update_distance(None, 0) network_tables.attach_fn(self.netTable, "Distance", self.update_distance, self.distanceBar) # ----- End Distance Bar ----- # ----- Begin Arm ----- self.netTable.PutNumber("ArmSet", 0) self.netTable.PutNumber("ArmState", 0) self.armStateButtonLockDown = self.image_button( "armDownSel.png", "armDown.png", False, self.armStateButtonLockDown, "clicked", self.on_ArmStateLockedDown_pressed, ) self.armStateButtonUnlock = self.image_button( "armUnlockedSel.png", "armUnlocked.png", False, self.armStateButtonUnlock, "clicked", self.on_ArmStateUnlocked_pressed, ) self.armStateButtonLockUp = self.image_button( "armUpSel.png", "armUp.png", False, self.armStateButtonLockUp, "clicked", self.on_ArmStateLockedUp_pressed ) network_tables.attach_fn(self.netTable, "ArmState", self.update_arm_indicator, self.armStateButtonLockDown) # ----- End Arm ----- # ----- Begin Timer ----- self.timer.modify_font(self.font) self.on_timer() # ----- Begin Timer ----- # ----- Begin Robot State Image ----- self.netTable.PutBoolean("BallLoaded", False) self.RobotStateImage = util.replace_widget(self.RobotStateImage, robot_widget.RobotStateImage()) network_tables.attach_fn(self.netTable, "ArmState", self.RobotStateImage.updatearm, self.RobotStateImage) network_tables.attach_fn(self.netTable, "BallLoaded", self.RobotStateImage.updateball, self.RobotStateImage) # this is for whatever the catapult's angle is. network_tables.attach_fn(self.netTable, "ShootAngle", self.RobotStateImage.updatecatapult, self.RobotStateImage) # self.update_robot_state_image(None,None) # ----- End Robot State Image ----- # ----- Begin Robot Angle Widget ----- self.RobotAngleWidget = util.replace_widget(self.RobotAngleWidget, robot_angle_widget.RobotAngleWidget()) self.netTable.PutNumber("GyroAngle", 0) # robot angle widget sending the variable to itself network_tables.attach_fn(self.netTable, "GyroAngle", self.RobotAngleWidget.update, self.window) network_tables.attach_fn(self.netTable, "GyroEnabled", self.on_gyro_enabled, self.window) self.RobotAngleWidget.connect( "angle-enabled-changed", lambda w: self.netTable.PutBoolean("GyroEnabled", w.angle_enabled) ) # ----- End Robot Angle Widget ----- # ------ Begin Power Bar Slider ----- powerslider = self.PowerBarSlider.get_value() # ------ End Power Bar Slider ------- # ------ Begin Graph Window ----- self.GraphOpener = graphwindow.GraphOpener(self.netTable) # self.GraphPlot=graphwindow.GraphPlot(self.netTable) # ------ End Graph Window ------- """ code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here this is to help Matt navigate the code, and he apologizes. """ if competition: self.window.move(0, 0) self.window.resize(1356, 525) backProcessor.set_camera_widget(self.BackCameraImage) self.imageProcessors = [backProcessor] self.tuning_widget = util.replace_widget( self.tuning_widget, detector_tuning_widget.DetectorTuningWidget(backProcessor) ) self.tuning_widget.initialize() # get notified when the robot switches modes network_tables.attach_fn(self.netTable, "RobotMode", self.on_robot_mode_update, self.window) # setup the autonomous chooser self.autonomous_tuner = util.replace_widget( self.autonomous_tuner, autonomous_tuning_widget.AutonomousTuningWidget(self.netTable) ) # show the window AND all of its child widgets. If you don't call show_all, the # children may not show up self.window.show_all() self.setup_background() # make sure the UI kills itself when the UI window exits self.window.connect("destroy", self.on_destroy)
def __init__(self, NetworkTable, frontProcessor, backProcessor, competition): self.netTable = NetworkTable util.initialize_from_xml(self) self.shootPower = [10, 30, 50, 70, 90] self.currentShootPower = 4 #starts the timer self.starttime = None #self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('#aaaaaa')) import pango self.font = pango.FontDescription("bold 18") self.fontMono = pango.FontDescription("Monospace 14") self.fontDistanceBig = pango.FontDescription("bold 100") #from wpilib import DriverStation #DriverStation.GetInstance() '''# demo: load the images into pixbufs so that Gtk can use them active = util.pixbuf_from_file('toggle-on.png') inactive = util.pixbuf_from_file('toggle-off.png') # demo: create a ToggleButton widget. There are lots of widgets you can create real_widget = toggle_button.ToggleButton(active, inactive, clickable=True) # demo: replace a fake widget in the glade file with a 'real' widget util.replace_widget(self.toggleButton, real_widget) # demo: connect to the toggled event of the real widget, so that our # function gets called when the button state is changed real_widget.connect('toggled', self.on_toggleButton_toggled) ''' # ----- Begin Position Set ----- self.netTable.PutNumber('position', 0) # ----- End Position Set----- # ----- Begin Fire Button ----- self.netTable.PutBoolean("BallLoaded", False) self.FireButton = self.image_button('fire_good.png', 'fire_bad.png', False, self.FireButton, 'clicked', self.on_fire_clicked) network_tables.attach_fn(self.netTable, "BallLoaded", self.on_ball_loaded, self.FireButton) # ----- End Fire Button ----- #------ Begin Compressor Label ----- network_tables.attach_fn(self.netTable, "Compressor", self.update_compressor_image, self.compressoronoff) self.on = util.pixbuf_from_file('compressoron.jpg') self.off = util.pixbuf_from_file('compressoroff.jpg') #------ End Compressor Label ----- #----- Begin AutoWinch Toggle ----- active = util.pixbuf_from_file('booleanT.png') inactive = util.pixbuf_from_file('booleanF.png') real_widget = toggle_button.ToggleButton(active, inactive, clickable=True) util.replace_widget(self.autoWinchToggle, real_widget) real_widget.connect('toggled', self.on_autoWinch_toggled) # ----- End AutoWinch Toggle ----- # ----- Begin Cameras ----- self.BackCameraImage = util.replace_widget( self.BackCameraImage, target_widget.TargetWidget((320, 240), self.netTable)) # ----- End Cameras ----- # ----- Begin Distance Bar ----- self.distanceBar.modify_font(self.fontMono) self.distanceBar.configure(2.5, 0, 2.5) self.netTable.PutNumber("Distance", 0) self.update_distance(None, 0) network_tables.attach_fn(self.netTable, "Distance", self.update_distance, self.distanceBar) # ----- End Distance Bar ----- # ----- Begin Arm ----- self.netTable.PutNumber("ArmSet", 0) self.netTable.PutNumber("ArmState", 0) self.armStateButtonLockDown = self.image_button( 'armDownSel.png', 'armDown.png', False, self.armStateButtonLockDown, 'clicked', self.on_ArmStateLockedDown_pressed) self.armStateButtonUnlock = self.image_button( 'armUnlockedSel.png', 'armUnlocked.png', False, self.armStateButtonUnlock, 'clicked', self.on_ArmStateUnlocked_pressed) self.armStateButtonLockUp = self.image_button( 'armUpSel.png', 'armUp.png', False, self.armStateButtonLockUp, 'clicked', self.on_ArmStateLockedUp_pressed) network_tables.attach_fn(self.netTable, "ArmState", self.update_arm_indicator, self.armStateButtonLockDown) # ----- End Arm ----- # ----- Begin Timer ----- self.timer.modify_font(self.font) self.on_timer() # ----- Begin Timer ----- # ----- Begin Robot State Image ----- self.netTable.PutBoolean("BallLoaded", False) self.RobotStateImage = util.replace_widget( self.RobotStateImage, robot_widget.RobotStateImage()) network_tables.attach_fn(self.netTable, "ArmState", self.RobotStateImage.updatearm, self.RobotStateImage) network_tables.attach_fn(self.netTable, "BallLoaded", self.RobotStateImage.updateball, self.RobotStateImage) #this is for whatever the catapult's angle is. network_tables.attach_fn(self.netTable, "ShootAngle", self.RobotStateImage.updatecatapult, self.RobotStateImage) #self.update_robot_state_image(None,None) # ----- End Robot State Image ----- # ----- Begin Robot Angle Widget ----- self.RobotAngleWidget = util.replace_widget( self.RobotAngleWidget, robot_angle_widget.RobotAngleWidget()) self.netTable.PutNumber("GyroAngle", 0) # robot angle widget sending the variable to itself network_tables.attach_fn(self.netTable, 'GyroAngle', self.RobotAngleWidget.update, self.window) network_tables.attach_fn(self.netTable, 'GyroEnabled', self.on_gyro_enabled, self.window) self.RobotAngleWidget.connect( 'angle-enabled-changed', lambda w: self.netTable.PutBoolean('GyroEnabled', w.angle_enabled)) # ----- End Robot Angle Widget ----- # ------ Begin Power Bar Slider ----- powerslider = self.PowerBarSlider.get_value() # ------ End Power Bar Slider ------- # ------ Begin Graph Window ----- self.GraphOpener = graphwindow.GraphOpener(self.netTable) #self.GraphPlot=graphwindow.GraphPlot(self.netTable) # ------ End Graph Window ------- ''' code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here code starts here this is to help Matt navigate the code, and he apologizes. ''' if competition: self.window.move(0, 0) self.window.resize(1356, 525) backProcessor.set_camera_widget(self.BackCameraImage) self.imageProcessors = [backProcessor] self.tuning_widget = util.replace_widget( self.tuning_widget, detector_tuning_widget.DetectorTuningWidget(backProcessor)) self.tuning_widget.initialize() # get notified when the robot switches modes network_tables.attach_fn(self.netTable, 'RobotMode', self.on_robot_mode_update, self.window) # setup the autonomous chooser self.autonomous_tuner = util.replace_widget( self.autonomous_tuner, autonomous_tuning_widget.AutonomousTuningWidget(self.netTable)) # show the window AND all of its child widgets. If you don't call show_all, the # children may not show up self.window.show_all() self.setup_background() # make sure the UI kills itself when the UI window exits self.window.connect('destroy', self.on_destroy)