Example #1
0
def create_window(window):
    def create():
        browser = BrowserView.BrowserForm(window)
        BrowserView.instances[window.uid] = browser

        if not window.hidden:
            browser.Show()

        _main_window_created.set()

        if window.uid == "master":
            app.Run()

    app = WinForms.Application

    if window.uid == "master":
        if sys.getwindowsversion().major >= 6:
            windll.user32.SetProcessDPIAware()

        CEF.init(window)

        app.EnableVisualStyles()
        app.SetCompatibleTextRenderingDefault(False)
        thread = Thread(ThreadStart(create))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        thread.Join()

    else:
        _main_window_created.wait()
        i = list(BrowserView.instances.values())[0]  # arbitrary instance
        i.Invoke(Func[Type](create))
Example #2
0
def create_window(uid, title, url, width, height, resizable, fullscreen,
                  min_size, confirm_quit, background_color, debug, js_api,
                  text_select, webview_ready):
    def create():
        window = BrowserView.BrowserForm(uid, title, url, width, height,
                                         resizable, fullscreen, min_size,
                                         confirm_quit, background_color, debug,
                                         js_api, text_select, webview_ready)
        BrowserView.instances[uid] = window
        window.Show()

        if uid == 'master':
            app.Run()

    webview_ready.clear()
    app = WinForms.Application

    if uid == 'master':
        set_ie_mode()
        if sys.getwindowsversion().major >= 6:
            windll.user32.SetProcessDPIAware()

        app.EnableVisualStyles()
        app.SetCompatibleTextRenderingDefault(False)

        thread = Thread(ThreadStart(create))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        thread.Join()
    else:
        i = list(BrowserView.instances.values())[0]  # arbitrary instance
        i.Invoke(Func[Type](create))
Example #3
0
def create_window(config):
  def create():
    Application().Run(MacronWindow(config))
  
  thread = Thread(ThreadStart(create))
  thread.SetApartmentState(ApartmentState.STA)
  thread.Start()
  thread.Join()
Example #4
0
    def run(cls, xaml=None):
        '''调用 run 函数启动窗口程序

        :param xaml: xaml 文件路径或者 xaml 格式的 xml 字符串
        '''
        thread = Thread(ParameterizedThreadStart(cls._thread))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start(xaml)
        thread.Join()
Example #5
0
def run_debugger(py_file):
    if Thread.CurrentThread.GetApartmentState() == ApartmentState.STA:
        t = Thread(ParameterizedThreadStart(run_debugger))
        t.SetApartmentState(ApartmentState.MTA)
        t.Start(py_file)
        t.Join()
    else:
        p = IPyDebugProcess()
        p.run(py_file)
Example #6
0
    def __init__(self, API_key=''):
        def start():
            self.browser = AuthDialog.FormBrowser(API_key)
            WinForms.Application.Run(self.browser)

        # Create a new thread to run the process
        thread = Thread(ThreadStart(start))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        thread.Join()
Example #7
0
def open_tkinter_dialog(title, initial_folder):
    out_queue = Queue()
    out_queue.Enqueue(title)
    out_queue.Enqueue(initial_folder)
    start = ParameterizedThreadStart(tkinter_dialog_thread)
    thread = Thread(start)
    thread.SetApartmentState(ApartmentState.STA)
    thread.Start(out_queue)
    thread.Join()
    final_result = out_queue.Dequeue()
    return final_result[0], final_result[1]
Example #8
0
    def show(self):
        def start():
            self.browser = BrowserView.BrowserForm(
                self.title, self.url, self.width, self.height, self.resizable,
                self.fullscreen, self.min_size, self.webview_ready)
            app = WinForms.Application
            app.Run(self.browser)

        thread = Thread(ThreadStart(start))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        thread.Join()
Example #9
0
    def show(self):
        def start():
            app = WinForms.Application
            self.browser = BrowserView.BrowserForm(
                self.title, self.url, self.width, self.height, self.resizable,
                self.fullscreen, self.min_size, self.confirm_quit,
                self.background_color, self.debug, self.js_api,
                self.webview_ready)

            app.Run(self.browser)

        thread = Thread(ThreadStart(start))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        thread.Join()
