Esempio n. 1
0
def appStart():
	try:
		global are, idu
		app = Application()
		
		idu = IronDiskUsage(app)

		global dispatcher
		dispatcher = Dispatcher.FromThread(Thread.CurrentThread)
		
		are.Set()
		app.Run()
	finally:
		IronPython.Hosting.PythonEngine.ConsoleCommandDispatcher = None
Esempio n. 2
0
 def _initialize(self, state):
     print('init')
     global main_window, logic_thread, application, _running
     print('coinitializing')
     pythoncom.CoInitialize()
     print('coinitialized')
     main_window = MainWindow()
     main_window.DataContext = ApplicationViewModel()
     logic_thread = LogicThread(main_window.DataContext)
     logic_thread.start()
     application = Application()
     main_window.Hide()
     print('ai opened')
     _running = True
     application.Run()
Esempio n. 3
0
 def start_app(self):
     """ function called from __init__
         display the window
     """
     if self.main_form.ready and self.modelview.ready:
         
         if 'Autodesk' not in hostname:
             # ok in standalone, but makes Revit crash
             self.app = Application()  
             self.app.DispatcherUnhandledException += self.on_run_exception
             self.app.Run(self.main_form)
         else:
             self.main_form.Show()  # ShowDialog
     else:
         ok_error('Sorry, a component cannot start')
Esempio n. 4
0
def run_wpf_gui():
    import wpf

    from System.Windows import Application, Window
    from gui.windows.MainWindow import MainWindow

    Application().Run(MainWindow())
Esempio n. 5
0
def application_main():
    global icon

    icon = NotifyIcon()
    icon.Text = "Hello World"
    icon.Icon = Icon(SystemIcons.Application, 40, 40)
    icon.Visible = True

    Application().Run()
Esempio n. 6
0
 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 dialog():
    class MyWindow(Window):
        def __init__(self, vars):
            wpf.LoadComponent(self, thisdir+'/wpf_test.xaml')
        def OnClosing(self, event):
            vars[0] = self.tb1.Text
            vars[1] = self.tb2.Text
    vars = [None, None]
    Application().Run(MyWindow(vars))
    return tuple(vars)
Esempio n. 8
0
    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)
Esempio n. 9
0
def show_log_window(log):
    class MyWindow(Window):
        def __init__(self, log):
            wpf.LoadComponent(self, gui_path + 'log_window.xaml')
            self.logbox.Text = log

        def OnClosing(self, event):
            self.Topmost = False

    MyWindow.Topmost = True
    Application().Run(MyWindow(log))
    MyWindow.Topmost = True
Esempio n. 10
0
 def Run(self):
     self.box = EzVBox()
     if self.menu: self.box.AddItem(EzMenuBar(self.menu), expand=False)
     if self.tool:
         for tool in EzToolBar(self.tool):
             self.box.AddItem(tool, expand=False)
     if self.content: self.box.AddItem(EzLayout(self.content), expand=True)
     if self.status:
         self.box.AddItem(EzStatusBar(self.status), expand=False)
     self.Content = self.box.ctrl
     if self.createdHandler: self.createdHandler()
     Application().Run(self)
Esempio n. 11
0
# -*- 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())
Esempio n. 12
0
        return self._size

    @size.setter
    def size(self, value):
        self._size = value
        print 'Size changed to %r' % self.size


class TestWPF(object):

    def __init__(self):
        self._vm = ViewModel()
        self.root = XamlReader.Parse(XAML_str)
        self.DataPanel.DataContext = self._vm
        self.Button.Click += self.OnClick
        
    def OnClick(self, sender, event):
        # must be string to two-way binding work correctly
        self._vm.size = '10'

    def __getattr__(self, name):
        # provides easy access to XAML elements (e.g. self.Button)
        return self.root.FindName(name)


if __name__ == '__main__':
    tw = TestWPF()
    app = Application()
    app.Run(tw.root)

Esempio n. 13
0
from System.Windows.Controls import (Button, Label, StackPanel)

from System.Windows.Media.Effects import DropShadowBitmapEffect

win = Window(Title="Welcome to IronPython", Width=450)
win.SizeToContent = SizeToContent.Height

stack = StackPanel()
stack.Margin = Thickness(15)
win.Content = stack

button = Button(Content="Push Me",
                FontSize=24,
                BitmapEffect=DropShadowBitmapEffect())


def onClick(sender, event):
    msg = Label()
    msg.FontSize = 36
    msg.Content = 'Welcome to IronPython!'

    stack.Children.Add(msg)


