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, *args, **kwargs): # customise the style kwargs.setdefault('style', wx.TE_READONLY) # initialise super class super(InstrumentDisplay, self).__init__(*args, **kwargs) # set the background colour (also for text controls) # self.SetBackgroundColour(wx.WHITE) # text controls self._label_text = wx.TextCtrl(self, style=wx.BORDER_NONE) self._label_text.SetFont( wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self._label_text.SetBackgroundColour(self.GetBackgroundColour()) self._label_text.ChangeValue("---") self._value_text = wx.TextCtrl(self, style=wx.BORDER_NONE | wx.TE_CENTRE) self._value_text.SetFont( wx.Font(30, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self._value_text.SetBackgroundColour(self.GetBackgroundColour()) self._value_text.ChangeValue("-.-") self._value_text.SetMinSize((60, 40)) self._unit_text = wx.TextCtrl(self, style=wx.BORDER_NONE | wx.TE_RIGHT) self._unit_text.SetFont( wx.Font(12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL)) self._unit_text.SetBackgroundColour(self.GetBackgroundColour()) self._unit_text.ChangeValue("--") # value text needs a nested sizer to centre vertically self._value_sizer = wx.BoxSizer(wx.HORIZONTAL) self._value_sizer.Add( self._value_text, wx.SizerFlags(1).Align(wx.ALIGN_CENTRE_VERTICAL).Border(wx.ALL, 0)) # top level sizers self._top_sizer = wx.BoxSizer(wx.VERTICAL) self._top_sizer.Add( self._label_text, wx.SizerFlags(0).Align(wx.ALIGN_TOP | wx.ALIGN_LEFT).Border( wx.ALL, 2)) self._top_sizer.Add(self._value_sizer, wx.SizerFlags(1).Expand().Border(wx.ALL, 1)) self._top_sizer.Add( self._unit_text, wx.SizerFlags(0).Align(wx.ALIGN_RIGHT).Border(wx.ALL, 2)) # layout sizers self._top_sizer.SetSizeHints(self) self.SetSizer(self._top_sizer) self.SetAutoLayout(True)
def add_text(self, setting, width=300, height=100, multiline=False): '''add a text input line''' tab = self.panel(setting.tab) if multiline: ctrl = wx.TextCtrl(tab, -1, "", size=(width, height), style=wx.TE_MULTILINE | wx.TE_PROCESS_ENTER) else: ctrl = wx.TextCtrl(tab, -1, "", size=(width, -1)) self._add_input(setting, ctrl)
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 __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, state, parent, sysid, compid, vehtype, isLeader, listFollowers, takeoffalt): wx.Panel.__init__(self, parent) self.state = state self.sysid = sysid self.compid = compid self.listFollowers = listFollowers self.isLeader = isLeader self.vehtype = vehtype self.takeoffalt = takeoffalt self.inLinkLoss = False # XYZ offsets. Filled are we get params self.offsetValues = [None, None, None] self.sizer = wx.BoxSizer(wx.VERTICAL) # Status boxes if self.isLeader: self.title = wx.StaticText(self, label="Leader {0}:{1} {2}".format( sysid, compid, get_vehicle_name(vehtype))) self.offsets = wx.StaticText(self, label="Offset: N/A") else: self.title = wx.StaticText(self, label="Veh {0}:{1} {2}".format( sysid, compid, get_vehicle_name(vehtype))) self.offsets = wx.StaticText(self, label="Offset: xxxxxx") self.armmode = wx.StaticText(self, label="armed/mode N/A ") self.thrAlt = wx.StaticText( self, label="Alt: {0}m Thr: {1}%".format(0, 0)) self.altRel = wx.StaticText(self, label="Rel Alt: {0}m".format(0)) self.battery = wx.StaticText(self, label="Battery: {0}V".format(0)) self.status = wx.StaticText(self, label="Status: N/A") self.prearm = wx.StaticText(self, label="Prearm: N/A") self.statusText = wx.TextCtrl( self, style=wx.TE_READONLY | wx.TE_MULTILINE, size=wx.Size(140, 100)) # Command buttons self.doArm = wx.Button(self, label="XXX", size=wx.Size(100, 50)) self.Bind(wx.EVT_BUTTON, self.arm, self.doArm) if self.isLeader: self.armSizer = wx.BoxSizer(wx.HORIZONTAL) self.doArmAll = wx.Button(self, label="ALL", size=wx.Size(70, 50)) self.Bind(wx.EVT_BUTTON, self.armAll, self.doArmAll) self.doGuided = wx.Button( self, label="Mode GUIDED", size=wx.Size(100, 50)) self.Bind(wx.EVT_BUTTON, self.guided, self.doGuided) if self.isLeader: self.guidedSizer = wx.BoxSizer(wx.HORIZONTAL) self.doGuidedAll = wx.Button( self, label="ALL", size=wx.Size(70, 50)) self.Bind(wx.EVT_BUTTON, self.guidedAll, self.doGuidedAll) if vehtype != mavutil.mavlink.MAV_TYPE_GROUND_ROVER: self.doGuidedTakeoff = wx.Button( self, label="GUIDED T/O {0}m".format(self.takeoffalt), size=wx.Size(130, 50)) self.Bind(wx.EVT_BUTTON, self.guidedTakeoff, self.doGuidedTakeoff) if self.isLeader: self.takeoffSizer = wx.BoxSizer(wx.HORIZONTAL) self.doGuidedTakeoffAll = wx.Button( self, label="ALL".format(self.takeoffalt), size=wx.Size(70, 50)) self.Bind(wx.EVT_BUTTON, self.guidedTakeoffAll, self.doGuidedTakeoffAll) self.doRTL = wx.Button(self, label="Mode RTL", size=wx.Size(100, 50)) self.Bind(wx.EVT_BUTTON, self.rtl, self.doRTL) if self.isLeader: self.rtlSizer = wx.BoxSizer(wx.HORIZONTAL) self.doRTLAll = wx.Button(self, label="ALL", size=wx.Size(70, 50)) self.Bind(wx.EVT_BUTTON, self.rtlAll, self.doRTLAll) self.doKill = wx.Button(self, label="KILL", size=wx.Size(100, 50)) self.killTimer = None self.Bind(wx.EVT_BUTTON, self.kill, self.doKill) if self.isLeader: self.killSizer = wx.BoxSizer(wx.HORIZONTAL) self.doKillAll = wx.Button(self, label="ALL", size=wx.Size(70, 50)) self.killAllTimer = None self.Bind(wx.EVT_BUTTON, self.killall, self.doKillAll) if self.isLeader: self.doFollowAll = wx.Button( self, label="All Follow Leader", size=wx.Size(130, 50)) self.Bind(wx.EVT_BUTTON, self.followAll, self.doFollowAll) self.doAUTO = wx.Button( self, label="Mode AUTO", size=wx.Size(100, 50)) self.Bind(wx.EVT_BUTTON, self.auto, self.doAUTO) else: self.doFollow = wx.Button( self, label="Mode Follow", size=wx.Size(100, 50)) self.Bind(wx.EVT_BUTTON, self.follow, self.doFollow) # Do the sizer layout self.doSizer() # get offset params. Needs to be after GUI elements are created time.sleep(0.05) self.state.child_pipe.send(("getoffsets", self.sysid, self.compid))