I made a wxPython listbox containing available serial com ports.
My example is this.
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent = None, title= "ListBox Test", size = (300,200))
self.panel = wx.Panel(self)
self.listBox1 = wx.ListBox(self.panel, -1, name='listBox1', pos =(50, 20), size= (100, 20), choices = ["Com 1", "Com 2", "Com 3", "Com 4"])
if __name__ == "__main__":
app = wx.App()
frame = MainFrame()
frame.Show()
app.MainLoop()
I want to show a whole com port list to select a com port when I bring my mouse cursor on the listbox.
Could anyone show me how?
I'd suggest a ComboBox
or a Choice
import wx
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent = None, title= "ListBox Test", size = (600,200))
self.panel = wx.Panel(self)
self.listBox1 = wx.ComboBox(self.panel, -1, pos =(50, 20), size= (100, 30), choices = ["Com 1", "Com 2", "Com 3", "Com 4"])
self.listBox1.SetSelection(0)
self.choice1 = wx.Choice(self.panel, -1, pos =(250, 20), size= (100, 30), choices = ["Com 1", "Com 2", "Com 3", "Com 4"])
self.choice1.SetSelection(0)
if __name__ == "__main__":
app = wx.App()
frame = MainFrame()
frame.Show()
app.MainLoop()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.