Example #10
0
def create_window(window):
    def create():
        browser = BrowserView.BrowserForm(window)
        BrowserView.instances[window.uid] = browser

        if not window.hidden:
            browser.Show()

        _main_window_created.set()

        if window.uid == 'master':
            app.Run()

    app = WinForms.Application

    if window.uid == 'master':
        if not is_edge and not is_cef:
            _set_ie_mode()

        if sys.getwindowsversion().major >= 6:
            windll.user32.SetProcessDPIAware()

        if is_cef:
            CEF.init(window)

        app.EnableVisualStyles()
        app.SetCompatibleTextRenderingDefault(False)
        thread = Thread(ThreadStart(create))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        if not _multiprocessing:
            thread.Join()
        else:
            p = Process()
            p.join = thread.Join
            p.is_alive = thread.IsAlive
            p.name = thread.Name
            p.kill = thread.Abort
            return thread

    else:
        _main_window_created.wait()
        i = list(BrowserView.instances.values())[0]     # arbitrary instance
        i.Invoke(Func[Type](create))
Example #11
0
    def show(self):
        def start():
            if sys.getwindowsversion().major >= 6:
                windll.user32.SetProcessDPIAware()

            app = WinForms.Application
            app.EnableVisualStyles()
            app.SetCompatibleTextRenderingDefault(False)

            self.browser = BrowserView.BrowserForm(
                self.title, self.url, self.width, self.height, self.resizable,
                self.fullscreen, self.min_size, self.confirm_quit,
                self.webview_ready)
            app.Run(self.browser)

        thread = Thread(ThreadStart(start))
        thread.SetApartmentState(ApartmentState.STA)
        thread.Start()
        thread.Join()
Example #12
0
def getChoicesFromList(choiceList=None,
                       prompt=DEFAULT_PROMPT,
                       title=DEFAULT_TITLE,
                       alignChoices=None):
    """
    Ask user to enter their choices from the list and return it.
  
    choiceList should be a list of strings
    """
    if alignChoices is None:
        alignChoices = 'left'

    choiceData = ChooseFromListModel(choiceList=choiceList,
                                     prompt=prompt,
                                     title=title,
                                     alignChoices=alignChoices)

    thread = Thread(ThreadStart(lambda: ChooseFromListView(choiceData)))
    thread.SetApartmentState(ApartmentState.STA)
    thread.Start()
    thread.Join()

    return choiceData.choices
Example #13
0
def main():
    thread = Thread(ThreadStart(app_thread))
    thread.SetApartmentState(ApartmentState.STA)
    thread.Start()
    thread.Join()
Example #14
0
                       ('raiseAnchor', 'Raise Anchor'),
                       ('dropAnchor', 'Drop Anchor'),
                       ('turnLeft', 'Turn Left'), ('turnRight', 'Turn Right'),
                       ('start', 'Start')]
        self.setEvents()

    def setEvents(self):
        for x in self.events:
            btn = self.Content.FindName(x[0])
            btn.Click += self.clickButton

    def clickButton(self, sender, event):
        for x in self.events:
            if x[0] == event.Source.Name:
                Msg(x[1])


def ShowWindow():
    try:
        c = XamlWindow()
        c.ShowDialog()
    except Exception as e:
        # if you don't catch these, an exception will likely take down CUO/CA
        print e


t = Thread(ThreadStart(ShowWindow))
t.SetApartmentState(ApartmentState.STA)
t.Start()
t.Join()
Example #15
0
clr.AddReference(r"wpf\PresentationFramework")
from System.Drawing import Icon, SystemIcons
from System.Windows import Application
from System.Windows.Forms import ContextMenu, NotifyIcon
from System.Threading import Thread, ThreadStart, ApartmentState

icon = NotifyIcon()


def application_main():
    global icon

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

    Application().Run()


try:
    thread = Thread(ThreadStart(application_main))
    thread.SetApartmentState(ApartmentState.STA)
    thread.Start()

    input()
finally:
    if icon is not None: icon.Dispose()
    if thread is not None: thread.Interrupt()
Example #16
0
 def run_efsharp_thread(self, runner):
     from System.Threading import Thread, ThreadStart, ApartmentState
     thread = Thread(ThreadStart(runner))
     thread.SetApartmentState(ApartmentState.STA)
     thread.Start()
     return thread