| | |
wxPython slider help
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
I googled and found something in a old code at:
http://aspn.activestate.com/ASPN/Mai...-users/1908355
Still not shure!
http://aspn.activestate.com/ASPN/Mai...-users/1908355
Still not shure!
I looked around in my toolbox and found some odds and ends. I combined what I found and wrote a little code snippet on the wx.Slider(), hope it helps.
http://www.daniweb.com/code/snippet403.html
http://www.daniweb.com/code/snippet403.html
May 'the Google' be with you!
I copied the snippet onto my IDE editor and it works well. Then I made three of vertically sliders and just chnaged the upper left corner x,y of each so now I have three sliders next to each other in the right side of frame or panel for RGB selection. Looks like good start of project.
What would you recommend to use for a colour area. I need two of them one for computer select colour and one for slider select colour.
What would you recommend to use for a colour area. I need two of them one for computer select colour and one for slider select colour.
•
•
Join Date: May 2005
Posts: 215
Reputation:
Solved Threads: 16
when I run the code, I get this error
My linux system has two different versions of wxPython installed, my guess is it is using the wrong version.
Python Syntax (Toggle Plain Text)
shane@mainbox ~ $ python test.py Traceback (most recent call last): File "test.py", line 58, in ? MyPanel(frame,-1) File "test.py", line 41, in __init__ self.Bind(wx.EVT_SLIDER, self.sliderUpdate) AttributeError: MyPanel instance has no attribute 'Bind'
My linux system has two different versions of wxPython installed, my guess is it is using the wrong version.
In a perfect world exceptions would not be needed.
The newest wxPython version 2.6 is still compatible with 2.4 even though the wx namespace is now preferred. If you use an editor with code completion, then you get a dropdown list of wxPython choices after you typed "wx." .
I would not recommend to keep old versions of wxPython around, mixed with newer versions!
I would not recommend to keep old versions of wxPython around, mixed with newer versions!
May 'the Google' be with you!
•
•
•
•
Originally Posted by bumsfeld
I copied the snippet onto my IDE editor and it works well. Then I made three of vertically sliders and just chnaged the upper left corner x,y of each so now I have three sliders next to each other in the right side of frame or panel for RGB selection. Looks like good start of project.
What would you recommend to use for a colour area. I need two of them one for computer select colour and one for slider select colour.
http://www.daniweb.com/code/snippet407.html
May 'the Google' be with you!
This how far I am with the program. It does flicker so and needs more work:
Anybody have idea about stopping flicker?
Python Syntax (Toggle Plain Text)
# Colour Matching Skill Tester first version # Colour the label1 with random RGB values # Colour the label2 with RGB values from sliders # Needs exposition of result closeness and possible file saving import random import wx class MyPanel(wx.Panel): """ class MyPanel creates a panel with 2 labels, 3 sliders, inherits wx.Panel """ def __init__(self, parent, id): wx.Panel.__init__(self, parent, id) self.SetBackgroundColour("white") str1 = "" self.Red1 = random.randrange(256) self.Green1 = random.randrange(256) self.Blue1 = random.randrange(256) # label1 with random RGB colour values self.label1 = wx.StaticText(self, -1, str1 , (10, 10), (120, 100)) self.label1.SetBackgroundColour((self.Red1, self.Green1, self.Blue1)) self.Red2 = 125 self.Green2 = 125 self.Blue2 = 125 # label2 with RGB colour values from sliders self.label2 = wx.StaticText(self, -1, str1 , (10, 120), (120, 100)) self.label2.SetBackgroundColour((self.Red2, self.Green2, self.Blue2)) # init value = 125, min value = 0, max value = 255 for colours self.sliderR = wx.Slider(self, -1, self.Red2, 0, 255, (140, 10), (50, 200), wx.SL_VERTICAL | wx.SL_AUTOTICKS | wx.SL_LABELS) wx.StaticText(self, -1, "Red" , (160, 205)) self.sliderG = wx.Slider(self, -1, self.Green2, 0, 255, (200, 10), (50, 200), wx.SL_VERTICAL | wx.SL_AUTOTICKS | wx.SL_LABELS) wx.StaticText(self, -1, "Green" , (220, 205)) self.sliderB = wx.Slider(self, -1, self.Blue2, 0, 255, (260, 10), (50, 200), wx.SL_VERTICAL | wx.SL_AUTOTICKS | wx.SL_LABELS) wx.StaticText(self, -1, "Blue" , (280, 205)) # result label self.label3 = wx.StaticText(self, -1, "", (160, 230)) # all three sliders ... self.Bind(wx.EVT_SCROLL, self.slideColour) # button click self.button1 = wx.Button(self, -1, "Evaluate", (10, 230)) self.button1.Bind(wx.EVT_BUTTON, self.button1Click) def slideColour(self, event): self.Red2 = self.sliderR.GetValue() self.Green2 = self.sliderG.GetValue() self.Blue2 = self.sliderB.GetValue() colour1 = wx.Colour(self.Red2, self.Green2, self.Blue2) # still flickers much! self.label2 = wx.StaticText(self, -1, "", (10, 120), (120, 100)).SetBackgroundColour(colour1) def button1Click(self,event): str1 = "Upper R=%d G=%d B=%d" % (self.Red1, self.Green1, self.Blue1) str2 = "Lower R=%d G=%d B=%d" % (self.Red2, self.Green2, self.Blue2) self.label3.SetLabel(str1 + '\n' + str2) app = wx.PySimpleApp() frame = wx.Frame(None, -1, "Colour Skill Tester V1.0 HAB", size = (350, 310)) MyPanel(frame,-1) frame.Show(True) app.MainLoop()
![]() |
Other Threads in the Python Forum
- Previous Thread: run different versions of wxPython
- Next Thread: File with date + time
Views: 4965 | Replies: 13
| Thread Tools | Search this Thread |
Tag cloud for Python
advanced anydbm app assignment bash beginner bits bluetooth calling chmod cmd code convert cursor data decimals dictionary dynamic dynamically examples excel external file float format ftp function gnu gui homework http import input itunes jaunty java keycontrol leftmouse line linux list lists loan loop maintain millimeter module mouse newb number numbers output parsing path port prime program programming projects push py-mailer py2exe pygame pyqt python random recursion recursive scrolledtext search slicenotation smtp split ssh string strings table tennis terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable variables ventrilo web webservice windows wxpython






