wxPython slider help

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

wxPython slider help

 
0
  #1
Oct 17th, 2005
I have run the slider demo that come with wxPython docs. It is rather stupid, as it puts slider on a panel using many unexplained numbers, never tells how to get position of slider or what to do next if the slider is moved. I am much lost, does anyone have a actual usefull example?
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: wxPython slider help

 
0
  #2
Oct 17th, 2005
I googled and found something in a old code at:
http://aspn.activestate.com/ASPN/Mai...-users/1908355

Still not shure!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,126
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 946
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: wxPython slider help

 
0
  #3
Oct 18th, 2005
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
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: wxPython slider help

 
0
  #4
Oct 19th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: wxPython slider help

 
0
  #5
Oct 19th, 2005
when I run the code, I get this error
  1. shane@mainbox ~ $ python test.py
  2. Traceback (most recent call last):
  3. File "test.py", line 58, in ?
  4. MyPanel(frame,-1)
  5. File "test.py", line 41, in __init__
  6. self.Bind(wx.EVT_SLIDER, self.sliderUpdate)
  7. 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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,126
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 946
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: wxPython slider help

 
0
  #6
Oct 19th, 2005
Bind was introduced with version 2.5 of wxPython.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 215
Reputation: shanenin is an unknown quantity at this point 
Solved Threads: 16
shanenin shanenin is offline Offline
Posting Whiz in Training

Re: wxPython slider help

 
0
  #7
Oct 19th, 2005
is version 2.4 of wxPython still needed for many apps to run. Do you guys run both versions?
In a perfect world exceptions would not be needed.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,126
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 946
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: wxPython slider help

 
0
  #8
Oct 19th, 2005
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!
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 4,126
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 946
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: wxPython slider help

 
0
  #9
Oct 20th, 2005
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.
The best area to color with the sliders without getting too much flickering would be a paint event like drawing and then floodfilling a shape like a rectangle. Take a look at the wxPython snippet ...
http://www.daniweb.com/code/snippet407.html
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,221
Reputation: bumsfeld will become famous soon enough bumsfeld will become famous soon enough 
Solved Threads: 138
bumsfeld's Avatar
bumsfeld bumsfeld is offline Offline
Nearly a Posting Virtuoso

Re: wxPython slider help

 
0
  #10
Oct 23rd, 2005
This how far I am with the program. It does flicker so and needs more work:
  1. # Colour Matching Skill Tester first version
  2. # Colour the label1 with random RGB values
  3. # Colour the label2 with RGB values from sliders
  4. # Needs exposition of result closeness and possible file saving
  5.  
  6. import random
  7. import wx
  8.  
  9. class MyPanel(wx.Panel):
  10. """ class MyPanel creates a panel with 2 labels, 3 sliders, inherits wx.Panel """
  11. def __init__(self, parent, id):
  12. wx.Panel.__init__(self, parent, id)
  13. self.SetBackgroundColour("white")
  14. str1 = ""
  15.  
  16. self.Red1 = random.randrange(256)
  17. self.Green1 = random.randrange(256)
  18. self.Blue1 = random.randrange(256)
  19. # label1 with random RGB colour values
  20. self.label1 = wx.StaticText(self, -1, str1 , (10, 10), (120, 100))
  21. self.label1.SetBackgroundColour((self.Red1, self.Green1, self.Blue1))
  22.  
  23. self.Red2 = 125
  24. self.Green2 = 125
  25. self.Blue2 = 125
  26. # label2 with RGB colour values from sliders
  27. self.label2 = wx.StaticText(self, -1, str1 , (10, 120), (120, 100))
  28. self.label2.SetBackgroundColour((self.Red2, self.Green2, self.Blue2))
  29.  
  30. # init value = 125, min value = 0, max value = 255 for colours
  31. self.sliderR = wx.Slider(self, -1, self.Red2, 0, 255, (140, 10), (50, 200),
  32. wx.SL_VERTICAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
  33. wx.StaticText(self, -1, "Red" , (160, 205))
  34. self.sliderG = wx.Slider(self, -1, self.Green2, 0, 255, (200, 10), (50, 200),
  35. wx.SL_VERTICAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
  36. wx.StaticText(self, -1, "Green" , (220, 205))
  37. self.sliderB = wx.Slider(self, -1, self.Blue2, 0, 255, (260, 10), (50, 200),
  38. wx.SL_VERTICAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
  39. wx.StaticText(self, -1, "Blue" , (280, 205))
  40.  
  41. # result label
  42. self.label3 = wx.StaticText(self, -1, "", (160, 230))
  43.  
  44. # all three sliders ...
  45. self.Bind(wx.EVT_SCROLL, self.slideColour)
  46.  
  47. # button click
  48. self.button1 = wx.Button(self, -1, "Evaluate", (10, 230))
  49. self.button1.Bind(wx.EVT_BUTTON, self.button1Click)
  50.  
  51. def slideColour(self, event):
  52. self.Red2 = self.sliderR.GetValue()
  53. self.Green2 = self.sliderG.GetValue()
  54. self.Blue2 = self.sliderB.GetValue()
  55. colour1 = wx.Colour(self.Red2, self.Green2, self.Blue2)
  56. # still flickers much!
  57. self.label2 = wx.StaticText(self, -1, "", (10, 120), (120, 100)).SetBackgroundColour(colour1)
  58.  
  59. def button1Click(self,event):
  60. str1 = "Upper R=%d G=%d B=%d" % (self.Red1, self.Green1, self.Blue1)
  61. str2 = "Lower R=%d G=%d B=%d" % (self.Red2, self.Green2, self.Blue2)
  62. self.label3.SetLabel(str1 + '\n' + str2)
  63.  
  64.  
  65. app = wx.PySimpleApp()
  66. frame = wx.Frame(None, -1, "Colour Skill Tester V1.0 HAB", size = (350, 310))
  67. MyPanel(frame,-1)
  68. frame.Show(True)
  69. app.MainLoop()
Anybody have idea about stopping flicker?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Python Forum


Views: 4965 | Replies: 13
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC