I am very new a wxpython and I’m looking for a way to draw a set of rectangles that will simulate a LED bar. However, I’m not sure how to draw them into a horizontal boxsizer using wxpython. i’m also looking for a way to perhaps update them like making the rectangle a class or something to changes the color etc to simulate a rgb led bar. some help is very much appreciated.
#!/usr/bin/python
-- coding: utf-8 --
gotoclass.py
import wx
class Example(wx.Frame):
def init(self, parent, title):
super(Example, self).init(parent, title=title, size=(900, 600))
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = wx.Panel(self)
font = wx.SystemSettings_GetFont(wx.SYS_SYSTEM_FONT)
font.SetPointSize(9)
vbox = wx.BoxSizer(wx.VERTICAL)
vbox.Add((-1, 5))
hbox1 = wx.BoxSizer(wx.HORIZONTAL)
ledST = wx.StaticText(panel, label=‘LED BAR’)
ledST.SetFont(font)
hbox1.Add(ledST, flag=wx.LEFT, border=5)
joystickST = wx.StaticText(panel, label=‘JOYSTICK’)
joystickST.SetFont(font)
hbox1.Add(joystickST, flag=wx.LEFT, border=600)
vbox.Add(hbox1, flag=wx.LEFT|wx.RIGHT|wx.TOP, border=0)
vbox.Add((-1, 10))
hbox2 = wx.BoxSizer(wx.HORIZONTAL)
dc = wx.PaintDC(self)
dc.SetBrush(wx.Brush(’#075100’))
dc.DrawRectangle(10, 4, 30, 5)
#NOT SURE WHAT TO DO HERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
vbox.Add((-1, 15))
hbox5 = wx.BoxSizer(wx.HORIZONTAL)
btn1 = wx.Button(panel, label=‘Ok’, size=(70, 30))
hbox5.Add(btn1)
btn2 = wx.Button(panel, label=‘Close’, size=(70, 30))
hbox5.Add(btn2, flag=wx.LEFT|wx.BOTTOM, border=5)
vbox.Add(hbox5, flag=wx.ALIGN_RIGHT|wx.RIGHT, border=10)
panel.SetSizer(vbox)
if name == ‘main’:
app = wx.App()
Example(None, title=‘Go To Class’)
app.MainLoop()
``
GUI.py (1.58 KB)