button.Click += onClick
stack.Children.Add(button)

app = Application()
app.Run(win)
Esempio n. 14
0
def start():
	global idu
	app = Application()
	idu = IronDiskUsage(app)
	app.Run()
Esempio n. 15
0
		<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
Esempio n. 16
0
import wpf
from System.Windows import Application, Window
from WindowMain import WindowMain
import sys
import argparse

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument("-p",
                        "--p",
                        type=int,
                        help="Port number to connect to by default")
    parser.add_argument("-host",
                        "--host",
                        type=str,
                        help="Host IP to connect to by default")
    parser.add_argument("-t",
                        "--test",
                        type=str,
                        help="File to read and run test form")
    args = parser.parse_args()

    Application().Run(
        WindowMain(host=args.host, port=args.p, testFile=args.test))
Esempio n. 17
0
    def _thread(cls, xaml=None):
        app = cls()
        app._load(xaml)

        Application().Run(app.window)
Esempio n. 18
0
def RunApp(rootElement):
    app = Application()
    app.Run(rootElement)
Esempio n. 19
0
    def _showError(self, error):
        self.errorLabel.Content = error
        self.errorLabel.Visibility = Visibility.Visible

    def _hideError(self):
        self.errorLabel.Visibility = Visibility.Collapsed

    def _showToss(self, won, toss):
        self.resultLabel.Content = toss
        self.resultLabel.Foreground = Brushes.Green if won else Brushes.Red

    def _showBankroll(self):
        self.bankrollLabel.Content = str(self.game.bankroll)

    def _maybeEndGame(self):
        if self.game.bankroll <= 0:
            self._showToss(False, 'X')

            self.flipButton.IsEnabled = False
            self.wagerBox.IsEnabled = False
            self.guessHeadsButton.IsEnabled = False
            self.guessTailsButton.IsEnabled = False

    def wagerBox_GotFocus(self, sender, e):
        sender.Foreground = Brushes.Black


if __name__ == '__main__':
    Application().Run(WpfSampleWindow())
Esempio n. 20
0
                    #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()
Esempio n. 21
0
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)
Esempio n. 22
0
class Manager(object):
    """ Main control on the app
        init all components and launch the form 
        handle the exit and saves some convenient settings
    """
    def __init__(self):
        super(Manager, self).__init__()
        logger.info('iph starting in {}'.format(hostname))
        self.app = None
        self.mode_dbg = False
        self.is_revit_host = 'Autodesk' in hostname
        self.modelview = None
        self.main_form = None
        self.settings_file = os.path.join(DIR_PATH, 'settings.json')
        self.settings = load_settings_from_file(self.settings_file)

    def init_components(self, target=None):
        """ init modelview and main form
        """
        logger.debug('Loading Modelview...')
        self.modelview = ModelView(self)
        if self.mode_dbg:
            self.modelview.debug(self)

        logger.debug('Loading UI...')
        if self.modelview.ready:
            self.main_form = MainForm(self)
            self.modelview.init(target)
        else:
            ok_error('Sorry, modelview cannot start')

    def start_app(self):
        """ function called from __init__
            display the window
        """
        if self.main_form.ready and self.modelview.ready:
            
            if 'Autodesk' not in hostname:
                # ok in standalone, but makes Revit crash
                self.app = Application()  
                self.app.DispatcherUnhandledException += self.on_run_exception
                self.app.Run(self.main_form)
            else:
                self.main_form.Show()  # ShowDialog
        else:
            ok_error('Sorry, a component cannot start')

    def exit_app(self):
        """ "handle" the exit, TODO some cleanup...
        """
        
        if self.mode_dbg:
            self.log_out()
        # self.Dispatcher.Invoke(lambda *_: self.win.Close())

        if self.save_settings_and_quit():  # else cancel by user

            if not self.is_revit_host:
                logger.debug('app exit (standalone)')
                self.app.DispatcherUnhandledException -= self.on_run_exception
                Application.Current.Shutdown()
                # ok in standalone, but makes Revit crash

            else:
                logger.debug('app exit (revit context)')
                self.main_form.Close()  # crash in standalone

            iph.SESSION = None

    def save_settings_and_quit(self):
        """ check if changes in settings and ask for save or cancel
            window pos is saved anyway
        """
        _exit = True
        try:
            self.settings['window']['Left'] = self.main_form.Left
            self.settings['window']['Top'] = self.main_form.Top
            self.settings['window']['Width'] = self.main_form.Width
            self.settings['window']['Height'] = self.main_form.Height

            new_targets = [api.get_json()
                           for api in self.modelview.treemanager.list_options]
            
            if not new_targets == self.settings['api_set']:
                
                action_user = ok_no_cancel('Save the targets changes ?')
                if action_user:
                    self.settings['api_set'] = new_targets

                elif action_user is None:
                    _exit = False
            if _exit:
                save_settings_to_file(self.settings, self.settings_file)
            
        except Exception as error:
            logger.error('save_settings failed :\n' + str(error))

        finally:
            return _exit

    def log_out(self):
        """ logs the 100 last errors stacked in logger when app is closing
        """
        logs = logger.errors[:100]
        if logs:
            import time
            ldate = time.strftime('%d %b %Y %X')
            with open(os.path.join(DIR_PATH, 'logs', 'session.log'), 'w') as fileout:
                fileout.write(ldate+'\n')
                for er in logs:
                    fileout.write(str(er)+'\n')

    #                               #
    #             EVENTS
    #                               #
    def on_run_exception(self, sender, event):
        """
            catch runtime exception when running alone
        """
        msg = str(event.Exception.Message)
        ok_error(msg)
        logger.error('Runtime exception :\n' + msg)
        event.Handled = True

    def __repr__(self):
        return 'Main App Manager (Debug: {})'.format(self.mode_dbg)
