我有以下 python 代码将处理过的单词写入 excel 文件。字数约7729
From openpyxl import *
book=Workbook ()
sheet=book.active
sheet.title="test"
for x in range (7729):
sheet.cell (row=1,column=x+1).value=x
book.save ('test.xlsx')
Run Code Online (Sandbox Code Playgroud)
这是我使用的代码的样子,但是当我运行它时,它给了我一个错误
openpyxl.utils.exceptions.IllegalCharacterError
Run Code Online (Sandbox Code Playgroud)
这是我第一次使用这个模块,我很感激任何帮助。
我知道一种放置tkinter窗口的方法可以说在中间
from tkinter import *
root=Tk()
w=350
h=285
ws=root.winfo_screenwidth()
hs=root.winfo_screenheight()
x=(ws/2)-(w/2)
y=(hs/2)-(h/2)
root.geometry('%dx%d+%d+%d'%(w,h,x,y))
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,tkinter窗口将在中间弹出,高度为285,宽度为350。但是,如果我添加了太多小部件,则高度285可能不够。堡垒的例子可以说我们添加了这段代码
for x in range(50):
Label(root,text=x).pack()
Run Code Online (Sandbox Code Playgroud)
因为我将高度设置为固定数字285,所以只有前13个数字将在窗口中。
所以我的问题是,有没有一种方法可以将tkinter窗口放置在屏幕中间而无需设置高度和宽度,我的意思是,如果高度和宽度未设置为固定值,则该窗口将继续自动扩展。例如,在下面的代码中,它将自动扩展,除非窗口不在中间。
from tkinter import *
win=Tk()
for x in range(50):
Label(win,text=x).pack()
Run Code Online (Sandbox Code Playgroud) 我有一组具有类似接口的反应本机组件。接口中重要的方法是run方法。用户可以通过按每个组件的操作按钮或按父级中的操作按钮来执行此 run 方法,这将使用其 ref 迭代每个类似的组件并调用 run 方法。这是设置的简化版本。
const Test1 = forwardRef((props, ref) => {
const [importantState, setimportantState] = useState('initial')
useImperativeHandle(ref, () => ({
run: run,
}))
const run = async () => {
// This function will open a modal
// where users will eventually change the important state
openInteractionModal()
// The idea of this promiss is to settle when the users
// eventually change the importantState thorugh thier interaction
// It does so by checking the state every 100 …
Run Code Online (Sandbox Code Playgroud) python ×2
closures ×1
javascript ×1
openpyxl ×1
promise ×1
react-native ×1
reactjs ×1
tkinter ×1