#!/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()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.
-- Tim Roberts, ti...@probo.com Providenza & Boekelheide, Inc.
The most straightforward way to do this is to set up your UI so you have a simple blank panel in the area where you want the LED bar to be.
-- Tim Roberts, ti...@probo.com Providenza & Boekelheide, Inc.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi guys,Thanks for the help. I ended up using panels as my led bars as it allows me to have more control over the color changing instead of having to draw the rectangle.
Thanks for the help. I ended up using panels as my led bars as it allows me to have more control over the color changing instead of having to draw the rectangle.
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Yes, there is no escape from the drawing loops. with try doing a protector angle updater to simulate a servo before designing the joystick. is there any good learning materials besides those you've already shared?
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
if panval>0 and panval<=90:
pandc = 25.0/180.0*(panval+90)
elif panval<=0 and panval>=-90:
pandc = 25.0/180.0*(panval+90)
if tiltval>0 and tiltval<=90:
tiltdc = 25.0/180.0*(tiltval+89)
elif tiltval<=0 and tiltval>=-90:
tiltdc = 25.0/180.0*(tiltval+90)
if 0 < panval <= 90:
pandc = 25.0/180.0*(panval+90)
elif 0 >= panval >= -90:
pandc = 25.0/180.0*(panval+90)
if 0 < tiltval <= 90:
tiltdc = 25.0/180.0*(tiltval+89)
elif 0 >= tiltval >= -90:
tiltdc = 25.0/180.0*(tiltval+90)
if panangle<=90:
panxcoor = int(panxfix-math.cos(math.radians(panangle+90))*90)
panycoor = int(panyfix-math.sin(math.radians(panangle+90))*90)
elif panangle > 90:
panxcoor = int(panxfix+math.cos(math.radians(270-panangle))*90)
panycoor = int(panyfix-math.sin(math.radians(panangle+90))*90)
if panangle<=90:
panxcoor = int(panxfix-math.cos(math.radians(panangle+90))*90)
panycoor = int(panyfix-math.sin(math.radians(panangle+90))*90)
else:
panxcoor = int(panxfix+math.cos(math.radians(270-panangle))*90)
panycoor = int(panyfix-math.sin(math.radians(panangle+90))*90)