Re: [IronPython] Slider In IronPython

2010-01-07 Thread Andrew Evans
I have debugged some of the code now it loads for a second then it some how
refreshes and disappears not sure what I am doing wrong

Any ideas

Cheers

Here is the full code hope that's alright :D


from System.Windows import Application
from System.Windows.Controls import MediaElement
from System.Windows.Controls import Button, Orientation, StackPanel, Slider
from System import Uri, UriKind
from System.Windows.Media.Imaging import BitmapImage
from System.Windows.Threading import *
from System import TimeSpan
class Gui():
def __init__(self):

self.main = StackPanel()

self.layer1 = StackPanel()
self.layer1.Orientation = Orientation.Horizontal

self.stopB = Button()
self.stopB.Width = 25
self.stopB.Height = 20
self.stopB.Content = BitmapImage(Uri(stop.jpg, UriKind.Relative))

self.pauseB = Button()
self.pauseB.Width = 25
self.pauseB.Height = 20
self.pauseB.Content = BitmapImage(Uri(pause.jpg,
UriKind.Relative))

self.playB = Button()
self.playB.Width = 25
self.playB.Height = 20
self.playB.Content = BitmapImage(Uri(play.jpg, UriKind.Relative))

# Assign Buttons to Functions
self.stopB.Click += self.StopPlay
self.pauseB.Click += self.PausePlay
self.playB.Click += self.StartPlay

#add a video slider
self.myslide = Slider()
self.myslide.Width = 250

# Add buttons to sub stack panel
self.layer1.Children.Add(self.stopB)
self.layer1.Children.Add(self.pauseB)
self.layer1.Children.Add(self.myslide)
self.layer1.Children.Add(self.playB)

# create new sub stack panel
self.layer2 = StackPanel()
self.layer2.Orientation = Orientation.Vertical

#create Media Element
self.video = MediaElement()
self.source = Uri(counter.wmv, UriKind.Relative)
self.video.Volume = 0.4
self.video.Source = self.source
self.video.Width = 450
self.video.Height = 400
self.video.CurrentStateChanged += self.videoChanged

self.timer = DispatcherTimer()
self.timer.Interval = TimeSpan.FromMilliseconds(45)
self.timer.Tick += self.MyTimeToTick



# Add media Element to Sub Stack panel
self.layer2.Children.Add(self.video)

# Add sub stack panels to place holde stack panel
self.main.Children.Add(self.layer1)
self.main.Children.Add(self.layer2)

# Load the UI
Application.Current.RootVisual = self.main

def MyTimeToTick(self, s, e):
if self.video.NaturalDuration.TimeSpan.TotalSeconds  0:
self.myslide.Value = self.video.Position.TotalSeconds /
self.video.NaturalDuration.TimeSpan.TotalSeconds


def videoChanged(self, s, e):
if self.video.NaturalDuration.CurrentState ==
MediaElementState.Playing:
self.timer.Start()
else:
self.timer.Stop()
##
##
def StopPlay(self, s, e):
# stop the video
self.video.Stop()

def PausePlay(self, s, e):
#pause the video
self.video.Pause()

def StartPlay(self, s, e):
#play the video
self.video.Play()

gui = Gui()
gui
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


[IronPython] Slider In IronPython

2010-01-06 Thread Andrew Evans
Ok I guess my first question is: Is there anyway to debug Silverlight
Applications. When I receive no errors makes it hard to do any debugging any
suggestions?

Next question

Making a slider for a video player here is the essential source. I
appreciate the feedback

# BEGIN LOTS OF CODE #

from System.Windows import Application
from System.Windows.Controls import MediaElement
from System.Windows.Controls import Button, Orientation, StackPanel, Slider
from System import Uri, UriKind
from System.Windows.Media.Imaging import BitmapImage
from System.Windows.Threading import *

...

self.timer = DispatcherTimer()
self.timer.Interval = TimeSpan.FromMilliseconds(50)
self.timer.Tick += MyTimeToTick
self.main = StackPanel()
...

#add a video slider
self.myslide = Slider()
self.myslide.Width = 250



  self.layer1.Children.Add(self.myslide)

...

#create Media Element
self.video = MediaElement()

...

self.video.CurrentStateChanged += videoChanged



def MyTimeToTick(self, s, e):
if self.video.NaturalDuration.TimeSpan.TotalSeconds  0:
self.myslide.Value = self.video.Position.TotalSeconds /
self.video.NaturalDuration.TimeSpan.TotalSeconds


def videoChanged(self, s, e):
if self.video.NaturalDuration.CurrentState == self.video.Playing:
self.timer.Start()
else:
self.timer.Stop()

# END CODE ##
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


Re: [IronPython] Slider In IronPython

2010-01-06 Thread Andrew Evans
It is not working and I would appreciate the feedback to get it to work

Sorry about my double post
___
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com