def __init__(self, xaml): self._xaml = xaml xr = XmlReader.Create(StringReader(xaml)) self.winLoad = XamlReader.Load(xr) self._button = self.winLoad.FindName('button') self._stakpanel = self.winLoad.FindName('stackPanel') self._button.Click += self.onClick
def __init__(self): rd = ResourceDictionary() rd.Source = Uri( "pack://application:,,,/ClassicAssist.Shared;component/Resources/DarkTheme.xaml" ) self.Resources.MergedDictionaries.Add(rd) self.Background = self.Resources["ThemeWindowBackgroundBrush"] self.Content = XamlReader.Parse(xaml) self.Title = "Rudder" self.Topmost = True self.Height = 250 self.Width = 250 self.refreshTime = TimeSpan.FromSeconds(30) self.events = [('forwardLeft', 'Forward Left'), ('forward', 'Forward'), ('forwardRight', 'Forward Right'), ('left', 'Left'), ('turnAround', 'Turn Around'), ('right', 'Right'), ('backLeft', 'Back Left'), ('back', 'Back'), ('backRight', 'Back Right'), ('stop', 'Stop'), ('raiseAnchor', 'Raise Anchor'), ('dropAnchor', 'Drop Anchor'), ('turnLeft', 'Turn Left'), ('turnRight', 'Turn Right'), ('start', 'Start')] self.setEvents()
def __init__(self, overlay: OverlayWindow): self.overlay = overlay self.window = XamlReader.Load( XmlReader.Create(StringReader(SettingsXaml))) self.InitializeComponent() self.LoadConfig()
def __deserialize_from_xml(file_full_name): iaddin_custom_frame_instance = None try: filereader = None try: filereader = File.OpenText(file_full_name) if filereader: content = filereader.ReadToEnd() stringreader = StringReader(content) xmlreader = None try: xmlreader = XmlReader.Create(stringreader) if xmlreader: iaddin_custom_frame_instance = XamlReader.Load( xmlreader) finally: if xmlreader: xmlreader.Dispose() xmlreader = None finally: if filereader: filereader.Dispose() filereader = None except Exception as e: CommonUtil.sprint("Failed to desrialize: {}".format(e)) iaddin_custom_frame_instance = None return iaddin_custom_frame_instance
def SaveXaml(filename, element): from System.Windows.Serialization import XamlReader s = XamlReader.SaveAsXml(element) try: f = open(filename, "w") f.write(s) finally: f.close()
def __init__(self, xamlPath): stream = File.OpenRead(xamlPath) try: self.Root = XamlReader.Load(stream) except SystemError, e: print 'Error parsing xaml file: {0}'.format(xamlPath) #print str(e) raise e
def LoadXaml(filename): from System.IO import * from System.Windows.Markup import XamlReader f = FileStream(filename, FileMode.Open, FileAccess.Read) try: element = XamlReader.Load(f) finally: f.Close() return element
def __init__(self): xaml = '''<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Grid> <Label Content="Hello XAML!" HorizontalAlignment="Center" VerticalAlignment="Center"/> </Grid> </Window>''' window = XamlReader.Parse(xaml) Application().Run(window)
def __init__(self, mode): f = FileStream(Path.Combine(SCRIPTDIRECTORY, "DuplicateForm.xaml"), FileMode.Open) self.win = XamlReader.Load(XmlReader.Create(f)) f.Close() self._action = None self.RenameText = "The file you are moving will be renamed: " #Load the images and icon path = FileInfo(__file__).DirectoryName arrow = BitmapImage() arrow.BeginInit() arrow.UriSource = Uri(Path.Combine(SCRIPTDIRECTORY, "arrow.png"), UriKind.Absolute) arrow.EndInit() self.win.FindName("Arrow1").Source = arrow self.win.FindName("Arrow2").Source = arrow self.win.FindName("Arrow3").Source = arrow icon = BitmapImage() icon.BeginInit() icon.UriSource = Uri(ICON, UriKind.Absolute) icon.EndInit() self.win.Icon = icon self.win.FindName("CancelButton").Click += self.CancelClick self.win.FindName("Cancel").Click += self.CancelClick self.win.FindName("ReplaceButton").Click += self.ReplaceClick self.win.FindName("RenameButton").Click += self.RenameClick self.win.Closing += self.FormClosing #The the correct text based on what mode we are in #Mode is set by default so only change if in Copy or Simulation mode if mode == Mode.Copy: self.win.FindName("MoveHeader").Content = "Copy and Replace" self.win.FindName( "MoveText" ).Content = "Replace the file in the destination folder with the file you are copying:" self.win.FindName("DontMoveHeader").Content = "Don't Copy" self.win.FindName( "RenameHeader").Content = "Copy, but keep both files" self.RenameText = "The file you are copying will be renamed: " self.win.FindName( "RenameText" ).Text = "The file you are copying will be renamed: " if mode == Mode.Simulate: self.win.FindName( "Subtitle" ).Content = "Click the file you want to keep (simulated, no files will be deleted or moved)"
def __init__(self, model): """ Display the GUI using data in the model class """ self.model = model stream = StreamReader( os.path.join(os.path.dirname(__file__), GUI_XAML_FILE)) self.window = XamlReader.Load(stream.BaseStream) self.window.Title = self.model.title self.lblPrompt = LogicalTreeHelper.FindLogicalNode( self.window, "lblPrompt") self.lblPrompt.Content = self.model.prompt self.choicesGrid = LogicalTreeHelper.FindLogicalNode( self.window, "choicesGrid") self.choicesChk = System.Array.CreateInstance( CheckBox, len(self.model.choiceList)) self.choicesLabels = System.Array.CreateInstance( Label, len(self.model.choiceList)) for ii, choiceName in enumerate(self.model.choiceList): self.choicesGrid.RowDefinitions.Add(RowDefinition()) self.choicesLabels[ii] = Label() self.choicesLabels[ii].Content = choiceName self.choicesLabels[ii].SetValue(Grid.RowProperty, ii) self.choicesLabels[ii].SetValue(Grid.ColumnProperty, 0) if self.model.alignChoices.lower() == 'left': self.choicesLabels[ ii].HorizontalAlignment = HorizontalAlignment.Left else: self.choicesLabels[ ii].HorizontalAlignment = HorizontalAlignment.Right self.choicesGrid.Children.Add(self.choicesLabels[ii]) self.choicesChk[ii] = CheckBox() self.choicesChk[ii].Margin = Thickness(7.0, 7.0, 2.0, 2.0) self.choicesChk[ii].SetValue(Grid.RowProperty, ii) self.choicesChk[ii].SetValue(Grid.ColumnProperty, 1) self.choicesChk[ii].HorizontalAlignment = HorizontalAlignment.Left self.choicesGrid.Children.Add(self.choicesChk[ii]) self.btCancel = LogicalTreeHelper.FindLogicalNode( self.window, "btCancel") self.btCancel.Click += self.cancel_clicked self.btOK = LogicalTreeHelper.FindLogicalNode(self.window, "btOK") self.btOK.Click += self.ok_clicked self.window.Show() self.window.Closed += lambda s, e: self.window.Dispatcher.InvokeShutdown( ) System.Windows.Threading.Dispatcher.Run()
def getNumberOfSpeakers(): vm = ViewModel(Application.Current.MainWindow.DataContext.Speakers.Length) stream = Application.Current.GetType().Assembly.GetManifestResourceStream( "IronPython.UI.Scripts.ResultWindow.xaml") reader = StreamReader(stream) window = XamlReader.Parse(reader.ReadToEnd()) reader.Close() stream.Close() window.DataContext = vm window.FindName("CloseButton").Click += lambda s, e: window.Close() window.Show()
def __init__(self): try: stream = StreamReader(xaml_path) self.window = XamlReader.Load(stream.BaseStream) self.initialise_icon() self.initialise_elements() self.initialise_visibility() Application().Run(self.window) except Exception as ex: print(ex)
def __init__(self): stream = File.OpenRead( "wpfFromXAML2.xaml") #r'D:\git\ipy\ch9_wpf\wpfFromXAML.xaml' #stream = File.OpenRead(r'D:\git\ipy\ch9_wpf\wpfFromXAML2.xaml') #r'D:\git\ipy\ch9_wpf\wpfFromXAML.xaml' # create WPF object from xaml self.Root = XamlReader.Load(stream) self.button = self.Root.FindName('button') self.stackPanel = self.Root.FindName('stackPanel') self.button.Click += self.on_click self.button.Click += self.button_Click
def LoadXaml(filename): from System.IO import * from System.Windows.Markup import XamlReader from System.Windows.Markup import ParserContext f = FileStream(filename, FileMode.Open, FileAccess.Read) try: parserContext = ParserContext() parserContext.XmlnsDictionary.Add('c','IronTunesApp') element = XamlReader.Load(f) finally: f.Close() return element
def __init__(self): self.window = XamlReader.Load( XmlReader.Create(StringReader(OverlayXaml))) self.console = Console() self.InitializeComponent() self.LoadConfig() self.settings = SettingsWindow(self) self.Run()
def load_document(path, page, console): with open(path) as handle: xaml = handle.read().decode('utf-8') document = XamlReader.Load(xaml) for index, button in enumerate(find_buttons(document)): def handler(sender, event, index=index): code = get_code(path, page, index) console.handle_lines(code) button.Click += handler return document
def _load(self, xaml=None): '''创建一个 Xaml 窗口程序 :param xaml: xaml 文件路径或者 xaml 格式的 xml 字符串 ''' window = None if not xaml: xaml = PythonWin.emptyWindowXaml if xaml.startswith('<Window xmlns'): window = XamlReader.Parse(xaml) else: stream = StreamReader(xaml) window = XamlReader.Load(stream.BaseStream) self.window = window self.controls = {'All': {}} self._get_windows_controls(window) self.auto_bind_events() invert_op = getattr(self, "load", None) if callable(invert_op): getattr(self, 'load')()
def create_user_control(filename): userControl = None try: s = None if filename: s = StreamReader(filename) userControl = XamlReader.Load(s.BaseStream) except Exception as e: CommonUtil.sprint("Failed to Create UserControl: {}".format(e)) finally: if s: s.Close() s.Dispose() return userControl
def __init__(self): rd = ResourceDictionary() rd.Source = Uri("pack://application:,,,/ClassicAssist.Shared;component/Resources/DarkTheme.xaml") self.Resources.MergedDictionaries.Add(rd) self.Background = self.Resources["ThemeWindowBackgroundBrush"] self.Content = XamlReader.Parse(xaml) self.Title = "Durability" self.Topmost = True self.SizeToContent = SizeToContent.Width self.Height = 400 self.refreshTime = TimeSpan.FromSeconds(30) self.listView = self.Content.FindName('listView') self.startButton = self.Content.FindName('startButton') self.startButton.Click += self.onClick self.timer = DispatcherTimer() self.timer.Tick += self.onTick self.timer.Interval = TimeSpan().FromSeconds(0) self.timer.Start() self.timer.Interval = self.refreshTime self.Running = True
import clr clr.AddReference("PresentationFramework") clr.AddReference("System.Xml") from System.Xml import XmlReader from System.Windows.Markup import XamlReader xaml = XmlReader.Create("app.xaml") app = XamlReader.Load(xaml) xaml.Close() app.Run()
def InitializeComponent(self): self.server = "eu" self.window.MouseLeftButtonDown += self.MoveOverlay self.window.MouseLeftButtonUp += self.SaveOverlayPos self.window.MouseRightButtonUp += self.OverlayRightClick grid = LogicalTreeHelper.FindLogicalNode(self.window, "Grid") self.label = XamlReader.Load( XmlReader.Create(StringReader(OverlayLabelXaml))) self.check_label = XamlReader.Load( XmlReader.Create(StringReader(OverlayLabelXaml))) self.check_label.VerticalAlignment = 0 self.check_label.HorizontalAlignment = 0 self.check_label.Background = BrushFromHex("#00000000") self.check_label.Foreground = BrushFromHex("#00000000") self.check_label.Content = "9999ms" grid.Children.Add(self.label) grid.Children.Add(self.check_label) # Overlay menu self.menu = System.Windows.Forms.ContextMenuStrip() settings_item = System.Windows.Forms.ToolStripMenuItem("Settings") settings_item.Click += self.OpenSettings console_item = System.Windows.Forms.ToolStripMenuItem("Console") console_item.Click += self.OpenConsole respos_item = System.Windows.Forms.ToolStripMenuItem("Reset position") respos_item.Click += self.ResetPos close_item = System.Windows.Forms.ToolStripMenuItem("Close") close_item.Click += self.CloseOverlay self.menu.Items.Add(settings_item) self.menu.Items.Add(console_item) self.menu.Items.Add(respos_item) self.menu.Items.Add(close_item) # Icon menu menu_icon = System.Windows.Forms.ContextMenu() settings_item_icon = System.Windows.Forms.MenuItem("Settings") settings_item_icon.Click += self.OpenSettings console_item_icon = System.Windows.Forms.MenuItem("Console") console_item_icon.Click += self.OpenConsole respos_item_icon = System.Windows.Forms.MenuItem("Reset position") respos_item_icon.Click += self.ResetPos close_item_icon = System.Windows.Forms.MenuItem("Close") close_item_icon.Click += self.CloseOverlay menu_icon.MenuItems.Add(settings_item_icon) menu_icon.MenuItems.Add(console_item_icon) menu_icon.MenuItems.Add(respos_item_icon) menu_icon.MenuItems.Add(close_item_icon) notify_icon = System.Windows.Forms.NotifyIcon() notify_icon.Text = "Brawlhalla Display Ping" notify_icon.Icon = System.Drawing.Icon(ResourcePath("icon.ico")) notify_icon.ContextMenu = menu_icon notify_icon.Click += self.ClickTrayIcon notify_icon.Visible = True
def __init__(self): self.window = XamlReader.Load( XmlReader.Create(StringReader(ConsoleXaml))) self.InitializeComponent()
def __init__(self): ''' get the window design from Window.xaml FindLogicalNode maps each component to a variable += maps an event to a function, the name of the event can be found in Windows class help file ''' Window.__init__(self) stream = StreamReader("Window.xaml") window = XamlReader.Load(stream.BaseStream) self._timer = DispatcherTimer() self._timer.Tick += self._timer_Tick self._timer.Interval = TimeSpan.FromMilliseconds(10) 'run the timer every 10ms' self._timer.Start() initializing = True print("main window") while Transfer.all_connected() == False and initializing: if MessageBox.Show("Devices not initialized, retry?","warning", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes: Transfer.reinitialize() else: initializing = False if initializing == False: Application.Current.Shutdown() return self.UI_x = LogicalTreeHelper.FindLogicalNode(window, "UI_x") self.UI_x.Content = KCubeDCServoUI.CreateLargeView(Transfer.x) self.UI_y = LogicalTreeHelper.FindLogicalNode(window, "UI_y") self.UI_y.Content = KCubeDCServoUI.CreateLargeView(Transfer.y) self.UI_z = LogicalTreeHelper.FindLogicalNode(window, "UI_z") self.UI_z.Content = KCubeDCServoUI.CreateLargeView(Transfer.z) self.UI_rx = LogicalTreeHelper.FindLogicalNode(window, "UI_rx") self.UI_rx.Content = KCubeDCServoUI.CreateLargeView(Transfer.rx) self.UI_ry = LogicalTreeHelper.FindLogicalNode(window, "UI_ry") self.UI_ry.Content = KCubeDCServoUI.CreateLargeView(Transfer.ry) self.UI_r = LogicalTreeHelper.FindLogicalNode(window, "UI_r") self.UI_r.Content = KCubeDCServoUI.CreateLargeView(Transfer.r) self.Help = LogicalTreeHelper.FindLogicalNode(window, "Help") self.Help.Click += self.Help_Click self.ZUp = LogicalTreeHelper.FindLogicalNode(window, "ZUp") self.ZUp.Checked += self.ZUp_Checked self.ZUp.Unchecked += self.ZUp_Unchecked self.ZDown = LogicalTreeHelper.FindLogicalNode(window, "ZDown") self.ZDown.Checked += self.ZDown_Checked self.ZDown.Unchecked += self.ZDown_Unchecked self.ViewMode = LogicalTreeHelper.FindLogicalNode(window, "ViewMode") self.ViewMode.SelectionChanged += self.ViewMode_Changed self.Button1 = LogicalTreeHelper.FindLogicalNode(window, "Button1") self.Button1.Click += self.Button1_Click self.Mode = LogicalTreeHelper.FindLogicalNode(window, "Mode") self.Mode.Text = "High speed mode" self.RotateAngle = LogicalTreeHelper.FindLogicalNode(window, "Angle") self.Title = "Gaming..." '''lock the size''' Application().Run(window)
def __init__(self, xaml): try: self.Root = XamlReader.Load(xaml) except SystemError, e: print 'Error parsing xaml: {0}'.format(xaml) raise e
def __init__(self): stream = StreamReader("DynamicGrid.xaml") window = XamlReader.Load(stream.BaseStream) Application().Run(window)
def __init__(self): self._vm = ViewModel() self.root = XamlReader.Parse(XAML_str) self.DataPanel.DataContext = self._vm self.Button.Click += self.OnClick
def __init__(self): stream = File.OpenRead(fileName) self.Root = XamlReader.Load(stream) self.button = self.Root.FindName('button') self.stackPanel = self.Root.FindName('stackPanel') self.button.Click += self.onClick
for cc in c.Children: Waddle(cc, d) elif hasattr(c,"Child"): Waddle(c.Child, d) elif hasattr(c,"Content"): Waddle(c.Content, d) # Test Functions. def sayhello(s,e): print "sayhello" def sayhello2(s,e): print "sayhello2" if __name__ == "__main__": xr = XmlReader.Create(StringReader(xaml)) win = XamlReader.Load(xr) controls = {} Waddle(win, controls) #Make all Named buttons do something! for butt in controls['Button']: controls['Button'][butt].Click += sayhello #Make one button do something. controls['Button']['NewSite'].Click += sayhello2 Application().Run(win) xr = XmlReader.Create(StringReader(xaml)) win = XamlReader.Load(xr)
scrollers.pop() if sender.SelectedIndex == 0: scrollers.append(scroller) focus_text_box() if sender.SelectedIndex == 1: scrollers.append(about) if sender.SelectedIndex == 2: scrollers.append(documentation) tab_control.SelectionChanged += on_tabpage_changed changing_scrollers = [about, documentation, scroller] with open('docs.xaml') as handle: xaml = handle.read().decode('utf-8') doc_page = XamlReader.Load(xaml) documentation.Content = doc_page ########################################### # setup navigationbars # can't be done in a class or event unhooking # doesn't seem to work :-( _xaml_cache = {} topComboBoxPage = root.topComboBoxPage bottomComboBoxPage = root.bottomComboBoxPage topComboBoxPart = root.topComboBoxPart bottomComboBoxPart = root.bottomComboBoxPart title = 'Try Python: %s'