def __init__(self, parent, device):
        self.device = device
        ports = get_serial_ports()
        ports.append(device.resource)
        self.ports = list(set(ports))

        wx.Dialog.__init__(self, parent=parent, title='Serial port settings')

        textPort = wx.StaticText(self, label='Port')
        self.comboPort = wx.ComboBox(self,
                                     choices=self.ports,
                                     style=wx.TE_PROCESS_ENTER)
        self.comboPort.SetSelection(self.ports.index(device.resource))

        textBaud = wx.StaticText(self, label='Baud rate')
        self.choiceBaud = wx.Choice(
            self, choices=[str(baud) for baud in device.get_bauds()])
        self.choiceBaud.SetSelection(device.get_bauds().index(device.baud))
        textByte = wx.StaticText(self, label='Byte size')
        self.choiceBytes = wx.Choice(
            self, choices=[str(byte) for byte in DeviceGPS.BYTES])
        self.choiceBytes.SetSelection(DeviceGPS.BYTES.index(device.bytes))
        textParity = wx.StaticText(self, label='Parity')
        self.choiceParity = wx.Choice(self, choices=DeviceGPS.PARITIES)
        self.choiceParity.SetSelection(DeviceGPS.PARITIES.index(device.parity))
        textStop = wx.StaticText(self, label='Stop bits')
        self.choiceStops = wx.Choice(
            self, choices=[str(stop) for stop in DeviceGPS.STOPS])
        self.choiceStops.SetSelection(DeviceGPS.STOPS.index(device.stops))
        textSoft = wx.StaticText(self, label='Software flow control')
        self.checkSoft = wx.CheckBox(self)
        self.checkSoft.SetValue(device.soft)

        buttonOk = wx.Button(self, wx.ID_OK)
        buttonCancel = wx.Button(self, wx.ID_CANCEL)
        sizerButtons = wx.StdDialogButtonSizer()
        sizerButtons.AddButton(buttonOk)
        sizerButtons.AddButton(buttonCancel)
        sizerButtons.Realize()
        self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk)

        grid = wx.GridBagSizer(10, 10)
        grid.Add(textPort, pos=(0, 0), flag=wx.ALL)
        grid.Add(self.comboPort, pos=(0, 1), flag=wx.ALL)
        grid.Add(textBaud, pos=(1, 0), flag=wx.ALL)
        grid.Add(self.choiceBaud, pos=(1, 1), flag=wx.ALL)
        grid.Add(textByte, pos=(2, 0), flag=wx.ALL)
        grid.Add(self.choiceBytes, pos=(2, 1), flag=wx.ALL)
        grid.Add(textParity, pos=(3, 0), flag=wx.ALL)
        grid.Add(self.choiceParity, pos=(3, 1), flag=wx.ALL)
        grid.Add(textStop, pos=(4, 0), flag=wx.ALL)
        grid.Add(self.choiceStops, pos=(4, 1), flag=wx.ALL)
        grid.Add(textSoft, pos=(5, 0), flag=wx.ALL)
        grid.Add(self.checkSoft, pos=(5, 1), flag=wx.ALL)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(grid, flag=wx.ALL, border=10)
        box.Add(sizerButtons, flag=wx.ALL | wx.ALIGN_RIGHT, border=10)

        self.SetSizerAndFit(box)
    def __init__(self, parent, device):
        self.device = device
        self.ports = get_serial_ports()

        wx.Dialog.__init__(self, parent=parent, title='Serial port settings')

        textPort = wx.StaticText(self, label='Port')
        self.choicePort = wx.Choice(self, choices=self.ports)
        sel = 0
        if device.resource in self.ports:
            sel = self.ports.index(device.resource)
        self.choicePort.SetSelection(sel)

        textBaud = wx.StaticText(self, label='Baud rate')
        self.choiceBaud = wx.Choice(self,
                                    choices=[str(baud) for baud in device.get_bauds()])
        self.choiceBaud.SetSelection(device.get_bauds().index(device.baud))
        textByte = wx.StaticText(self, label='Byte size')
        self.choiceBytes = wx.Choice(self,
                                     choices=[str(byte) for byte in DeviceGPS.BYTES])
        self.choiceBytes.SetSelection(DeviceGPS.BYTES.index(device.bytes))
        textParity = wx.StaticText(self, label='Parity')
        self.choiceParity = wx.Choice(self, choices=DeviceGPS.PARITIES)
        self.choiceParity.SetSelection(DeviceGPS.PARITIES.index(device.parity))
        textStop = wx.StaticText(self, label='Stop bits')
        self.choiceStops = wx.Choice(self,
                                     choices=[str(stop) for stop in DeviceGPS.STOPS])
        self.choiceStops.SetSelection(DeviceGPS.STOPS.index(device.stops))
        textSoft = wx.StaticText(self, label='Software flow control')
        self.checkSoft = wx.CheckBox(self)
        self.checkSoft.SetValue(device.soft)

        buttonOk = wx.Button(self, wx.ID_OK)
        buttonCancel = wx.Button(self, wx.ID_CANCEL)
        sizerButtons = wx.StdDialogButtonSizer()
        sizerButtons.AddButton(buttonOk)
        sizerButtons.AddButton(buttonCancel)
        sizerButtons.Realize()
        self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk)

        grid = wx.GridBagSizer(10, 10)
        grid.Add(textPort, pos=(0, 0), flag=wx.ALL)
        grid.Add(self.choicePort, pos=(0, 1), flag=wx.ALL)
        grid.Add(textBaud, pos=(1, 0), flag=wx.ALL)
        grid.Add(self.choiceBaud, pos=(1, 1), flag=wx.ALL)
        grid.Add(textByte, pos=(2, 0), flag=wx.ALL)
        grid.Add(self.choiceBytes, pos=(2, 1), flag=wx.ALL)
        grid.Add(textParity, pos=(3, 0), flag=wx.ALL)
        grid.Add(self.choiceParity, pos=(3, 1), flag=wx.ALL)
        grid.Add(textStop, pos=(4, 0), flag=wx.ALL)
        grid.Add(self.choiceStops, pos=(4, 1), flag=wx.ALL)
        grid.Add(textSoft, pos=(5, 0), flag=wx.ALL)
        grid.Add(self.checkSoft, pos=(5, 1), flag=wx.ALL)

        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(grid, flag=wx.ALL, border=10)
        box.Add(sizerButtons, flag=wx.ALL | wx.ALIGN_RIGHT, border=10)

        self.SetSizerAndFit(box)
 def __on_type(self, event, device):
     device.type = DeviceGPS.TYPE.index(event.GetString())
     if device.type == DeviceGPS.NMEA_SERIAL:
         device.resource = get_serial_ports()[0]
     elif device.type == DeviceGPS.NMEA_TCP:
         device.resource = "localhost:10110"
     else:
         device.resource = "localhost:2947"
Beispiel #4
0
 def __on_type(self, event, device):
     device.type = DeviceGPS.TYPE.index(event.GetString())
     if device.type == DeviceGPS.NMEA_SERIAL:
         device.resource = get_serial_ports()[0]
     elif device.type == DeviceGPS.NMEA_TCP:
         device.resource = 'localhost:10110'
     else:
         device.resource = 'localhost:2947'