Re: question regarding wxSlider

2010-03-13 Thread Ugo Cupcic
Hi Philip,

Thanks for your redirection. I'll try with them :)

Cheers,

Ugo

PS : yes developing  a robotic hand is really fun :D

On Fri, Mar 12, 2010 at 7:08 PM, Philip Semanchuk phi...@semanchuk.comwrote:

 On Mar 12, 2010, at 1:56 PM, Ugo Cupcic wrote:

  Hi all,

 I have a question regarding wxSlider. I'm developing a wxwidget python
 interface for a robotic hand. The sliders send the target values to the
 joints.

 I'd like to display the current position of the joint on the slider. I
 wanted to use wxSlider.SetTick(myposition) but I couldn't get SetTick to
 display anything.

 Anyone has an idea ? I attached a dummy code to the message to illustrate.



 Hi Ugo,
 I don't mean to chase you away, but there is a dedicated wxPython mailing
 list where you obviously have a much better chance of getting an answer.

 http://www.wxpython.org/maillist.php

 Developing a robotic hand sounds like fun!

 Cheers
 Philip




 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
  Ugo Cupcic
http://www.genugo.com/ugocupcic
   _
  ' v '
/  \
 m m
-- 
http://mail.python.org/mailman/listinfo/python-list


question regarding wxSlider

2010-03-12 Thread Ugo Cupcic
Hi all,

I have a question regarding wxSlider. I'm developing a wxwidget python
interface for a robotic hand. The sliders send the target values to the
joints.

I'd like to display the current position of the joint on the slider. I
wanted to use wxSlider.SetTick(myposition) but I couldn't get SetTick to
display anything.

Anyone has an idea ? I attached a dummy code to the message to illustrate.

Cheers,

Ugo

-- 
  Ugo Cupcic
http://www.genugo.com/ugocupcic
   _
  ' v '
/  \
 m m
#!/usr/bin/python
import sys
sys.path.append(python_hand_library/)
from shadowhand import ShadowHand


# import the wxPython GUI package
import wx


# Create a new frame class, derived from the wxPython Frame.
class MyFrame(wx.Frame):

def __init__(self, parent, id, title):
# First, call the base class' __init__ method to create the frame
wx.Frame.__init__(self, parent, id, title)

#shadow arm - TODO : use dialog window to set ssh / not ssh  
self.myShadowHand = ShadowHand(0)

# Add a panel and some controls to display the size and position
panel = wx.Panel(self, -1)

#display a slider for each joints
self.joints = []
self.labels = []
self.sliders = []
self.slidervalues = []
for joint in self.myShadowHand.handJoints:
self.slidervalues.append(self.myShadowHand.valueof(joint.name))
self.joints.append(joint)
self.labels.append(wx.StaticText(panel, -1, joint.name))
self.sliders.append(wx.Slider(panel, -1, value = self.myShadowHand.valueof(joint.name), minValue = joint.min, 
 maxValue = joint.max, size=(25,200), style = wx.VERTICAL | wx.SL_LABELS | wx.SL_AUTOTICKS  ))

self.panel = panel


# initialize the positions + sendupdate only when relevant
self.oldPositions = []
for joint in self.joints:
self.oldPositions.append(self.myShadowHand.valueof(joint.name))

# Use some sizers for layout of the widgets
sizer = wx.FlexGridSizer(vgap=5, hgap=20)
subsizers = []

index = 0
for label in self.labels:
# draw the stuff
subsizerTmp = wx.FlexGridSizer(rows=2, cols=1, vgap = 10)
subsizerTmp.Add(self.sliders[index])
subsizerTmp.Add(label)
subsizers.append(subsizerTmp)
index += 1

for subsizer in subsizers:
sizer.Add(subsizer)

self.timer = wx.Timer(self)  


# bind the slider event
self.Bind(wx.EVT_SLIDER, self.sliderUpdate)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
  
self.timer.Start(250)

border = wx.BoxSizer()
border.Add(sizer, 0, wx.ALL, 15)
panel.SetSizerAndFit(border)
self.Fit()

def sliderUpdate(self, event):
index = 0 
for slider in self.sliders:
#value_tmp = slider.GetValue()
#if self.oldPositions[index] != value_tmp:
#self.myShadowHand.sendupdate(self.joints[index].name, value_tmp)
self.slidervalues[index] = slider.GetValue()
#index += 1
#self.myShadowHand.resend_targets(self.slidervalues)

def update(self, event):
self.myShadowHand.resend_targets(self.slidervalues)

# Every wxWidgets application must have a class derived from wx.App
class MyApp(wx.App):

# wxWindows calls this method to initialize the application
def OnInit(self):

# Create an instance of our customized Frame class
frame = MyFrame(None, -1, Joint Sliders)
frame.Show(True)

# Tell wxWindows that this is our main window
self.SetTopWindow(frame)

# Return a success flag
return True

app = MyApp(0) # Create an instance of the application class
app.MainLoop() # Tell it to start processing events
-- 
http://mail.python.org/mailman/listinfo/python-list