pygame 和 ttk 的问题
本帖最后由 cjjJasonchen 于 2023-7-21 10:30 编辑<blockquote><div class="blockcode"><blockquote>""" 这个版本是专门用来体验的,如果要追求性能请调节SpurtFire的timer"""
import pygame
import sys
import random
import ttkbootstrap as tk
import ttkbootstrap.constants as tkc
from pygame.locals import *
class Particle(pygame.sprite.Sprite):
def __init__(self,color=(255,255,255),position=,radius=0,speed=,time=-1):
super().__init__()
self.position = position
self.image = pygame.Surface().convert_alpha()
self.rect = self.image.get_rect()
self.rect.centerx,self.rect.centery = position,position
self.color = color
self.radius = radius
self.speed = speed
self.time = time
pygame.draw.rect(self.image,(0,0,0,0),)
def update(self):
self.time -= 1
self.rect.centerx += self.speed
self.rect.centery += self.speed
pygame.draw.circle(self.image,
color=self.color,
center=(self.radius,self.radius),
radius=self.radius)
class SpurtFire(Particle):
def __init__(self, position,
color=,
time=,
speed=[[-2,2],[-2,-2]],
num = 4,
radius=,
burn_time=600,
timer = 0):
self.particles = pygame.sprite.Group()
self.position = position
self.color = color
self.time = time
self.speed = speed
self.num = num
self.radius = radius
self.burn_time = burn_time
self.timer0 = timer
self.timer = timer
def update(self):
self.particles.update()
for i in self.particles:
if i.time == 0:
self.particles.remove(i)
i.speed = ,self.speed),random.randint(self.speed,self.speed)]
i.color = self.color/self.time*i.time
if self.timer == 0:
self.timer = self.timer0
self.create_particle()
else:
self.timer -= 1
self.burn_time -= 1
def draw(self,screen):
self.particles.draw(screen)
def create_particle(self):
for i in range(self.num):
self.particles.add(Particle(color=self.color.copy(),
position=,self.position],
radius=random.randint(self.radius,self.radius),
speed=,self.speed),random.randint(self.speed,self.speed)],
time = random.randint(self.time,self.time)
)
)
def set_up():
color = {"outside":,
"inside":,
"core":,
"bg":}
num_list =
size =
root = tk.Window(themename="superhero")
root.geometry("700x700+300+10")
tk.Label(root, text="请输入外焰、內焰和焰芯的颜色",font=("楷体", 30)).pack(padx=5,pady=10)
key_l = tk.Label(root, text="点它!——> (红)(绿)(蓝)(透明度) <——点它!",font=("楷体", 15))
key_l.pack(padx = 5,pady = 5)
frame1 = tk.Frame(root,width = 400,height = 300)
frame1.pack(padx=5,pady=5)
tk.Label(frame1, text="",font=("楷体", 40)).grid(row=0,column=0)
# 外焰
tk.Label(frame1, text="外焰颜色(RGBA):(",font=("楷体", 20)).grid(row=1,column=0)
outer_e1 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e1.grid(row=1,column=1)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=1,column=2)
outer_e2 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e2.grid(row=1,column=3)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=1,column=4)
outer_e3 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e3.grid(row=1,column=5)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=1,column=6)
outer_e4 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e4.grid(row=1,column=7)
tk.Label(frame1, text=")",font=("楷体", 20)).grid(row=1,column=8)
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=2,column=0)
# 内焰
tk.Label(frame1, text="内焰颜色(RGBA):(",font=("楷体", 20)).grid(row=3,column=0)
inside_e1 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e1.grid(row=3,column=1)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=3,column=2)
inside_e2 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e2.grid(row=3,column=3)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=3,column=4)
inside_e3 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e3.grid(row=3,column=5)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=3,column=6)
inside_e4 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e4.grid(row=3,column=7)
tk.Label(frame1, text=")",font=("楷体", 20)).grid(row=3,column=8)
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=4,column=0)
# 焰芯
tk.Label(frame1, text="焰芯颜色(RGBA):(",font=("楷体", 20)).grid(row=5,column=0)
core_e1 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e1.grid(row=5,column=1)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=5,column=2)
core_e2 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e2.grid(row=5,column=3)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=5,column=4)
core_e3 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e3.grid(row=5,column=5)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=5,column=6)
core_e4 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e4.grid(row=5,column=7)
tk.Label(frame1, text=")",font=("楷体", 20)).grid(row=5,column=8)
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=6,column=0)
# 粒子数量
num = tk.IntVar()
num.set(50)
particel_num = tk.StringVar()
particel_num.set(f"粒子数量:外焰{int(num.get())}、內焰{int(num.get()/2)}、焰芯{int(num.get()/4)}")
tk.Label(frame1, textvariable=particel_num, font=("楷体", 20)).grid(row=7, column=0,columnspan=7)
tk.Label(frame1, text="少",style="primary", font=("楷体", 15)).grid(row=8,column=0)
tk.Label(frame1, text="多",style="primary", font=("楷体", 15)).grid(row=8,column=7)
def change_particle_num(event):
particel_num.set(f"粒子数量:外焰{int(num.get())}、內焰{int(num.get()/2)}、焰芯{int(num.get()/4)}")
num_s = tk.Scale(frame1, from_=10, to=80, length=300, variable=num,command=change_particle_num)
num_s.grid(row=8,column=0,columnspan=7,padx=5,pady=5,sticky="e")
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=9,column=0)
# 粒子大小
tk.Label(frame1, text="粒子数量:", font=("楷体", 20)).grid(row=10, column=0)
tk.Label(frame1, text="最小:",style="primary", font=("楷体", 15)).grid(row=10,column=1)
tk.Label(frame1, text="最大:",style="primary", font=("楷体", 15)).grid(row=10,column=4)
size_e1 = tk.Entry(frame1, width=3,font=("楷体", 15))
size_e1.grid(row=10,column=2,padx=5,pady=5,sticky="e")
size_e2 = tk.Entry(frame1, width=3,font=("楷体", 15))
size_e2.grid(row=10,column=5,padx=5,pady=5)
# 背景
tk.Label(frame1, text="背景\n更改\n |\n﹀",style="primary").grid(row=0,column=9)
tk.Button(frame1, text="白",style="light").grid(row=10,column=9,padx=10)
tk.Button(frame1, text="黑",style="secondary").grid(row=1,column=9,padx=10)
bg_s = tk.Scale(frame1, from_=0, to=255, orient=tk.VERTICAL, length=300,style="light")
bg_s.grid(row=1,rowspan=10,column=9,padx=30,pady=10)
# 确定
def return_color():
try:
color["outside"] =
color["inside"] =
color["core"] =
color["bg"] =
num_list=int(num_s.get())
num_list=int(num_s.get()/2)
num_list=int(num_s.get()/4)
size=int(size_e1.get())
size=int(size_e2.get())
except:
pass
root.destroy()
tk.Style().configure('my.TButton', font=('楷体', 35))
b = tk.Button(root, text='确定', style='my.TButton',command=return_color)
b.pack(padx=10,pady = 20,fill="both")
root.mainloop()
return color,num_list,size
if __name__ == "__main__":
size = width, height = 800,600
screen = pygame.display.set_mode(size)
pygame.display.set_caption("title")
clock = pygame.time.Clock()
delay = 60 # 延时计时器
time = 0
# 是否全屏
fullscreen = False
screen_change = False
running = True
# 粒子效果列表
particles = []
# 颜色,数量,大小
color = {"outside":,
"inside":,
"core":,
"bg":}
num =
particle_size =
while running:
clock.tick(60)
# 得到鼠标位置
pos = pygame.mouse.get_pos()
# 检测是否全屏
if fullscreen and screen_change:
screen = pygame.display.set_mode(size,FULLSCREEN,HWSURFACE)
screen_change = False
elif screen_change:
screen = pygame.display.set_mode(size)
screen_change = False
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
particles.append(SpurtFire(pos,
color=color["outside"],
time=,
speed=[[-3,+3],[-2,-1]],
num = num,
radius = particle_size,
burn_time = 1200,
timer=0))
particles.append(SpurtFire(pos,
color=color["inside"],
time=,
speed=[[-2,+2],[-2,-1]],
num = num,
radius = particle_size,
burn_time = 1200,
timer=0))
particles.append(SpurtFire(pos,
color=color["core"],
time=,
speed=[[-1,+1],[-2,-1]],
num = num,
radius = particle_size,
burn_time = 1200,
timer=0))
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
sys.exit()
#F11切换全屏
elif event.key == K_F11:
fullscreen = not fullscreen
screen_change = True
elif event.key == K_1:
bg = (255,255,255)
elif event.key == K_2:
bg = (0,0,0)
elif event.key == K_o:
color,num,particle_size=set_up()
pygame.event.clear()
elif event.key == K_c:
particles.clear()
#画背景
screen.fill(color["bg"])
#画 xxxx
for particle in particles:
particle.draw(screen)
#刷新
for particle in particles:
particle.update()
if not particle.burn_time:
particles.remove(particle)
# 刷新界面
pygame.display.update()
点击o会生成一个ttk界面,但是从第二次开始他的风格变得不一样了,看起来像tkinter的默认主题
再补充一下,主题看起来是对的,但是组件的风格看起来不对,上图:
我寻思这可能就是ttk自己有问题啊。。。
看看这个:
import ttkbootstrap as ttk
class A():
def __init__(self):
#input("回车创建窗口")
self.root=ttk.Window()
self.root.geometry("700x700+300+10")
ttk.Button(self.root,text="关闭",command=self.callback).pack()
self.root.mainloop()
print(1)
def callback(self):
self.root.destroy()
if __name__ == "__main__":
A()
A()
明明是一样的,我甚至没有设置主题。。。为什么两次出来的不一样{:10_266:}
import pygame
import sys
import random
import tkinter as tkinter
import ttkbootstrap as tk
import ttkbootstrap.constants as tkc
from pygame.locals import *
from threading import Thread, current_thread
class Particle(pygame.sprite.Sprite):
def __init__(self,color=(255,255,255),position=,radius=0,speed=,time=-1):
super().__init__()
self.position = position
self.image = pygame.Surface().convert_alpha()
self.rect = self.image.get_rect()
self.rect.centerx,self.rect.centery = position,position
self.color = color
self.radius = radius
self.speed = speed
self.time = time
pygame.draw.rect(self.image,(0,0,0,0),)
def update(self):
self.time -= 1
self.rect.centerx += self.speed
self.rect.centery += self.speed
pygame.draw.circle(self.image,
color=self.color,
center=(self.radius,self.radius),
radius=self.radius)
class SpurtFire(Particle):
def __init__(self, position,
color=,
time=,
speed=[[-2,2],[-2,-2]],
num = 4,
radius=,
burn_time=600,
timer = 0):
self.particles = pygame.sprite.Group()
self.position = position
self.color = color
self.time = time
self.speed = speed
self.num = num
self.radius = radius
self.burn_time = burn_time
self.timer0 = timer
self.timer = timer
def update(self):
self.particles.update()
for i in self.particles:
if i.time == 0:
self.particles.remove(i)
i.speed = ,self.speed),random.randint(self.speed,self.speed)]
i.color = self.color/self.time*i.time
if self.timer == 0:
self.timer = self.timer0
self.create_particle()
else:
self.timer -= 1
self.burn_time -= 1
def draw(self,screen):
self.particles.draw(screen)
def create_particle(self):
for i in range(self.num):
self.particles.add(Particle(color=self.color.copy(),
position=,self.position],
radius=random.randint(self.radius,self.radius),
speed=,self.speed),random.randint(self.speed,self.speed)],
time = random.randint(self.time,self.time)
)
)
# 颜色,数量,大小
color = {"outside":,
"inside":,
"core":,
"bg":}
num =
particle_size =
def set_up():
global root
color = {"outside":,
"inside":,
"core":,
"bg":}
num_list =
size =
root = tk.Window(themename="superhero")
root.geometry("700x700+300+10")
root.update()
tk.Label(root, text="请输入外焰、內焰和焰芯的颜色",font=("楷体", 30)).pack(padx=5,pady=10)
key_l = tk.Label(root, text="点它!——> (红)(绿)(蓝)(透明度) <——点它!",font=("楷体", 15))
key_l.pack(padx = 5,pady = 5)
frame1 = tk.Frame(root,width = 400,height = 300)
frame1.pack(padx=5,pady=5)
tk.Label(frame1, text="",font=("楷体", 40)).grid(row=0,column=0)
# 外焰
tk.Label(frame1, text="外焰颜色(RGBA):(",font=("楷体", 20)).grid(row=1,column=0)
outer_e1 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e1.grid(row=1,column=1)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=1,column=2)
outer_e2 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e2.grid(row=1,column=3)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=1,column=4)
outer_e3 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e3.grid(row=1,column=5)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=1,column=6)
outer_e4 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
outer_e4.grid(row=1,column=7)
tk.Label(frame1, text=")",font=("楷体", 20)).grid(row=1,column=8)
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=2,column=0)
# 内焰
tk.Label(frame1, text="内焰颜色(RGBA):(",font=("楷体", 20)).grid(row=3,column=0)
inside_e1 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e1.grid(row=3,column=1)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=3,column=2)
inside_e2 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e2.grid(row=3,column=3)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=3,column=4)
inside_e3 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e3.grid(row=3,column=5)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=3,column=6)
inside_e4 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
inside_e4.grid(row=3,column=7)
tk.Label(frame1, text=")",font=("楷体", 20)).grid(row=3,column=8)
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=4,column=0)
# 焰芯
tk.Label(frame1, text="焰芯颜色(RGBA):(",font=("楷体", 20)).grid(row=5,column=0)
core_e1 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e1.grid(row=5,column=1)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=5,column=2)
core_e2 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e2.grid(row=5,column=3)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=5,column=4)
core_e3 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e3.grid(row=5,column=5)
tk.Label(frame1, text=")(",font=("楷体", 20)).grid(row=5,column=6)
core_e4 = tk.Entry(frame1,width=3,font=("楷体", 20),bootstyle="PRIMARY")
core_e4.grid(row=5,column=7)
tk.Label(frame1, text=")",font=("楷体", 20)).grid(row=5,column=8)
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=6,column=0)
# 粒子数量
num = tk.IntVar()
num.set(50)
particel_num = tk.StringVar()
particel_num.set(f"粒子数量:外焰{int(num.get())}、內焰{int(num.get()/2)}、焰芯{int(num.get()/4)}")
tk.Label(frame1, textvariable=particel_num, font=("楷体", 20)).grid(row=7, column=0,columnspan=7)
tk.Label(frame1, text="少",style="primary", font=("楷体", 15)).grid(row=8,column=0)
tk.Label(frame1, text="多",style="primary", font=("楷体", 15)).grid(row=8,column=7)
def change_particle_num(event):
particel_num.set(f"粒子数量:外焰{int(num.get())}、內焰{int(num.get()/2)}、焰芯{int(num.get()/4)}")
num_s = tk.Scale(frame1, from_=10, to=80, length=300, variable=num,command=change_particle_num)
num_s.grid(row=8,column=0,columnspan=7,padx=5,pady=5,sticky="e")
tk.Label(frame1, text="",font=("楷体", 30)).grid(row=9,column=0)
# 粒子大小
tk.Label(frame1, text="粒子数量:", font=("楷体", 20)).grid(row=10, column=0)
tk.Label(frame1, text="最小:",style="primary", font=("楷体", 15)).grid(row=10,column=1)
tk.Label(frame1, text="最大:",style="primary", font=("楷体", 15)).grid(row=10,column=4)
size_e1 = tk.Entry(frame1, width=3,font=("楷体", 15))
size_e1.grid(row=10,column=2,padx=5,pady=5,sticky="e")
size_e2 = tk.Entry(frame1, width=3,font=("楷体", 15))
size_e2.grid(row=10,column=5,padx=5,pady=5)
# 背景
tk.Label(frame1, text="背景\n更改\n |\n﹀",style="primary").grid(row=0,column=9)
tk.Button(frame1, text="白",style="light").grid(row=10,column=9,padx=10)
tk.Button(frame1, text="黑",style="secondary").grid(row=1,column=9,padx=10)
bg_s = tk.Scale(frame1, from_=0, to=255, orient=tk.VERTICAL, length=300,style="light")
bg_s.grid(row=1,rowspan=10,column=9,padx=30,pady=10)
# 确定
def return_color():
try:
global color,num,particle_size
color["outside"] =
color["inside"] =
color["core"] =
color["bg"] =
num_list=int(num_s.get())
num_list=int(num_s.get()/2)
num_list=int(num_s.get()/4)
size=int(size_e1.get())
size=int(size_e2.get())
# outer_e1.set()
except:
pass
root.withdraw()
# root.update()
# root.protocol("WM_DELETE_WINDOW", on_closing)
# root.destroy()
# if not root:
# return
tk.Style().configure('my.TButton', font=('楷体', 35))
b = tk.Button(root, text='确定', style='my.TButton',command=return_color)
b.pack(padx=10,pady = 20,fill="both")
root.mainloop()
# root_L.mainloop()
if_start = 0
if __name__ == "__main__":
size = width, height = 800,600
screen = pygame.display.set_mode(size)
pygame.display.set_caption("title")
clock = pygame.time.Clock()
delay = 60 # 延时计时器
time = 0
# 是否全屏
fullscreen = False
screen_change = False
running = True
# 粒子效果列表
particles = []
while running:
clock.tick(60)
# 得到鼠标位置
pos = pygame.mouse.get_pos()
# 检测是否全屏
if fullscreen and screen_change:
screen = pygame.display.set_mode(size,FULLSCREEN,HWSURFACE)
screen_change = False
elif screen_change:
screen = pygame.display.set_mode(size)
screen_change = False
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
# root.destroy()
exit()
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
particles.append(SpurtFire(pos,
color=color["outside"],
time=,
speed=[[-3,+3],[-2,-1]],
num = num,
radius = particle_size,
burn_time = 1200,
timer=0))
particles.append(SpurtFire(pos,
color=color["inside"],
time=,
speed=[[-2,+2],[-2,-1]],
num = num,
radius = particle_size,
burn_time = 1200,
timer=0))
particles.append(SpurtFire(pos,
color=color["core"],
time=,
speed=[[-1,+1],[-2,-1]],
num = num,
radius = particle_size,
burn_time = 1200,
timer=0))
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.quit()
root.destroy()
sys.exit()
#F11切换全屏
elif event.key == K_F11:
fullscreen = not fullscreen
screen_change = True
elif event.key == K_1:
bg = (255,255,255)
elif event.key == K_2:
bg = (0,0,0)
elif event.key == K_o:
# color,num,particle_size=thread01=Thread(target=set_up, name="线程1")
if (if_start == 0):
thread01=Thread(target=set_up, name="线程1")
thread01.start()
if_start = 1
else:
root.update()
root.deiconify()
pygame.event.clear()
elif event.key == K_c:
particles.clear()
#画背景
screen.fill(color["bg"])
#画 xxxx
for particle in particles:
particle.draw(screen)
#刷新
for particle in particles:
particle.update()
if not particle.burn_time:
particles.remove(particle)
# 刷新界面
pygame.display.update()
使用多线程来解决这个办法
然后再打开还会保留上一次的数据,你自己写把内容清空就行了
如果对你有帮助的话,给个最佳答案呗!!! 占楼 问题再86行,创建一个ttk窗口对象,从第二次开始就会出现问题,但第一次是好的(显示出现问题,好像不影响实际使用) cjjJasonchen 发表于 2023-7-20 23:26
问题再86行,创建一个ttk窗口对象,从第二次开始就会出现问题,但第一次是好的(显示出现问题,好像不影响 ...
之前用tkinter做的时候好像没有问题 这是因为style = ttk.Style()创建了一个新的样式对象,但是没有加载任何主题。这就是为什么你第一次调用set_up()时看到的是你期望的主题(在你的主程序中已经加载了),但是在对set_up()的后续调用中,你看到的是默认主题:因为在这些情况下,你正在创建和使用一个新的、未加载主题的样式对象。
如果你将style = ttk.Style()行移动到set_up()函数的顶部(在任何其他 ttk 或 tkinter 代码之前),那么你应该会在set_up()的每次调用中都看到你期望的主题。你的set_up()函数应该如下所示:
def set_up():
style = ttk.Style()
style.theme_use('default')
# ...
这样,每次你创建一个新的样式对象时,你都会立即加载 default 主题,因此在你的 ttk 代码中你将始终看到这个主题,而不是 tkinter 的默认主题。 任务管理器:*************
这个是真的吃CPU{:10_277:} 我都12核了,3个就卡的要死(巨形) isdkz 发表于 2023-7-20 23:29
这是因为style = ttk.Style()创建了一个新的样式对象,但是没有加载任何主题。这就是为什么你第一次调 ...
在第一次创建的时候就出现两个窗口,问题没有解决 歌者文明清理员 发表于 2023-7-20 23:31
任务管理器:*************
这个是真的吃CPU 我都12核了,3个就卡的要死(巨形)
这玩意这个状态下就是纯纯的只能看。。。要不然就要降低画质{:10_266:} 建议不要切换黑白,直接换主题,正常主题是cosmo,黑色主题是darkly liuhongrun2022 发表于 2023-7-21 08:11
建议不要切换黑白,直接换主题,正常主题是cosmo,黑色主题是darkly
切换黑白是切换的pygame(功能还没写),ttk的主题没有去动他 上去
Mike_python小 发表于 2023-7-20 23:23
使用多线程来解决这个办法
然后再打开还会保留上一次的数据,你自己写把内容清空就行了
问题解决了,非常感谢,但是楼主没有学过这个库,有没有推荐的教程看看{:10_282:} Mike_python小 发表于 2023-7-20 23:23
使用多线程来解决这个办法
然后再打开还会保留上一次的数据,你自己写把内容清空就行了
如果我点击右上角关闭窗口会报错欸{:10_277:} cjjJasonchen 发表于 2023-7-21 11:59
如果我点击右上角关闭窗口会报错欸
可以参考这个文章https://qa.1r1g.com/sf/ask/7780881/#google_vignette
然后再窗口关闭的时候替换成隐藏窗口的命令 cjjJasonchen 发表于 2023-7-21 11:55
问题解决了,非常感谢,但是楼主没有学过这个库,有没有推荐的教程看看
我这个说不好,学过好多教程,然后现在就是有啥不会的翻翻书就行了
页:
[1]