[英]How to increase the border width of the progressbar(ttk) tkinter python
How can I increase the border width of progress bar in Thinker using Python.如何使用 Python 在 Thinker 中增加进度条的边框宽度。 Below you can see my code, I have used length = 1360 and bd = 5 parameters but I can't manage to get the thickness I desired from the progress bar.下面你可以看到我的代码,我使用了 length = 1360 和 bd = 5 参数,但我无法从进度条中获得我想要的厚度。
from tkinter import ttk
from tkinter.ttk import *
from tkinter import *
import tkinter
root = Tk() root.configure(background = "sky blue")
root.wm_attributes("-fullscreen","true")
progress = Progressbar(root, orient = HORIZONTAL, length = 1360,
maximum=150, mode = "determinate",
style="TProgressbar", bd=5)
def bar():
import time progress["value"] = 60 root.update_idletasks()
time.sleep(1)
progress["value"] = 150
root.update_idletasks()
time.sleep(1)
root.destroy()
progress.pack(pady=4)
class HoverButton(tkinter.Button):
def init(self, master, **kw):
tkinter.Button.init(self,master=master,**kw)
self.defaultBackground = self["background"]
self.bind("", self.on_enter)
self.bind("", self.on_leave)
def on_enter(self, e):
self["background"] = self["activebackground"]
def on_leave(self, e):
self["background"] = self.defaultBackground
classButton = HoverButton(root,text="Start",padx=6,pady=1,
bd=7,font=("Eras Demi ITC",14,"bold"),
width=14, activebackground="purple",command=bar)
classButton.pack(pady=5)
root.mainloop()
Create a Canvas (with a window in it) and add progressbar to that.创建一个画布(其中有一个窗口)并为其添加进度条。 In this way you can control the width, you desired.通过这种方式,您可以根据需要控制宽度。
canvas = Tkinter.Canvas(self, relief = Tkinter.FLAT, width = 1200, height = 5)
progressbar = Progressbar(canvas, orient=Tkinter.HORIZONTAL,
length=1360, mode="determinate" )
canvas.create_window(1, 1, anchor=Tkinter.NW, window=progressbar)
canvas.grid()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.