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, state, title): self.state = state wx.Frame.__init__(self, None, title=title, size=(800,300)) self.panel = wx.Panel(self) state.frame = self # values for the status bar self.values = {} self.menu = None self.menu_callback = None self.control = wx.TextCtrl(self.panel, style=wx.TE_MULTILINE | wx.TE_READONLY) 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.Show(True) self.pending = []
def create_main_panel(self): 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, 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 __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 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 = []
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")