Python 导致程序延迟的tkinter主题
在tkinter中,框架由多个迷你长画布(包含一些文本和按钮)组成,可以使用滚动条上下滚动。我还使用tkinter主题使我的gui看起来很漂亮。但由于某种原因,当我在gui中添加时,框架在上下滚动时会有一点滞后,就像画布相互碰撞一样,他们要解决这个问题吗 下面是它在不滚动的情况下的外观 下面是它在滚动时的外观 这是密码Python 导致程序延迟的tkinter主题,python,oop,tkinter,pycharm,themes,Python,Oop,Tkinter,Pycharm,Themes,在tkinter中,框架由多个迷你长画布(包含一些文本和按钮)组成,可以使用滚动条上下滚动。我还使用tkinter主题使我的gui看起来很漂亮。但由于某种原因,当我在gui中添加时,框架在上下滚动时会有一点滞后,就像画布相互碰撞一样,他们要解决这个问题吗 下面是它在不滚动的情况下的外观 下面是它在滚动时的外观 这是密码 from tkinter import * from ttkthemes.themed_tk import ThemedTk from tkinter import * fr
from tkinter import *
from ttkthemes.themed_tk import ThemedTk
from tkinter import *
from tkinter.ttk import *
import tkinter as tk
from tkinter import ttk
class tkinterprogram(ThemedTk):
def __init__(self, *args, **kwargs):
ThemedTk.__init__(self, *args, **kwargs)
container = tk.Frame(self)
container.pack(side="top", fill="both", expand=True)
container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1)
self.frames = {}
for F in (StartPage,Task):
frame = F(container, self)
self.frames[F] = frame
frame.grid(row=0, column=0, sticky="nsew")
self.show_frame(StartPage)
def show_frame(self, cont):
frame = self.frames[cont]
frame.tkraise()
frame.winfo_toplevel().geometry("1024x720")
class StartPage(tk.Frame):
def __init__(self, parent, controller):
ttk.Frame.__init__(self, parent)
l = Canvas(self, bg='#4A4949')
l.pack(fill='both', expand='True')
global canvascon
canvascon = Canvas(l, height=400,width=1500,bg='#4A4949',highlightthickness=0)
global frame2
frame2 = Frame(canvascon)
global myscrollbar
myscrollbar = Scrollbar(l, orient="vertical",command=canvascon.yview)
canvascon.create_window((0, 0), window=frame2,width=15000,anchor='nw')
canvascon.place(x=25,y=150,relheight=0.558,relwidth=0.87)
myscrollbar.pack(side=RIGHT, fill=Y,pady=25)
Button(l,text='go',command=lambda: meth()).pack()
def meth():
for count in range(25):
c = Canvas(frame2, height=50, bg="#1E2133",highlightthickness=5,highlightbackground='#4A4949')
lab = tk.Label(frame2, text='running',bg='#1E2133',fg='#EFEFEF')
lab_window = c.create_window(10,15, window=lab,anchor=tk.NW)
stop = tk.Button(frame2, text='STOP')
stop_window = c.create_window(200, 15, window=stop, anchor=tk.NW)
c.pack(fill=X,expand=True)
frame2.update() # update frame2 height so it's no longer 0 ( height is 0 when it has just been created )
canvascon.configure(yscrollcommand=myscrollbar.set, scrollregion="0 0 0 %s" % frame2.winfo_height())
class Task(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
app = tkinterprogram()
app.get_themes()
app.set_theme('scidgrey')
app.mainloop()
提前谢谢你的帮助