一、引數說明
語法作用
scale(window, label="滑塊")
滑塊標題
scale(window, label="滑塊", from_=0)
滑塊最小值為0
scale(window, label="滑塊", to=100)
滑塊最大值為100
scale(window, label="滑塊", length=200)
滑塊長度為200
scale(window, label="滑塊", orient = tk.horizontal)
滑塊水平方向顯示
scale(window, label="滑塊", resolution=0.01)
滑塊值的精度為0.01
scale(window, label="滑塊", digits = 8)
設定顯示的位數為8
scale(window, label="滑塊", command=select)
滑動時的**
scale.get()
獲取當前滑塊位置的值
scale.set(10)
設定滑塊的值
二、**示例
import tkinter as tk三、效果圖window = tk.tk()
# 設定視窗大小
winwidth = 600
winheight = 400
# 獲取螢幕解析度
screenwidth = window.winfo_screenwidth()
screenheight = window.winfo_screenheight()
x = int((screenwidth - winwidth) / 2)
y = int((screenheight - winheight) / 2)
# 設定主視窗標題
window.title("scale引數說明")
# 設定視窗初始位置在螢幕居中
window.geometry("%sx%s+%s+%s" % (winwidth, winheight, x, y))
# 設定視窗圖示
window.iconbitmap("./image/icon.ico")
# 設定視窗寬高固定
window.resizable(0, 0)
"""scale引數.
valid resource names: activebackground, background, bigincrement, bd,
bg, borderwidth, command, cursor, digits, fg, font, foreground, from,
highlightbackground, highlightcolor, highlightthickness, label,
length, orient, relief, repeatdelay, repeatinterval, resolution,
showvalue, sliderlength, sliderrelief, state, takefocus,
tickinterval, to, troughcolor, variable, width."""
def select(v):
print(v)
# 建立乙個1到100的滑塊, 精度為0.01, 顯示的最大位數為8
scale = tk.scale(window, label="滑塊", length = 400, from_=1, to = 100, bg="#bbb", fg = "#f00", orient = tk.horizontal, command=select, resolution=0.01, digits = 8)
scale.pack()
def getscalevalue():
print(scale.get())
def setscalevalue():
scale.set(10)
tk.button(window, text="get value", width=30, pady=5, command=getscalevalue).pack()
tk.button(window, text="set value", width=30, pady=5, command=setscalevalue).pack()
window.mainloop()
猜數字之tkinter
import random import tkinter import tkinter.messagebox defb clicked if name entry.get tkinter.messagebox.showerror title error message 請輸入使用者名字 else c...
Tkinter 之ProgressBar進度條標籤
一 引數說明 引數作用 cursor 滑鼠位於進度條內時的形狀 length 進度條長度 maximum 進度條最大刻度值 mode 進度條的模式。有兩種 determinate 和 indeterminate orient 進度條的方向,有horizontal 和vertical兩種 style ...
Caffe之Scale層原始碼
最近要對模型進行壓縮使用slimming,因此需要scale層對scale diff進行l1正則。所以對原始碼進行了閱讀。公式 y ax b。公式比較簡單。上述公式的意思是,對feature map乘以a,並加b。乙個feature map共用乙個a,因此 a的維度是 c 這是理解原始碼的前提。反向...