WPF Slider Control
import clr clr.AddReference("PresentationFramework") clr.AddReference("PresentationCore"); clr.AddReference('System.Data') clr.AddReference('System.Windows.Forms') import System from System import * from System.Data import * from System.Type import GetType from System.Threading.Tasks import Task from System.Windows import * from System.Windows.Controls import * from System.Windows.Controls.Primitives import * from System.Windows.Media import * from System.Windows.Media.Imaging import * from System.Windows.Media.Effects import * from System.Windows.Shapes import Rectangle from System.Windows.Shapes import Rectangle from System.Windows.Data import Binding from System.Windows.Ink import Stroke from System.Windows.Forms import ( FolderBrowserDialog, DialogResult ) from Microsoft.Win32 import ( OpenFileDialog, SaveFileDialog ) import ctrl class WpfSlider(ctrl.WpfCtrl): def __init__(self,handler=None,min=None,max=None,value=None,**kwargs): self.ctrl = Slider() self.init(**kwargs) if handler: self.ctrl.ValueChanged += handler self.ctrl.Width = 100; self.ctrl.Height = 16; self.ctrl.Minimum = min if min else 0 self.ctrl.Maximum = max if max else 100 self.ctrl.Value = value if value else 0 self.ctrl.SmallChange = 1 self.ctrl.LargeChange = 10 self.ctrl.TickPlacement = TickPlacement.BottomRight self.ctrl.TickFrequency = 10 def get_value(self): return self.ctrl.Value def set_value(self,v): self.ctrl.Value = v if __name__ == "__main__": def slider_handler(s,e): print(s.Value) import win app = win.Win("Button Demo",320,240) s = WpfSlider(slider_handler) s.set_value(50) app.set_content(s.ctrl) app.run()
댓글 없음:
댓글 쓰기