#Add the misspelled word to the drop down menu #and make is the first item c.AddText(y) c.SelectedItem = y #Offer alternative spellings in the drop down menu for suggest in suggestions(y): c.AddText(suggest) #Add the combo box to the drop down menu paragraph.Inlines.Add(c) else: paragraph.Inlines.Add(Run(y)) paragraph.Inlines.Add(" ") paragraph.Inlines.Add(Run("\n")) else: #If there's no comment in the line, just directly #add it to the paragraph paragraph.Inlines.Add(Run(x)) return paragraph #--MAIN------------------------------------------------------------------------ main_window.Title = "IronPython Comment Checker" main_window.Background = Black main_window.Foreground = PaleGreen main_window.Content = FlowDocumentScrollViewer() main_window.Content.Document = FlowDocument() main_window.Content.Document.Blocks.Add(create_paragraph(lines_in_file)) main_window.Show() Application().Run() ms_word.Quit()
def create(): Application().Run(MacronWindow(config))
def _thread(cls, xaml=None): app = cls() app._load(xaml) Application().Run(app.window)
<Button Content="Button" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="101.6,42.4,0,0" Width="75.2" Height="23.2" x:Name="button" /> <StackPanel Grid.Column="0" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="24.8,84.8,0,0" Width="234.4" Height="161.6" x:Name="stackPanel" /> </Grid> </Window>""" try: hello = HelloWorld(xaml) print dir(hello) Application().Run(hello.winLoad) raw_input() #for debug in SharpDevelop except Exception as ex: print ex raw_input() #for debug in SharpDevelop
class ViewModel(NotifyPropertyChangedBase): def __init__(self): super(ViewModel, self).__init__() # must be string to two-way binding work correctly #self.define_notifiable_property("size") self.size = '10' self.fill_color = '#0066cc' self._red = 90 self._green = 55 self._blue = 200 class TestWindow(MetroWindow): def __init__(self): wpf.LoadComponent(self, 'MetroWindow.xaml') self._vm = ViewModel() self.DataPanel.DataContext = self._vm def __getattr__(self, name): # provides easy access to XAML elements (e.g. self.Button) return self.root.FindName(name) if __name__ == '__main__': app = Application() print "create window" wnd = TestWindow() print "run window" app.Run(wnd)
self.ball.move() self.plot(self.ball) def base_timer(self, sender, e): if self.started and ((self.base.get_direction() == Direction.LEFT and \ (self.base.xpos-self.base.width/2-self.base.speed)>0) \ or (self.base.get_direction() == Direction.RIGHT and \ (self.base.xpos+self.base.width/2+self.base.speed) < self.canvas.ActualWidth)): self.base.move() self.plot(self.base) def key_up(self, sender, e): (e.Key == Key.Escape) and self.init_game() (e.Key == Key.Enter) and not self.started and self.start_game() if (e.Key in (Key.Right, Key.Left)) and self.timers['base'].IsEnabled: self.timers['base'].Stop() def key_down(self, sender, e): if e.Key == Key.Left: if self.started and not self.timers['base'].IsEnabled: self.base.set_direction(Direction.LEFT) self.timers['base'].Start() elif e.Key == Key.Right: if self.started and not self.timers['base'].IsEnabled: self.base.set_direction(Direction.RIGHT) self.timers['base'].Start() if __name__ == '__main__': Application().Run(Gui('config.cfg'))
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) 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)
def main(): Application().Run(MyWindow())
for joint in data.Joints: if joint.ID == JointID.Head: jointPos = self.getDisplayPosition(joint) self.lastX = jointPos.X self.foundHead = True if self.foundHead: bubble = Image() #imageSource = System.Windows.Resources["think"] bubble.Source = self.thinkBubble bubble.SetValue(Canvas.TopProperty, self.lastY) bubble.SetValue(Canvas.LeftProperty, self.lastX) self.skeleton.Children.Add(bubble) text = TextBox() text.Text = "Hello World!" text.FontSize = 50 text.FontWeight = FontWeights.Bold text.BorderThickness = Thickness(0) text.SetValue(Canvas.TopProperty, self.lastY + 120) text.SetValue(Canvas.LeftProperty, self.lastX + 60) self.skeleton.Children.Add(text) def on_closing(self, s, e): self.nui.Uninitialize() if __name__ == '__main__': Application().Run(MainWindow())
def main(): hello = HelloWorld() app = Application() app.Run(hello.Root)
pass def Port_TextBox_TextChanged(self, sender, e): pass def User_TextBox_New_TextChanged(self, sender, e): pass def btn_test_Click(self, sender, e): MessageBox.Show("Welcome " + self.user + " to the Dev console, in future this will launch the Black Frost Console!", "Dev Console Alert" ) def dev_CheckBox_Checked(self, sender, e): self.btn_test.IsEnabled = True def dev_CheckBox_UnChecked(self, sender, e): self.btn_test.IsEnabled = False def JoystickEnable_CheckBox_Checked(self, sender, e): self.DebugEnabled_CheckBox.IsChecked = False def DebugEnabled_CheckBox_Checked(self, sender, e): self.JoystickEnable_CheckBox.IsChecked = False def TCPEnabled_CheckBox_Checked(self, sender, e): pass if __name__ == '__main__': Application().Run(StartWindow())
def start(): global idu app = Application() idu = IronDiskUsage(app) app.Run()
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): self.window = OverlayWindow() Application().Run(self.window.window)
import time from Main_Client import MainClient from System.Windows import Application, Window, MessageBox class MyWindow(Window): def __init__(self): wpf.LoadComponent(self, 'client_WPF.xaml') def Submit_Button_Click(self, sender, e): try: client = MainClient() client.UserID = self.InputuserID.Text client.PSW = self.Inputpassw.Password ss = client.conn() if client.result == 'Y': Choose = Window1(ss) Choose.ShowDialog() self.Hide() except Exception, e: tracelog = traceback.format_exc() MessageBox.Show(str(e)) pass def InputuserID_TextChanged(self, sender, e): pass if __name__ == '__main__': Application().Run(MyWindow())
def __init__(self): stream = StreamReader("DynamicGrid.xaml") window = XamlReader.Load(stream.BaseStream) Application().Run(window)
import clr clr.AddReference("PresentationCore") clr.AddReference("System.Xaml") clr.AddReference("WindowsBase") clr.AddReference("PresentationFramework") clr.AddReference('IronPython.wpf') import wpf from System.Windows import Application, Window class LoseScreen(Window): def __init__(self): wpf.LoadComponent(self, 'LoseScreen.xaml') if __name__ == '__main__': Application().Run(LoseScreen())
# -*- coding: utf-8 -*- """ Data Binding Example. * Run this file. """ import wpf from System.Windows import Application, Window from example_databinding_viewmodel import Example_databinding_viewmodel class Example_databinding_main(Window): def __init__(self): self.vm = Example_databinding_viewmodel() self.DataContext = self.vm wpf.LoadComponent(self, 'example_databinding_view.xaml') print('Init window.') if __name__ == '__main__': Application().Run(Example_databinding_main())
def RunApp(rootElement): app = Application() app.Run(rootElement)
#print time.strftime("%a%b%d%H:%M:%S%Y", time.localtime()) name = time.strftime("%a%b%d%H%M%S%Y", time.localtime()) + "camera1.jpg" try: filestream = FileStream(name, FileMode.Create) except: filestream = FileStream( time.strftime("%a%b%d%H%M%S%Y", time.localtime()) + "camera2.jpg", FileMode.Create) encoder = JpegBitmapEncoder() encoder.FlipHorizontal = True encoder.FlipVertical = True encoder.Frames.Add(BitmapFrame.Create(self.CameraDisplay.Source)) encoder.Save(filestream) #Receive=receive_window(self.Addr,name) filestream.Close() self.Cameracapturedll.Release() self.ss.pathBlock.Text = name self.ss.StartTransFile(name) self.Hide() def Cancle_Button_Click(self, sender, e): self._worker.CancelAsync() def Window_Close(self, sender, e): self._worker.CancelAsync() if __name__ == '__main__': Application().Run(CameraCap())