如果这是我的代码:
from tkinter import *
class Program:
def __init__(self):
self.tk = Tk()
self.tk.attributes("-topmost", 1)
self.canvas = Canvas(self.tk, height=500, width=500, highlightthickness=0)
self.canvas.pack(fill="both", expand=1)
self.width = 500
self.height = 500
self.tk.bind("<Configure>", self.resize)
self.input = Entry(self.tk)
self.input.pack(fill="x", expand=1)
self.button = Button(self.tk, text="Start!", command=self.pressed)
self.button.pack(fill="x", expand=1)
self.pressed = 0
self.start = time()
def mainloop(self):
while 1:
self.canvas.delete("all")
self.canvas.create_rectangle(0, 0, self.width, self.height, fill="#4dffff", width=0)
self.tk.update()
def pressed(self):
self.pressed = 1
def resize(self, event):
self.width = event.width
self.height = event.height
Program().mainloop()
我如何更改代码以保持画布(我的意思是它的彩色部分)覆盖Tk()窗口的未覆盖部分的结果?
答案 0 :(得分:0)
你有很多错误和/或不必要的代码导致各种各样的问题。归结为你不应该创建自己的static_assert(sizeof(productData<int>)==sizeof(productDataAsArray<int>::arr), "padding/alignment inconsistency");
static_assert(sizeof(productData<char>)==sizeof(productDataAsArray<char>::arr), "padding/alignment inconsistency");
static_assert(sizeof(productData<double>)==sizeof(productDataAsArray<double>::arr), "padding/alignment inconsistency");
static_assert(sizeof(productData<char*>)==sizeof(productDataAsArray<char*>::arr), "padding/alignment inconsistency");
class alignas(16) testClass {
int x;
int y;
virtual void test() {};
};
static_assert(sizeof(productData<testClass>)==sizeof(productDataAsArray<testClass>::arr), "padding/alignment inconsistency");
。使用task build \
{
}
提供的那个,除非您深刻理解为什么会这样。
在尝试执行任何其他操作之前,请先使用此代码:
mainloop