今天迈入第14天了,耶~~~今天的内容我也是很喜欢,尤其是自己调整背景颜色的实作,真的觉得非常有趣~
♠♣今天的文章大纲♥♦
Scale就是数值卷轴,可以移动数值卷轴去产生数字。
参数 | 说明 |
---|---|
activebackground | 滑鼠游标在数值卷轴时的背景颜色。 |
from底线 | 数值卷轴范围值得初值。 |
bg | 标签背景或 indicator 的背景颜色。 |
borderwidth或bd | 边界宽度,预设是2px。 |
command | 当使用者更改选项时,会自动执行此函数。 |
cursor | 当滑鼠游标在选项纽时的外形。 |
fg | 文字的颜色。 |
font | 字型。 |
label | 预设是没有标签文字,如果数值卷轴是水平此标签出现在左上角,如果数值卷轴是垂直此标签出现在右上角。 |
length | 预设是100像素。 |
highlightbackground | 当数值卷轴取得焦点时的背景颜色。 |
highlightcolor | 当数值卷轴取得焦点时的颜色。 |
orient | 设是水平卷轴,可以设定水平 HORIZONTAL 或垂直 VERTICAL |
relief | 预设是FLAT,可由此更改边界外观。 |
justify | 当文字多行时,最後一行的对齐方式。 |
repeatdelay | 可设定时需要按着卷轴盒多久才可移动此卷轴盒,单位是毫秒 (milliseconds),预设是300。 |
resolution | 每次更改的数值。 |
showvalue | 常会显示数值卷轴目前值,如果设为0则不显示。 |
state | 如果设为 DISABLE 则暂时无法使用此 Scale。 |
takefocus | 正常时此数值卷轴可以循环取得焦点,如果设为0则无法。 |
tickinterval | 数值卷轴的标记刻度。 |
to | 数值卷轴范圈值的末端值。 |
troughcolor | 槽(trough) 的颜色。 |
variable | 设定或取得目前选取的选项按钮,它的值态通常是 IntVar 或StringVar。 |
width | 选项纽的文字区间有几个字元寛,省略时会自行调整为实际宽度。 |
设数值卷轴为红绿蓝,可以自行调整背景颜色,这个好有趣,原来介面就是这样设计,还可以自己调颜色,超酷的我做完後玩超久||ヽ( ̄▽ ̄)ノミ|Ю
import tkinter as tk
root = tk.Tk()
root.title('cuteluluWindow')
root.configure(bg="#7AFEC6")
root.iconbitmap('heart_green.ico')
root.geometry('350x300')
def bgcolor (source):
red = rSlider.get()
green = gSlider.get()
blue = bSlider.get()
print("R=%d, G=%d, B=%d" % (red, green, blue))
myColor="#%02x%02x%02x" % (red, green, blue)
root.config(bg=myColor)
fm = tk.Frame (root)
fm.pack()
l=tk.Label(root,text='Change background color yourself.',bg='#7AFEC6',fg='#FFAAD5',font=("Ravie",10,"bold"))
l.pack()
rSlider = tk.Scale (fm, from_= 0 , to = 255 , command=bgcolor)
gSlider = tk.Scale (fm, from_= 0 , to = 255 , command=bgcolor)
bSlider = tk.Scale (fm, from_= 0 , to = 255 , command=bgcolor)
gSlider.set(125)
rSlider.grid (row=0,column=0)
gSlider.grid (row=0,column=1)
bSlider.grid (row=0,column=3)
root.mainloop()
执行结果⬇⬇⬇
可以自己去调整背景颜色,超好玩。
这个也蛮好玩的,但个人觉得上一个更好玩,因为不知道会调到什麽颜色,就会有的惊喜。
import tkinter as tk
from tkinter.colorchooser import askcolor
root = tk.Tk()
root.title('cuteluluWindow')
root.configure(bg="#7AFEC6")
root.iconbitmap('heart_green.ico')
root.geometry('300x300')
def bgcolor():
bgColor = askcolor()
print (type (bgColor), bgColor)
root.config(bg=bgColor[1])
btn = tk.Button(text="Change background Color",command=bgcolor)
btn.pack (pady = 10)
root.mainloop()
执行结果⬇⬇⬇
这个就是自己去点击想要的颜色,按确定後就可以套用了。
今天的文章就到这边了,明天就是第15天了呢,继续加油吧!!!
本篇同步发布於个人Blog: [PoEAA] Domain Logic Pattern - Tabl...
这是我前几年作为学习/练习的例子。 看过与C交互後,接着来看看一个更实际应用的例子。不过不用C,来...
这个得上一篇:https://ithelp.ithome.com.tw/articles/10261...
For the topic today, I can't fully understand the ...
今天的 Home 目录没有修改,https://github.com/simba-fs/2021-...