def create_main_panel(self): import platform if platform.system() == 'Darwin': from MAVProxy.modules.lib.MacOS import backend_wxagg FigCanvas = backend_wxagg.FigureCanvasWxAgg else: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigCanvas self.panel = wx.Panel(self) self.init_plot() self.canvas = FigCanvas(self.panel, -1, self.fig) self.close_button = wx.Button(self.panel, -1, "Close") self.Bind(wx.EVT_BUTTON, self.on_close_button, self.close_button) self.pause_button = wx.Button(self.panel, -1, "Pause") self.Bind(wx.EVT_BUTTON, self.on_pause_button, self.pause_button) self.Bind(wx.EVT_UPDATE_UI, self.on_update_pause_button, self.pause_button) self.hbox1 = wx.BoxSizer(wx.HORIZONTAL) self.hbox1.Add(self.close_button, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.hbox1.AddSpacer(1) self.hbox1.Add(self.pause_button, border=5, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW) self.vbox.Add(self.hbox1, 0, flag=wx.ALIGN_LEFT | wx.TOP) self.panel.SetSizer(self.vbox) self.vbox.Fit(self)
def __init__(self, state, title): self.state = state wx.Frame.__init__(self, None, title=title, size=(350, 400), style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER) #use tabs for the individual checklists self.createLists() self.panel = wx.Panel(self) self.nb = wx.Choicebook(self.panel, wx.ID_ANY) #create the tabs self.createWidgets() #assign events to the buttons on the tabs self.createActions() #add in the pipe from MAVProxy self.timer = wx.Timer(self) #self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.Bind(wx.EVT_TIMER, lambda evt, notebook=self.nb: self.on_timer(evt, notebook), self.timer) self.timer.Start(100) # finally, put the notebook in a sizer for the panel to manage # the layout sizer = wx.BoxSizer() sizer.Add(self.nb, 1, wx.EXPAND) self.panel.SetSizer(sizer) self.Show(True) self.pending = []
def __init__(self, title, graphdef, callback): wx.Dialog.__init__(self, None, -1, title, size=(900, 400)) self.callback = callback self.graphdef = graphdef self.panel = wx.Panel(self, -1) vbox = wx.BoxSizer(wx.VERTICAL) # name entry hbox_name = wx.BoxSizer(wx.HORIZONTAL) st_name = wx.StaticText(self.panel, -1, 'Name: ') self.tc_name = wx.TextCtrl(self.panel, -1, size=(400, -1)) self.tc_name.Value = self.graphdef.name hbox_name.Add(st_name, 0, wx.LEFT, 10) hbox_name.Add(self.tc_name, 0, wx.LEFT, 35) vbox.Add(hbox_name, 0, wx.TOP, 10) # expression entry st = wx.StaticText(self.panel, -1, 'Expressions: ') vbox.Add(st, 0, wx.LEFT, 10) hbox_expressions = wx.BoxSizer(wx.HORIZONTAL) self.tc_expressions = wx.TextCtrl(self.panel, -1, style=wx.TE_MULTILINE | wx.HSCROLL, size=(800, 80)) elist = [] for e in self.graphdef.expressions: e = ' '.join(e.split()) elist.append(e) self.tc_expressions.Value = '\n'.join(elist) vbox.Add(self.tc_expressions, 0, wx.LEFT, 15) # description entry st = wx.StaticText(self.panel, -1, 'Description: ') vbox.Add(st, 0, wx.LEFT, 10) self.tc_description = wx.TextCtrl(self.panel, -1, style=wx.TE_MULTILINE) vbox.Add(self.tc_description, 1, wx.EXPAND | wx.TOP | wx.RIGHT | wx.LEFT, 15) self.tc_description.Value = self.graphdef.description # buttons button_save = wx.Button(self.panel, 1, 'Save') button_cancel = wx.Button(self.panel, 2, 'Cancel') button_test = wx.Button(self.panel, 3, 'Test') hbox_buttons = wx.BoxSizer(wx.HORIZONTAL) hbox_buttons.Add(button_save, 0, wx.LEFT, 10) hbox_buttons.Add(button_cancel, 0, wx.LEFT, 10) hbox_buttons.Add(button_test, 0, wx.LEFT, 10) vbox.Add(hbox_buttons, 0, wx.TOP, 10) self.Bind(wx.EVT_BUTTON, self.OnSave, id=1) self.Bind(wx.EVT_BUTTON, self.OnCancel, id=2) self.Bind(wx.EVT_BUTTON, self.OnTest, id=3) self.panel.SetSizer(vbox) self.Centre()
def legend_panel(*k, **kw): if MagcalPanel._legend_panel: return MagcalPanel._legend_panel p = MagcalPanel._legend_panel = wx.Panel(*k, **kw) sizer = wx.BoxSizer(wx.HORIZONTAL) p.SetSizer(sizer) marker = wx.Panel(p, wx.ID_ANY, size=(10, 10)) marker.SetBackgroundColour(MagcalPanel._empty_color) sizer.Add(marker, flag=wx.ALIGN_CENTER) text = wx.StaticText(p, wx.ID_ANY) text.SetLabel('Sections not hit') sizer.Add(text, border=4, flag=wx.ALIGN_CENTER | wx.LEFT) marker = wx.Panel(p, wx.ID_ANY, size=(10, 10)) marker.SetBackgroundColour(MagcalPanel._filled_color) sizer.Add(marker, border=10, flag=wx.ALIGN_CENTER | wx.LEFT) text = wx.StaticText(p, wx.ID_ANY) text.SetLabel('Sections hit') sizer.Add(text, border=4, flag=wx.ALIGN_CENTER | wx.LEFT) return p
def __init__(self, state, title): self.state = state wx.Frame.__init__(self, None, title=title, size=(800, 300)) self.panel = wx.Panel(self) self.panel.SetBackgroundColour('white') state.frame = self # values for the status bar self.values = {} self.menu = None self.menu_callback = None self.last_layout_send = time.time() #array of the names of my MPButtons self.buttonnames = {} #array of the MPButtons self.buttons = [] self.control = wx.TextCtrl(self.panel, size=(800, 150), style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_AUTO_URL) self.vbox = wx.BoxSizer(wx.VERTICAL) # start with one status row self.status = [wx.BoxSizer(wx.HORIZONTAL)] self.vbox.Add(self.status[0], 0, flag=wx.ALIGN_LEFT | wx.TOP) # place to hold up to 9 buttons self.buttongridsizer = wx.GridSizer(3, 3, 0) # for i in range(1, 2): # btn = "Btn" + str(i) # self.buttongridsizer.Add(wx.Button(self.panel, label=btn), 0, wx.EXPAND) self.vbox.Add(self.buttongridsizer, 1, flag=wx.GROW) self.vbox.Add(self.control, 0, flag=wx.LEFT | wx.BOTTOM | wx.GROW) self.panel.SetSizer(self.vbox) self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(100) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_TEXT_URL, self.on_text_url) self.Show(True) self.pending = []
def LoaderProgress(self, parent): panel = wx.Panel(parent) panel.SetBackgroundColour(parent.GetBackgroundColour()) font = panel.GetFont() font.MakeItalic() panel.SetFont(font) self.load_progress = wx.Gauge(panel, size=(-1, 10)) self.load_progress_last_time = time.time() self.load_text = wx.StaticText(panel) sizer = wx.BoxSizer(wx.VERTICAL) panel.SetSizer(sizer) sizer.Add(self.load_progress, border=10, flag=wx.EXPAND | wx.LEFT | wx.RIGHT) sizer.Add(self.load_text, border=10, flag=wx.LEFT | wx.RIGHT) return panel
def __init__(self, state, title): self.state = state wx.Frame.__init__(self, None, title=title, size=(800, 300)) # different icons for MAVExplorer and MAVProxy try: if title == "MAVExplorer": self.SetIcon(icon.SimpleIcon("EXPLORER").get_ico()) else: self.SetIcon(icon.SimpleIcon("CONSOLE").get_ico()) except Exception: pass self.panel = wx.Panel(self) self.panel.SetBackgroundColour('white') state.frame = self # values for the status bar self.values = {} self.menu = None self.menu_callback = None self.last_layout_send = time.time() self.control = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_AUTO_URL) self.vbox = wx.BoxSizer(wx.VERTICAL) # start with one status row self.status = [wx.BoxSizer(wx.HORIZONTAL)] self.vbox.Add(self.status[0], 0, flag=wx.ALIGN_LEFT | wx.TOP) self.vbox.Add(self.control, 1, flag=wx.LEFT | wx.BOTTOM | wx.GROW) self.panel.SetSizer(self.vbox) self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(100) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_TEXT_URL, self.on_text_url) self.Show(True) self.pending = []
def __init__(self, state, title): self.state = state wx.Frame.__init__(self, None, title=title, size=(800, 300)) self.panel = wx.Panel(self) self.panel.SetBackgroundColour('white') state.frame = self # values for the status bar self.values = {} # values for restserver # self.values_rest = {} # text for restserver # self.text_rest = TextList() self.menu = None self.menu_callback = None self.last_layout_send = time.time() self.control = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_AUTO_URL) self.vbox = wx.BoxSizer(wx.VERTICAL) # start with one status row self.status = [wx.BoxSizer(wx.HORIZONTAL)] self.vbox.Add(self.status[0], 0, flag=wx.ALIGN_LEFT | wx.TOP) self.vbox.Add(self.control, 1, flag=wx.LEFT | wx.BOTTOM | wx.GROW) self.panel.SetSizer(self.vbox) self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(100) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_TEXT_URL, self.on_text_url) self.Show(True) # comment out to hide console self.pending = []
def __init__(self, tab_names, title='Title', size=wx.DefaultSize): wx.Dialog.__init__(self, None, -1, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) self.tab_names = tab_names self.notebook = wx.Notebook(self, -1, size=size) self.panels = {} self.sizers = {} for t in tab_names: self.panels[t] = wx.Panel(self.notebook) self.notebook.AddPage(self.panels[t], t) self.sizers[t] = wx.BoxSizer(wx.VERTICAL) self.panels[t].SetSizer(self.sizers[t]) self.dialog_sizer = wx.BoxSizer(wx.VERTICAL) self.dialog_sizer.Add(self.notebook, 1, wx.EXPAND | wx.ALL, 5) self.controls = {} self.browse_option_map = {} self.control_map = {} self.setting_map = {} button_box = wx.BoxSizer(wx.HORIZONTAL) self.button_apply = wx.Button(self, -1, "Apply") self.button_cancel = wx.Button(self, -1, "Cancel") self.button_save = wx.Button(self, -1, "Save") self.button_load = wx.Button(self, -1, "Load") button_box.Add(self.button_cancel, 0, wx.ALL) button_box.Add(self.button_apply, 0, wx.ALL) button_box.Add(self.button_save, 0, wx.ALL) button_box.Add(self.button_load, 0, wx.ALL) self.dialog_sizer.Add(button_box, 0, wx.GROW | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 5) wx.EVT_BUTTON(self, self.button_cancel.GetId(), self.on_cancel) wx.EVT_BUTTON(self, self.button_apply.GetId(), self.on_apply) wx.EVT_BUTTON(self, self.button_save.GetId(), self.on_save) wx.EVT_BUTTON(self, self.button_load.GetId(), self.on_load) self.Centre()
def init_ui(self): '''Initalise the UI elements''' if not hasattr(self.mlog, 'formats'): print("Must be DF log") return self.panel = wx.Panel(self) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.AddStretchSpacer() self.panel.SetSizer(self.vbox) self.idmap = {} self.values = {} self.controls = {} self.callbacks = {} self.row = None msg_names = self.mlog.name_to_id.keys() mag_format = self.mlog.formats[self.mlog.name_to_id['MAG']] if 'I' in mag_format.columns: mag_choices = ['MAG[0]', 'MAG[1]', 'MAG[2]'] else: mag_choices = ['MAG', 'MAG2', 'MAG3'] att_choices = ['ATT'] if self.have_msg('NKF1'): att_choices.append('NKF1') if self.have_msg('XKF1'): att_choices.append('XKF1') # first row, Mag and attitude source self.StartRow('Source Selection') self.AddCombo('Magnetometer', mag_choices) self.AddCombo('Attitude', att_choices) self.StartRow('Position') self.AddSpinFloat("Lattitude", -90, 90, 0.000001, 0, digits=8) self.AddSpinFloat("Longitude", -180, 180, 0.000001, 0, digits=8) self.StartRow() self.AddSpinInteger("Reduce", 1, 20, 1) self.StartRow('Offset Estimation') self.AddCheckBox("Offsets", default=True) self.StartRow() self.AddSpinInteger("OffsetMax", 500, 3000, 1500) self.StartRow('Scale Factor Estimation') self.AddSpinFloat("ScaleMin", 0.5, 2.0, 0.01, 1.0) self.AddSpinFloat("ScaleMax", 0.5, 2.0, 0.01, 1.0) self.StartRow('Elliptical Estimation') self.AddCheckBox("Elliptical") self.StartRow() self.AddSpinFloat("DiagonalMin", 0.8, 1.0, 0.01, 0.8) self.AddSpinFloat("DiagonalMax", 1.0, 1.2, 0.01, 1.2) self.StartRow() self.AddSpinFloat("OffDiagMin", -0.2, 0.0, 0.01, -0.2) self.AddSpinFloat("OffDiagMax", 0, 0.2, 0.01, 0.2) self.StartRow('Motor Interference Estimation') self.AddCheckBox("CMOT") self.AddCheckBox("CMOT NoChange") self.StartRow() self.AddSpinInteger("BatteryNum", 1, 8, 1) self.AddSpinFloat("CMOT Max", 1.0, 10, 0.1, 10) self.StartRow("Processing") self.AddButton('Run', callback=self.run) self.AddButton('Close', callback=self.close) self.EndRow() self.Center()
def createWidgets(self): #create the panels for the tabs PanelAssembly = wx.Panel(self.nb) boxAssembly = wx.BoxSizer(wx.VERTICAL) PanelAssembly.SetAutoLayout(True) PanelAssembly.SetSizer(boxAssembly) PanelAssembly.Layout() PanelEngine = wx.Panel(self.nb) boxEngine = wx.BoxSizer(wx.VERTICAL) PanelEngine.SetAutoLayout(True) PanelEngine.SetSizer(boxEngine) PanelEngine.Layout() PanelTakeoff = wx.Panel(self.nb) boxTakeoff = wx.BoxSizer(wx.VERTICAL) PanelTakeoff.SetAutoLayout(True) PanelTakeoff.SetSizer(boxTakeoff) PanelTakeoff.Layout() PanelCruise = wx.Panel(self.nb) boxCruise = wx.BoxSizer(wx.VERTICAL) PanelCruise.SetAutoLayout(True) PanelCruise.SetSizer(boxCruise) PanelCruise.Layout() PanelDrop = wx.Panel(self.nb) boxDrop = wx.BoxSizer(wx.VERTICAL) PanelDrop.SetAutoLayout(True) PanelDrop.SetSizer(boxDrop) PanelDrop.Layout() PanelLanding = wx.Panel(self.nb) boxLanding = wx.BoxSizer(wx.VERTICAL) PanelLanding.SetAutoLayout(True) PanelLanding.SetSizer(boxLanding) PanelLanding.Layout() PanelShutdown = wx.Panel(self.nb) boxShutdown = wx.BoxSizer(wx.VERTICAL) PanelShutdown.SetAutoLayout(True) PanelShutdown.SetSizer(boxShutdown) PanelShutdown.Layout() #add the data to the individual tabs '''before assembly checklist''' for key in self.beforeAssemblyList: if self.beforeAssemblyList[key] == 0: disCheckBox = wx.CheckBox(PanelAssembly, wx.ID_ANY, key) disCheckBox.Enable(False) boxAssembly.Add(disCheckBox) if self.beforeAssemblyList[key] == 2: boxAssembly.Add(wx.CheckBox(PanelAssembly, wx.ID_ANY, key)) self.AssemblyButton = wx.Button(PanelAssembly, wx.ID_ANY, "Close final hatches") boxAssembly.Add(self.AssemblyButton) '''before Engine Start checklist''' for key in self.beforeEngineList: if self.beforeEngineList[key] == 0: disCheckBox = wx.CheckBox(PanelEngine, wx.ID_ANY, key) disCheckBox.Enable(False) boxEngine.Add(disCheckBox) if self.beforeEngineList[key] == 2: boxEngine.Add(wx.CheckBox(PanelEngine, wx.ID_ANY, key)) self.EngineButton = wx.Button(PanelEngine, wx.ID_ANY, "Ready for Engine start") boxEngine.Add(self.EngineButton) '''before takeoff checklist''' for key in self.beforeTakeoffList: if self.beforeTakeoffList[key] == 0: disCheckBox = wx.CheckBox(PanelTakeoff, wx.ID_ANY, key) disCheckBox.Enable(False) boxTakeoff.Add(disCheckBox) if self.beforeTakeoffList[key] == 2: boxTakeoff.Add(wx.CheckBox(PanelTakeoff, wx.ID_ANY, key)) self.TakeoffButton = wx.Button(PanelTakeoff, wx.ID_ANY, "Ready for Takeoff") boxTakeoff.Add(self.TakeoffButton) '''before cruise/AUTO checklist''' for key in self.beforeCruiseList: if self.beforeCruiseList[key] == 0: disCheckBox = wx.CheckBox(PanelCruise, wx.ID_ANY, key) disCheckBox.Enable(False) boxCruise.Add(disCheckBox) if self.beforeCruiseList[key] == 2: boxCruise.Add(wx.CheckBox(PanelCruise, wx.ID_ANY, key)) self.CruiseButton = wx.Button(PanelCruise, wx.ID_ANY, "Ready for Cruise/AUTO") boxCruise.Add(self.CruiseButton) '''before bottle drop checklist''' for key in self.bottleDropList: if self.bottleDropList[key] == 0: disCheckBox = wx.CheckBox(PanelDrop, wx.ID_ANY, key) disCheckBox.Enable(False) boxDrop.Add(disCheckBox) if self.bottleDropList[key] == 2: boxDrop.Add(wx.CheckBox(PanelDrop, wx.ID_ANY, key)) self.DropButton = wx.Button(PanelDrop, wx.ID_ANY, "Ready for Bottle Drop") boxDrop.Add(self.DropButton) '''before landing checklist''' for key in self.beforeLandingList: if self.beforeLandingList[key] == 0: disCheckBox = wx.CheckBox(PanelLanding, wx.ID_ANY, key) disCheckBox.Enable(False) boxLanding.Add(disCheckBox) if self.beforeLandingList[key] == 2: boxLanding.Add(wx.CheckBox(PanelLanding, wx.ID_ANY, key)) self.LandingButton = wx.Button(PanelLanding, wx.ID_ANY, "Ready for Landing") boxLanding.Add(self.LandingButton) '''before shutdown checklist''' for key in self.beforeShutdownList: if self.beforeShutdownList[key] == 0: disCheckBox = wx.CheckBox(PanelShutdown, wx.ID_ANY, key) disCheckBox.Enable(False) boxShutdown.Add(disCheckBox) if self.beforeShutdownList[key] == 2: boxShutdown.Add(wx.CheckBox(PanelShutdown, wx.ID_ANY, key)) self.ShutdownButton = wx.Button(PanelShutdown, wx.ID_ANY, "Ready for Shutdown") boxShutdown.Add(self.ShutdownButton) #and add in the tabs self.nb.AddPage(PanelAssembly, "1. During Assembly") self.nb.AddPage(PanelEngine, "2. Before Engine Start") self.nb.AddPage(PanelTakeoff, "3. Before Takeoff") self.nb.AddPage(PanelCruise, "4. Before Cruise/AUTO") self.nb.AddPage(PanelDrop, "5. Before Bottle Drop") self.nb.AddPage(PanelLanding, "6. Before Landing") self.nb.AddPage(PanelShutdown, "7. Before Shutdown")
def initUI(self): # Create Event Timer and Bindings self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self.timer.Start(100) self.Bind(wx.EVT_IDLE, self.on_idle) self.Bind(wx.EVT_CHAR_HOOK, self.on_KeyPress) # Create Panel self.panel = wx.Panel(self) self.vertSize = 0.09 self.resized = False # Create Matplotlib Panel self.createPlotPanel() # Fix Axes - vertical is of length 2, horizontal keeps the same lengthscale self.rescaleX() self.calcFontScaling() # Create Horizon Polygons self.createHorizonPolygons() # Center Pointer Marker self.thick = 0.015 self.createCenterPointMarker() # Pitch Markers self.dist10deg = 0.2 # Graph distance per 10 deg self.createPitchMarkers() # Add Roll, Pitch, Yaw Text self.createRPYText() # Add Airspeed, Altitude, Climb Rate Text self.createAARText() # Create Heading Pointer self.createHeadingPointer() # Create North Pointer self.createNorthPointer() # Create Battery Bar self.batWidth = 0.1 self.batHeight = 0.2 self.rOffset = 0.35 self.createBatteryBar() # Create Mode & State Text self.createStateText() # Create Waypoint Text self.createWPText() # Create Waypoint Pointer self.createWPPointer() # Create Altitude History Plot self.createAltHistoryPlot() # Show Frame self.Show(True) self.pending = []