_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q230900
MPModule.link_label
train
def link_label(link): '''return a link label as a string''' if hasattr(link, 'label'): label = link.label else: label = str(link.linknum+1) return label
python
{ "resource": "" }
q230901
MPModule.is_primary_vehicle
train
def is_primary_vehicle(self, msg): '''see if a msg is from our primary vehicle''' sysid = msg.get_srcSystem() if self.target_system == 0 or self.target_system == sysid: return True return False
python
{ "resource": "" }
q230902
MavGraph.next_flightmode_colour
train
def next_flightmode_colour(self): '''allocate a colour to be used for a flight mode''' if self.flightmode_colour_index > len(flightmode_colours): print("Out of colours; reusing") self.flightmode_colour_index = 0 ret = flightmode_colours[self.flightmode_colour_index] ...
python
{ "resource": "" }
q230903
MavGraph.flightmode_colour
train
def flightmode_colour(self, flightmode): '''return colour to be used for rendering a flight mode background''' if flightmode not in self.flightmode_colourmap: self.flightmode_colourmap[flightmode] = self.next_flightmode_colour() return self.flightmode_colourmap[flightmode]
python
{ "resource": "" }
q230904
MavGraph.setup_xrange
train
def setup_xrange(self, xrange): '''setup plotting ticks on x axis''' if self.xaxis: return xrange *= 24 * 60 * 60 interval = 1 intervals = [ 1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600, 900, 1800, 3600, 7200, 5*3600, 10*3600, 24*3600 ] fo...
python
{ "resource": "" }
q230905
MavGraph.xlim_changed
train
def xlim_changed(self, axsubplot): '''called when x limits are changed''' xrange = axsubplot.get_xbound() xlim = axsubplot.get_xlim() self.setup_xrange(xrange[1] - xrange[0]) if self.draw_events == 0: # ignore limit change before first draw event return ...
python
{ "resource": "" }
q230906
MavGraph.timestamp_to_days
train
def timestamp_to_days(self, timestamp): '''convert log timestamp to days''' if self.tday_base is None: try: self.tday_base = matplotlib.dates.date2num(datetime.datetime.fromtimestamp(timestamp+self.timeshift)) self.tday_basetime = timestamp except ...
python
{ "resource": "" }
q230907
MavGraph.xlim_change_check
train
def xlim_change_check(self, idx): '''handle xlim change requests from queue''' if not self.xlim_pipe[1].poll(): return xlim = self.xlim_pipe[1].recv() if xlim is None: return #print("recv: ", self.graph_num, xlim) if self.ax1 is not None and xlim !...
python
{ "resource": "" }
q230908
MiscModule.cmd_lockup_autopilot
train
def cmd_lockup_autopilot(self, args): '''lockup autopilot for watchdog testing''' if len(args) > 0 and args[0] == 'IREALLYMEANIT': print("Sending lockup command") self.master.mav.command_long_send(self.settings.target_system, self.settings.target_component, ...
python
{ "resource": "" }
q230909
MiscModule.cmd_gethome
train
def cmd_gethome(self, args): '''get home position''' self.master.mav.command_long_send(self.settings.target_system, 0, mavutil.mavlink.MAV_CMD_GET_HOME_POSITION, 0, 0, 0, 0, 0, 0...
python
{ "resource": "" }
q230910
MiscModule.cmd_led
train
def cmd_led(self, args): '''send LED pattern as override''' if len(args) < 3: print("Usage: led RED GREEN BLUE <RATE>") return pattern = [0] * 24 pattern[0] = int(args[0]) pattern[1] = int(args[1]) pattern[2] = int(args[2]) if len(...
python
{ "resource": "" }
q230911
MiscModule.cmd_oreoled
train
def cmd_oreoled(self, args): '''send LED pattern as override, using OreoLED conventions''' if len(args) < 4: print("Usage: oreoled LEDNUM RED GREEN BLUE <RATE>") return lednum = int(args[0]) pattern = [0] * 24 pattern[0] = ord('R') pattern[1] = ord...
python
{ "resource": "" }
q230912
MiscModule.cmd_playtune
train
def cmd_playtune(self, args): '''send PLAY_TUNE message''' if len(args) < 1: print("Usage: playtune TUNE") return tune = args[0] str1 = tune[0:30] str2 = tune[30:] if sys.version_info.major >= 3 and not isinstance(str1, bytes): str1 = b...
python
{ "resource": "" }
q230913
MiscModule.cmd_devid
train
def cmd_devid(self, args): '''decode device IDs from parameters''' for p in self.mav_param.keys(): if p.startswith('COMPASS_DEV_ID'): mp_util.decode_devid(self.mav_param[p], p) if p.startswith('INS_') and p.endswith('_ID'): mp_util.decode_devid(sel...
python
{ "resource": "" }
q230914
MapModule.add_menu
train
def add_menu(self, menu): '''add to the default popup menu''' from MAVProxy.modules.mavproxy_map import mp_slipmap self.default_popup.add(menu) self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_popup, combine=True))
python
{ "resource": "" }
q230915
MapModule.colour_for_wp
train
def colour_for_wp(self, wp_num): '''return a tuple describing the colour a waypoint should appear on the map''' wp = self.module('wp').wploader.wp(wp_num) command = wp.command return self._colour_for_wp_command.get(command, (0,255,0))
python
{ "resource": "" }
q230916
MapModule.label_for_waypoint
train
def label_for_waypoint(self, wp_num): '''return the label the waypoint which should appear on the map''' wp = self.module('wp').wploader.wp(wp_num) command = wp.command if command not in self._label_suffix_for_wp_command: return str(wp_num) return str(wp_num) + "(" + ...
python
{ "resource": "" }
q230917
MapModule.remove_mission_nofly
train
def remove_mission_nofly(self, key, selection_index): '''remove a mission nofly polygon''' if not self.validate_nofly(): print("NoFly invalid") return print("NoFly valid") idx = self.selection_index_to_idx(key, selection_index) wploader = self.module('wp'...
python
{ "resource": "" }
q230918
MapModule.handle_menu_event
train
def handle_menu_event(self, obj): '''handle a popup menu event from the map''' menuitem = obj.menuitem if menuitem.returnkey.startswith('# '): cmd = menuitem.returnkey[2:] if menuitem.handler is not None: if menuitem.handler_result is None: ...
python
{ "resource": "" }
q230919
MapModule.map_callback
train
def map_callback(self, obj): '''called when an event happens on the slipmap''' from MAVProxy.modules.mavproxy_map import mp_slipmap if isinstance(obj, mp_slipmap.SlipMenuEvent): self.handle_menu_event(obj) return if not isinstance(obj, mp_slipmap.SlipMouseEvent): ...
python
{ "resource": "" }
q230920
MapModule.drawing_end
train
def drawing_end(self): '''end line drawing''' from MAVProxy.modules.mavproxy_map import mp_slipmap if self.draw_callback is None: return self.draw_callback(self.draw_line) self.draw_callback = None self.map.add_object(mp_slipmap.SlipDefaultPopup(self.default_p...
python
{ "resource": "" }
q230921
MapModule.draw_lines
train
def draw_lines(self, callback): '''draw a series of connected lines on the map, calling callback when done''' from MAVProxy.modules.mavproxy_map import mp_slipmap self.draw_callback = callback self.draw_line = [] self.map.add_object(mp_slipmap.SlipDefaultPopup(None))
python
{ "resource": "" }
q230922
MapModule.cmd_set_originpos
train
def cmd_set_originpos(self, args): '''called when user selects "Set Origin" on map''' (lat, lon) = (self.click_position[0], self.click_position[1]) print("Setting origin to: ", lat, lon) self.master.mav.set_gps_global_origin_send( self.settings.target_system, lat*...
python
{ "resource": "" }
q230923
MapModule.cmd_center
train
def cmd_center(self, args): '''control center of view''' if len(args) < 3: print("map center LAT LON") return lat = float(args[1]) lon = float(args[2]) self.map.set_center(lat, lon)
python
{ "resource": "" }
q230924
MapModule.cmd_follow
train
def cmd_follow(self, args): '''control following of vehicle''' if len(args) < 2: print("map follow 0|1") return follow = int(args[1]) self.map.set_follow(follow)
python
{ "resource": "" }
q230925
MapModule.set_secondary_vehicle_position
train
def set_secondary_vehicle_position(self, m): '''show 2nd vehicle on map''' if m.get_type() != 'GLOBAL_POSITION_INT': return (lat, lon, heading) = (m.lat*1.0e-7, m.lon*1.0e-7, m.hdg*0.01) if abs(lat) < 1.0e-3 and abs(lon) > 1.0e-3: return # hack for OBC2016...
python
{ "resource": "" }
q230926
KmlReadModule.cmd_param
train
def cmd_param(self, args): '''control kml reading''' usage = "Usage: kml <clear | load (filename) | layers | toggle (layername) | fence (layername)>" if len(args) < 1: print(usage) return elif args[0] == "clear": self.clearkml() elif args[0] ==...
python
{ "resource": "" }
q230927
KmlReadModule.cmd_snap_wp
train
def cmd_snap_wp(self, args): '''snap waypoints to KML''' threshold = 10.0 if len(args) > 0: threshold = float(args[0]) wpmod = self.module('wp') wploader = wpmod.wploader changed = False for i in range(1,wploader.count()): w = wploader.wp(i...
python
{ "resource": "" }
q230928
KmlReadModule.cmd_snap_fence
train
def cmd_snap_fence(self, args): '''snap fence to KML''' threshold = 10.0 if len(args) > 0: threshold = float(args[0]) fencemod = self.module('fence') loader = fencemod.fenceloader changed = False for i in range(0,loader.count()): fp = loade...
python
{ "resource": "" }
q230929
KmlReadModule.fencekml
train
def fencekml(self, layername): '''set a layer as the geofence''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #for each point in the layer, add it in for layer in self.allayers: ...
python
{ "resource": "" }
q230930
KmlReadModule.togglekml
train
def togglekml(self, layername): '''toggle the display of a kml''' #Strip quotation marks if neccessary if layername.startswith('"') and layername.endswith('"'): layername = layername[1:-1] #toggle layer off (plus associated text element) if layername in self.curlayers...
python
{ "resource": "" }
q230931
KmlReadModule.clearkml
train
def clearkml(self): '''Clear the kmls from the map''' #go through all the current layers and remove them for layer in self.curlayers: self.mpstate.map.remove_object(layer) for layer in self.curtextlayers: self.mpstate.map.remove_object(layer) self.allayers...
python
{ "resource": "" }
q230932
KmlReadModule.loadkml
train
def loadkml(self, filename): '''Load a kml from file and put it on the map''' #Open the zip file nodes = self.readkmz(filename) self.snap_points = [] #go through each object in the kml... for n in nodes: point = self.readObject(n) #and plac...
python
{ "resource": "" }
q230933
KmlReadModule.idle_task
train
def idle_task(self): '''handle GUI elements''' if not self.menu_needs_refreshing: return if self.module('map') is not None and not self.menu_added_map: self.menu_added_map = True self.module('map').add_menu(self.menu) #(re)create the menu if mp...
python
{ "resource": "" }
q230934
KmlReadModule.readkmz
train
def readkmz(self, filename): '''reads in a kmz file and returns xml nodes''' #Strip quotation marks if neccessary filename.strip('"') #Open the zip file (as applicable) if filename[-4:] == '.kml': fo = open(filename, "r") fstring = fo.read() ...
python
{ "resource": "" }
q230935
AsterixModule.cmd_asterix
train
def cmd_asterix(self, args): '''asterix command parser''' usage = "usage: asterix <set|start|stop|restart|status>" if len(args) == 0: print(usage) return if args[0] == "set": self.asterix_settings.command(args[1:]) elif args[0] == "start": ...
python
{ "resource": "" }
q230936
AsterixModule.start_listener
train
def start_listener(self): '''start listening for packets''' if self.sock is not None: self.sock.close() self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.sock.bind(('',...
python
{ "resource": "" }
q230937
AsterixModule.stop_listener
train
def stop_listener(self): '''stop listening for packets''' if self.sock is not None: self.sock.close() self.sock = None self.tracks = {}
python
{ "resource": "" }
q230938
AsterixModule.set_secondary_vehicle_position
train
def set_secondary_vehicle_position(self, m): '''store second vehicle position for filtering purposes''' if m.get_type() != 'GLOBAL_POSITION_INT': return (lat, lon, heading) = (m.lat*1.0e-7, m.lon*1.0e-7, m.hdg*0.01) if abs(lat) < 1.0e-3 and abs(lon) < 1.0e-3: retu...
python
{ "resource": "" }
q230939
AsterixModule.could_collide_hor
train
def could_collide_hor(self, vpos, adsb_pkt): '''return true if vehicle could come within filter_dist_xy meters of adsb vehicle in timeout seconds''' margin = self.asterix_settings.filter_dist_xy timeout = self.asterix_settings.filter_time alat = adsb_pkt.lat * 1.0e-7 alon = adsb_...
python
{ "resource": "" }
q230940
AsterixModule.could_collide_ver
train
def could_collide_ver(self, vpos, adsb_pkt): '''return true if vehicle could come within filter_dist_z meters of adsb vehicle in timeout seconds''' if adsb_pkt.emitter_type < 100 or adsb_pkt.emitter_type > 104: return True margin = self.asterix_settings.filter_dist_z vtype = ...
python
{ "resource": "" }
q230941
AsterixModule.mavlink_packet
train
def mavlink_packet(self, m): '''get time from mavlink ATTITUDE''' if m.get_type() == 'GLOBAL_POSITION_INT': if abs(m.lat) < 1000 and abs(m.lon) < 1000: return self.vehicle_pos = VehiclePos(m)
python
{ "resource": "" }
q230942
LinkModule.complete_serial_ports
train
def complete_serial_ports(self, text): '''return list of serial ports''' ports = mavutil.auto_detect_serial(preferred_list=preferred_ports) return [ p.device for p in ports ]
python
{ "resource": "" }
q230943
LinkModule.complete_links
train
def complete_links(self, text): '''return list of links''' try: ret = [ m.address for m in self.mpstate.mav_master ] for m in self.mpstate.mav_master: ret.append(m.address) if hasattr(m, 'label'): ret.append(m.label) ...
python
{ "resource": "" }
q230944
LinkModule.cmd_link_attributes
train
def cmd_link_attributes(self, args): '''change optional link attributes''' link = args[0] attributes = args[1] print("Setting link %s attributes (%s)" % (link, attributes)) self.link_attributes(link, attributes)
python
{ "resource": "" }
q230945
LinkModule.find_link
train
def find_link(self, device): '''find a device based on number, name or label''' for i in range(len(self.mpstate.mav_master)): conn = self.mpstate.mav_master[i] if (str(i) == device or conn.address == device or getattr(conn, 'label', None) == device...
python
{ "resource": "" }
q230946
LinkModule.cmd_link_remove
train
def cmd_link_remove(self, args): '''remove an link''' device = args[0] if len(self.mpstate.mav_master) <= 1: print("Not removing last link") return i = self.find_link(device) if i is None: return conn = self.mpstate.mav_master[i] ...
python
{ "resource": "" }
q230947
LinkModule.master_send_callback
train
def master_send_callback(self, m, master): '''called on sending a message''' if self.status.watch is not None: for msg_type in self.status.watch: if fnmatch.fnmatch(m.get_type().upper(), msg_type.upper()): self.mpstate.console.writeln('> '+ str(m)) ...
python
{ "resource": "" }
q230948
LinkModule.handle_msec_timestamp
train
def handle_msec_timestamp(self, m, master): '''special handling for MAVLink packets with a time_boot_ms field''' if m.get_type() == 'GLOBAL_POSITION_INT': # this is fix time, not boot time return msec = m.time_boot_ms if msec + 30000 < master.highest_msec: ...
python
{ "resource": "" }
q230949
LinkModule.report_altitude
train
def report_altitude(self, altitude): '''possibly report a new altitude''' master = self.master if getattr(self.console, 'ElevationMap', None) is not None and self.mpstate.settings.basealt != 0: lat = master.field('GLOBAL_POSITION_INT', 'lat', 0)*1.0e-7 lon = master.field(...
python
{ "resource": "" }
q230950
LinkModule.cmd_vehicle
train
def cmd_vehicle(self, args): '''handle vehicle commands''' if len(args) < 1: print("Usage: vehicle SYSID[:COMPID]") return a = args[0].split(':') self.mpstate.settings.target_system = int(a[0]) if len(a) > 1: self.mpstate.settings.target_compon...
python
{ "resource": "" }
q230951
DeviceOpModule.devop_read
train
def devop_read(self, args, bustype): '''read from device''' if len(args) < 5: print("Usage: devop read <spi|i2c> name bus address regstart count") return name = args[0] bus = int(args[1],base=0) address = int(args[2],base=0) reg = int(args[3],base=...
python
{ "resource": "" }
q230952
DeviceOpModule.devop_write
train
def devop_write(self, args, bustype): '''write to a device''' usage = "Usage: devop write <spi|i2c> name bus address regstart count <bytes>" if len(args) < 5: print(usage) return name = args[0] bus = int(args[1],base=0) address = int(args[2],base=0...
python
{ "resource": "" }
q230953
Geo_reference.get_absolute
train
def get_absolute(self, points): """Given a set of points geo referenced to this instance, return the points as absolute values. """ # remember if we got a list is_list = isinstance(points, list) points = ensure_numeric(points, num.float) if len(points.shape) == ...
python
{ "resource": "" }
q230954
CameraViewModule.cmd_cameraview
train
def cmd_cameraview(self, args): '''camera view commands''' state = self if args and args[0] == 'set': if len(args) < 3: state.view_settings.show_all() else: state.view_settings.set(args[1], args[2]) state.update_col() ...
python
{ "resource": "" }
q230955
CameraViewModule.scale_rc
train
def scale_rc(self, servo, min, max, param): '''scale a PWM value''' # default to servo range of 1000 to 2000 min_pwm = self.get_mav_param('%s_MIN' % param, 0) max_pwm = self.get_mav_param('%s_MAX' % param, 0) if min_pwm == 0 or max_pwm == 0: return 0 if ma...
python
{ "resource": "" }
q230956
raise_msg_to_str
train
def raise_msg_to_str(msg): """msg is a return arg from a raise. Join with new lines""" if not is_string_like(msg): msg = '\n'.join(map(str, msg)) return msg
python
{ "resource": "" }
q230957
_create_wx_app
train
def _create_wx_app(): """ Creates a wx.App instance if it has not been created sofar. """ wxapp = wx.GetApp() if wxapp is None: wxapp = wx.App(False) wxapp.SetExitOnFrameDelete(True) # retain a reference to the app object so it does not get garbage # collected and cau...
python
{ "resource": "" }
q230958
draw_if_interactive
train
def draw_if_interactive(): """ This should be overriden in a windowing environment if drawing should be done in interactive python mode """ DEBUG_MSG("draw_if_interactive()", 1, None) if matplotlib.is_interactive(): figManager = Gcf.get_active() if figManager is not None: ...
python
{ "resource": "" }
q230959
RendererWx.new_gc
train
def new_gc(self): """ Return an instance of a GraphicsContextWx, and sets the current gc copy """ DEBUG_MSG('new_gc()', 2, self) self.gc = GraphicsContextWx(self.bitmap, self) self.gc.select() self.gc.unselect() return self.gc
python
{ "resource": "" }
q230960
RendererWx.get_wx_font
train
def get_wx_font(self, s, prop): """ Return a wx font. Cache instances in a font dictionary for efficiency """ DEBUG_MSG("get_wx_font()", 1, self) key = hash(prop) fontprop = prop fontname = fontprop.get_name() font = self.fontd.get(key) ...
python
{ "resource": "" }
q230961
GraphicsContextWx.select
train
def select(self): """ Select the current bitmap into this wxDC instance """ if sys.platform=='win32': self.dc.SelectObject(self.bitmap) self.IsSelected = True
python
{ "resource": "" }
q230962
GraphicsContextWx.unselect
train
def unselect(self): """ Select a Null bitmasp into this wxDC instance """ if sys.platform=='win32': self.dc.SelectObject(wx.NullBitmap) self.IsSelected = False
python
{ "resource": "" }
q230963
GraphicsContextWx.set_linewidth
train
def set_linewidth(self, w): """ Set the line width. """ DEBUG_MSG("set_linewidth()", 1, self) self.select() if w>0 and w<1: w = 1 GraphicsContextBase.set_linewidth(self, w) lw = int(self.renderer.points_to_pixels(self._linewidth)) if lw==0: lw = 1 ...
python
{ "resource": "" }
q230964
GraphicsContextWx.set_linestyle
train
def set_linestyle(self, ls): """ Set the line style to be one of """ DEBUG_MSG("set_linestyle()", 1, self) self.select() GraphicsContextBase.set_linestyle(self, ls) try: self._style = GraphicsContextWx._dashd_wx[ls] except KeyError: ...
python
{ "resource": "" }
q230965
GraphicsContextWx.get_wxcolour
train
def get_wxcolour(self, color): """return a wx.Colour from RGB format""" DEBUG_MSG("get_wx_color()", 1, self) if len(color) == 3: r, g, b = color r *= 255 g *= 255 b *= 255 return wx.Colour(red=int(r), green=int(g), blue=int(b)) ...
python
{ "resource": "" }
q230966
FigureCanvasWx.Copy_to_Clipboard
train
def Copy_to_Clipboard(self, event=None): "copy bitmap of canvas to system clipboard" bmp_obj = wx.BitmapDataObject() bmp_obj.SetBitmap(self.bitmap) if not wx.TheClipboard.IsOpened(): open_success = wx.TheClipboard.Open() if open_success: wx.TheClipboa...
python
{ "resource": "" }
q230967
FigureCanvasWx.draw_idle
train
def draw_idle(self): """ Delay rendering until the GUI is idle. """ DEBUG_MSG("draw_idle()", 1, self) self._isDrawn = False # Force redraw # Create a timer for handling draw_idle requests # If there are events pending when the timer is # complete, reset t...
python
{ "resource": "" }
q230968
FigureCanvasWx.draw
train
def draw(self, drawDC=None): """ Render the figure using RendererWx instance renderer, or using a previously defined renderer if none is specified. """ DEBUG_MSG("draw()", 1, self) self.renderer = RendererWx(self.bitmap, self.figure.dpi) self.figure.draw(self.rend...
python
{ "resource": "" }
q230969
FigureCanvasWx.start_event_loop
train
def start_event_loop(self, timeout=0): """ Start an event loop. This is used to start a blocking event loop so that interactive functions, such as ginput and waitforbuttonpress, can wait for events. This should not be confused with the main GUI event loop, which is always runni...
python
{ "resource": "" }
q230970
FigureCanvasWx.stop_event_loop
train
def stop_event_loop(self, event=None): """ Stop an event loop. This is used to stop a blocking event loop so that interactive functions, such as ginput and waitforbuttonpress, can wait for events. Call signature:: stop_event_loop_default(self) """ if ha...
python
{ "resource": "" }
q230971
FigureCanvasWx._get_imagesave_wildcards
train
def _get_imagesave_wildcards(self): 'return the wildcard string for the filesave dialog' default_filetype = self.get_default_filetype() filetypes = self.get_supported_filetypes_grouped() sorted_filetypes = filetypes.items() sorted_filetypes.sort() wildcards = [] e...
python
{ "resource": "" }
q230972
FigureCanvasWx.gui_repaint
train
def gui_repaint(self, drawDC=None): """ Performs update of the displayed image on the GUI canvas, using the supplied device context. If drawDC is None, a ClientDC will be used to redraw the image. """ DEBUG_MSG("gui_repaint()", 1, self) if self.IsShownOnScreen():...
python
{ "resource": "" }
q230973
FigureCanvasWx._onPaint
train
def _onPaint(self, evt): """ Called when wxPaintEvt is generated """ DEBUG_MSG("_onPaint()", 1, self) drawDC = wx.PaintDC(self) if not self._isDrawn: self.draw(drawDC=drawDC) else: self.gui_repaint(drawDC=drawDC) evt.Skip()
python
{ "resource": "" }
q230974
FigureCanvasWx._onSize
train
def _onSize(self, evt): """ Called when wxEventSize is generated. In this application we attempt to resize to fit the window, so it is better to take the performance hit and redraw the whole window. """ DEBUG_MSG("_onSize()", 2, self) # Create a new, correctly s...
python
{ "resource": "" }
q230975
FigureCanvasWx._onIdle
train
def _onIdle(self, evt): 'a GUI idle event' evt.Skip() FigureCanvasBase.idle_event(self, guiEvent=evt)
python
{ "resource": "" }
q230976
FigureCanvasWx._onKeyDown
train
def _onKeyDown(self, evt): """Capture key press.""" key = self._get_key(evt) evt.Skip() FigureCanvasBase.key_press_event(self, key, guiEvent=evt)
python
{ "resource": "" }
q230977
FigureCanvasWx._onKeyUp
train
def _onKeyUp(self, evt): """Release key.""" key = self._get_key(evt) #print 'release key', key evt.Skip() FigureCanvasBase.key_release_event(self, key, guiEvent=evt)
python
{ "resource": "" }
q230978
FigureCanvasWx._onLeftButtonUp
train
def _onLeftButtonUp(self, evt): """End measuring on an axis.""" x = evt.GetX() y = self.figure.bbox.height - evt.GetY() #print 'release button', 1 evt.Skip() if self.HasCapture(): self.ReleaseMouse() FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=ev...
python
{ "resource": "" }
q230979
FigureCanvasWx._onMouseWheel
train
def _onMouseWheel(self, evt): """Translate mouse wheel events into matplotlib events""" # Determine mouse location x = evt.GetX() y = self.figure.bbox.height - evt.GetY() # Convert delta/rotation/rate into a floating point step size delta = evt.GetWheelDelta() r...
python
{ "resource": "" }
q230980
FigureCanvasWx._onLeave
train
def _onLeave(self, evt): """Mouse has left the window.""" evt.Skip() FigureCanvasBase.leave_notify_event(self, guiEvent = evt)
python
{ "resource": "" }
q230981
FigureManagerWx.resize
train
def resize(self, width, height): 'Set the canvas size in pixels' self.canvas.SetInitialSize(wx.Size(width, height)) self.window.GetSizer().Fit(self.window)
python
{ "resource": "" }
q230982
MenuButtonWx._onMenuButton
train
def _onMenuButton(self, evt): """Handle menu button pressed.""" x, y = self.GetPositionTuple() w, h = self.GetSizeTuple() self.PopupMenuXY(self._menu, x, y+h-4) # When menu returned, indicate selection in button evt.Skip()
python
{ "resource": "" }
q230983
MenuButtonWx._handleSelectAllAxes
train
def _handleSelectAllAxes(self, evt): """Called when the 'select all axes' menu item is selected.""" if len(self._axisId) == 0: return for i in range(len(self._axisId)): self._menu.Check(self._axisId[i], True) self._toolbar.set_active(self.getActiveAxes()) ...
python
{ "resource": "" }
q230984
MenuButtonWx._handleInvertAxesSelected
train
def _handleInvertAxesSelected(self, evt): """Called when the invert all menu item is selected""" if len(self._axisId) == 0: return for i in range(len(self._axisId)): if self._menu.IsChecked(self._axisId[i]): self._menu.Check(self._axisId[i], False) else: ...
python
{ "resource": "" }
q230985
MenuButtonWx._onMenuItemSelected
train
def _onMenuItemSelected(self, evt): """Called whenever one of the specific axis menu items is selected""" current = self._menu.IsChecked(evt.GetId()) if current: new = False else: new = True self._menu.Check(evt.GetId(), new) # Lines above would be...
python
{ "resource": "" }
q230986
MenuButtonWx.getActiveAxes
train
def getActiveAxes(self): """Return a list of the selected axes.""" active = [] for i in range(len(self._axisId)): if self._menu.IsChecked(self._axisId[i]): active.append(i) return active
python
{ "resource": "" }
q230987
MenuButtonWx.updateButtonText
train
def updateButtonText(self, lst): """Update the list of selected axes in the menu button""" axis_txt = '' for e in lst: axis_txt += '%d,' % (e+1) # remove trailing ',' and add to button string self.SetLabel("Axes: %s" % axis_txt[:-1])
python
{ "resource": "" }
q230988
NavigationToolbarWx._create_menu
train
def _create_menu(self): """ Creates the 'menu' - implemented as a button which opens a pop-up menu since wxPython does not allow a menu as a control """ DEBUG_MSG("_create_menu()", 1, self) self._menu = MenuButtonWx(self) self.AddControl(self._menu) self.A...
python
{ "resource": "" }
q230989
NavigationToolbarWx._create_controls
train
def _create_controls(self, can_kill): """ Creates the button controls, and links them to event handlers """ DEBUG_MSG("_create_controls()", 1, self) # Need the following line as Windows toolbars default to 15x16 self.SetToolBitmapSize(wx.Size(16,16)) self.AddSimp...
python
{ "resource": "" }
q230990
NavigationToolbarWx.set_active
train
def set_active(self, ind): """ ind is a list of index numbers for the axes which are to be made active """ DEBUG_MSG("set_active()", 1, self) self._ind = ind if ind != None: self._active = [ self._axes[i] for i in self._ind ] else: self._ac...
python
{ "resource": "" }
q230991
SRTMDownloader.getURIWithRedirect
train
def getURIWithRedirect(self, url): '''fetch a URL with redirect handling''' tries = 0 while tries < 5: conn = httplib.HTTPConnection(self.server) conn.request("GET", url) r1 = conn.getresponse() if r1.status in [301, 302, 303, 307]:...
python
{ "resource": "" }
q230992
RCModule.cmd_rc
train
def cmd_rc(self, args): '''handle RC value override''' if len(args) != 2: print("Usage: rc <channel|all> <pwmvalue>") return value = int(args[1]) if value > 65535 or value < -1: raise ValueError("PWM value must be a positive integer between 0 and 65535...
python
{ "resource": "" }
q230993
complete_variable
train
def complete_variable(text): '''complete a MAVLink variable or expression''' if text == '': return list(rline_mpstate.status.msgs.keys()) if text.endswith(":2"): suffix = ":2" text = text[:-2] else: suffix = '' try: if mavutil.evaluate_expression(text, rline...
python
{ "resource": "" }
q230994
complete_rule
train
def complete_rule(rule, cmd): '''complete using one rule''' global rline_mpstate rule_components = rule.split(' ') # complete the empty string (e.g "graph <TAB><TAB>") if len(cmd) == 0: return rule_expand(rule_components[0], "") # check it matches so far for i in range(len(cmd)-1)...
python
{ "resource": "" }
q230995
HorizonFrame.createPlotPanel
train
def createPlotPanel(self): '''Creates the figure and axes for the plotting panel.''' self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self,-1,self.figure) self.canvas.SetSize(wx.Size(300,300)) self.axes.axis('off') self.fi...
python
{ "resource": "" }
q230996
HorizonFrame.rescaleX
train
def rescaleX(self): '''Rescales the horizontal axes to make the lengthscales equal.''' self.ratio = self.figure.get_size_inches()[0]/float(self.figure.get_size_inches()[1]) self.axes.set_xlim(-self.ratio,self.ratio) self.axes.set_ylim(-1,1)
python
{ "resource": "" }
q230997
HorizonFrame.calcFontScaling
train
def calcFontScaling(self): '''Calculates the current font size and left position for the current window.''' self.ypx = self.figure.get_size_inches()[1]*self.figure.dpi self.xpx = self.figure.get_size_inches()[0]*self.figure.dpi self.fontSize = self.vertSize*(self.ypx/2.0) self.le...
python
{ "resource": "" }
q230998
HorizonFrame.checkReszie
train
def checkReszie(self): '''Checks if the window was resized.''' if not self.resized: oldypx = self.ypx oldxpx = self.xpx self.ypx = self.figure.get_size_inches()[1]*self.figure.dpi self.xpx = self.figure.get_size_inches()[0]*self.figure.dpi if (...
python
{ "resource": "" }
q230999
HorizonFrame.createHeadingPointer
train
def createHeadingPointer(self): '''Creates the pointer for the current heading.''' self.headingTri = patches.RegularPolygon((0.0,0.80),3,0.05,color='k',zorder=4) self.axes.add_patch(self.headingTri) self.headingText = self.axes.text(0.0,0.675,'0',color='k',size=self.fontSize,horizontalal...
python
{ "resource": "" }