Esempio n. 23
0
import System.Windows
import clr
import _wpf
from Level import *
from Easy import *

clr.AddReference("System.Windows.Forms")
clr.AddReference("PresentationCore")
clr.AddReference("System.Xaml")
clr.AddReference("WindowsBase")
clr.AddReference("PresentationFramework")
clr.AddReference('IronPython.wpf')
from System.Windows import Application, Window
from System.ComponentModel import *


class Hangman(Window):
    def __init__(self):
        self.ui = _wpf.LoadComponent(self, 'Hangman.xaml')

    def Start_Click(self, sender, e):
        form1 = Level()
        form1.Show()
        self.Close()


if __name__ == '__main__':
    Application().Run(Hangman())
Esempio n. 24
0
# -*- coding: utf-8 -*-

"""
Data Binding Example.

* Run this file.
"""

import wpf
from System.Windows import Application, Window

class Example_xaml_main(Window):

    def __init__(self):
        wpf.LoadComponent(self, 'example_xaml_view.xaml')
        print('Init window.')
    
    def button1_Click(self, sender, e):
        ans = float(self.textBox1.Text) + float(self.textBox2.Text)
        self.textBox3.Text = str(ans)

if __name__ == '__main__':
    Application().Run(Example_xaml_main())
def run_form():
    Application().Run(MyWindow())
    time.sleep(1)
Esempio n. 26
0
 def create():
   Application().Run(MacronWindow(config))
Esempio n. 27
0
                j = int(self.jumlah2.Text)
                jml = str(j * 120000)

            elif self.combo2.Text == self.combo2.Items.GetItemAt(4).ToString():
                jenis = "LOGO BOX-WHITE-SS"
                harga = "120000"

                j = int(self.jumlah2.Text)
                jml = str(j * 120000)

            #menentukan ukuran
            if self.rb11.IsChecked:
                ukuran = "S"
            elif self.rb22.IsChecked:
                ukuran = "M"
            elif self.rb33.IsChecked:
                ukuran = "L"
            elif self.rb44.IsChecked:
                ukuran = "XL"

            self.hitung.append(int(jml))
            self.barang.append(int(j))
            stack.append(jenis + " (" + ukuran + ") x" + y + " -- Rp." + jml)
            self.list1.Items.Add(stack[n])
            n = n + 1

        pass
if __name__ == '__main__':
    Application().Run(MyWindow([], []))
Esempio n. 28
0
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())
Esempio n. 29
0
        if 'C' in param:
            self.inputText = ''
            return
        if self.inputText is '':
            self.prevOperator = param
            return
        if self.outputText is '':
            self.outputText = 0
        if self.prevOperator == '/' and float(self.inputText) == 0:
            self.inputText = ''
            self.outputText = ''
            return

        self.outputNumber = self.operators[self.prevOperator](
            self.outputNumber, self.inputText)
        self.prevOperator = param
        self.inputText = ''
        self.outputText = str(float(self.outputNumber))


class MyWindow(Window):
    def __init__(self):
        wpf.LoadComponent(
            self,
            os.path.join(os.path.dirname(__file__), 'Clac_Ironpython.xaml'))
        self.DataContext = MyViewModel()


if __name__ == '__main__':
    Application().Run(MyWindow())
Esempio n. 30
0
            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'))