小编Sam*_*Sam的帖子

Tkinter 启动画面和主循环外的多处理

我已经实现了一个启动画面,当我的应用程序在启动时从远程云存储加载数据库时显示。启动画面通过调用 .update() 保持活动状态(上面有一个进度条),并在单独的加载过程结束后销毁。在此之后,主循环启动并且应用程序正常运行。

下面的代码曾经在我的 Mac 上使用 python 3.6 和 tcl/tk 8.5.9 运行良好。但是,在更新到 Sierra 之后,我被迫将 tk 更新到 ActiveTcl 8.5.18。现在,在单独的进程完成之前不会显示启动画面,但随后会与根窗口一起出现并停留在屏幕上(即使调用了它的 .destroy() 方法)。

import tkinter as tk
import tkinter.ttk as ttk
import multiprocessing
import time


class SplashScreen(tk.Toplevel):
    def __init__(self, root):
        tk.Toplevel.__init__(self, root)
        self.geometry('375x375')
        self.overrideredirect(True)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        self.label = ttk.Label(self, text='My Splashscreen', anchor='center')
        self.label.grid(column=0, row=0, sticky='nswe')

        self.center_splash_screen()
        print('initialized splash')

    def center_splash_screen(self):
        w = self.winfo_screenwidth()
        h = self.winfo_screenheight()
        x = w / 2 - 375 / 2
        y = h / 2 - …
Run Code Online (Sandbox Code Playgroud)

python tk-toolkit tkinter splash-screen multiprocessing

5
推荐指数
1
解决办法
1579
查看次数

WScript.Shell 运行带有空格的脚本和来自 VBA 的参数

我需要使用 WScript.Shell 从 VBA 调用脚本 (R)。文件路径包含空格。此外,还向脚本传递了一系列参数,其中一些还包含空格。

我已经在路径、参数甚至整个字符串周围尝试了所有可能的引号和双引号组合(特别是这里的)。当需要传递参数时,似乎没有任何工作(我要么在命令行中收到“C:\Program” not识别“-或”invalid-syntax“-错误)。

Option Explicit
Private Const QUOTE As String = """"

Sub test()
    Dim WS_Shell As Object
    Set WS_Shell = VBA.CreateObject("WScript.Shell")
    Dim err_code As Long

    Dim path As String
    Dim arg_1 As String
    Dim arg_2_with_spaces As String

    Dim complete_cmd_str As String

    path = "C:\Program Files\R\R-3.3.2\bin\Rscript.exe"
    arg_1 = "F:\path\to\my\script.R"
    arg_2_with_spaces = "A string-arg with spaces"

    complete_cmd_str = "cmd.exe /K " & QUOTE & path & QUOTE & " " _
                    & QUOTE & …
Run Code Online (Sandbox Code Playgroud)

shell command-line vba rscript

3
推荐指数
1
解决办法
4112
查看次数