如何更改Tkinter窗口的背景颜色

时间:2019-08-02 16:56:10

标签: python tkinter

这与文字颜色无关,我只想更改tk背景,使其看起来更好。

label =标签(窗口,文本='TMU,大学图书馆',字体='75',bg =蓝色)

from tkinter import*
from tkinter.ttk import*
window=Tk()
window.title('hello sir,welcome to python library!')
window.geometry('500x350') 
label=Label(window,text='TMU,College library',font='75')
label.grid(column=1,row=3)
#label.pack(pady=10,padx=10)

lbl=Label(window,text='Student name')
lbl.grid(column=2,row=6)
lbl=Label(window,text='Enrollment no')
lbl.grid(column=2,row=7)
lbl=Label(window,text='year/semester')
lbl.grid(column=2,row=8)
lbl=Label(window,text='course')
lbl.grid(column=2,row=9)

a1=Entry(window)
a1.grid(column=3,row=6)
a1=Entry(window)
a1.grid(column=3,row=7)
a1=Entry(window)
a1.grid(column=3,row=8)

与错误无关。

1 个答案:

答案 0 :(得分:0)

尝试使用:

@import '~bulma/sass/utilities/initial-variables'
@import "~bulma/sass/utilities/functions"
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800')

$green: #00C434
$cyan: #5fd9eb 
$yellow: #ffba00

$aquamarine: #38b29f
$facebook: #4267b2
$google: #db4437
$cyan-invert: findColorInvert($cyan)
$aquamarine-invert: findColorInvert($aquamarine)
$facebook-invert: findColorInvert($facebook)
$google-invert: findColorInvert($google)
$info: $cyan
$twitter: #1B95E0
$linkedin: #0077B5
$pinterest: #c8232c
$whatsapp: #4FCE5D

$primary : #00D1B2
$primary-invert: findColorInvert($primary)

$orange: #FF814F
$orange-invert: findColorInvert($orange);

$grey-light-invert: findColorInvert($grey-light);

$family-sans-serif: 'Open Sans', sans-serif;
$family-primary: $family-sans-serif

@import "~bulma/sass/utilities/derived-variables"
$modal-background-background-color : rgba($black, 0.6)

$radius : 5px
$input-focus-border-color : $primary
$input-focus-box-shadow-color: rgba($input-focus-border-color, 0.25)
$breadcrumb-item-color : $grey
$button-border-color : $grey
$input-border-color : $grey
$input-shadow : none
$addColors : ( "orange" : ($orange, $orange-invert), "facebook" : ($facebook, $facebook-invert), "google" : ($google, $google-invert), "aquamarine" : ($aquamarine, $aquamarine-invert), "grey-light" : ($grey-light, $grey-light-invert) )
$colors: map-merge($colors, $addColors);
$size-8: .60rem
$dropdown-item-hover-background-color : rgba($primary, 0.25)
$dropdown-item-active-background-color : $primary
$navbar-item-hover-color : $primary

$tabs-link-active-border-bottom-color : $primary
$tabs-link-active-color : $primary

@import '~bulma/bulma'
@import '~buefy/src/scss/buefy'

$steps-divider-size: .1em
$steps-completed-color: $success
$steps-active-color: $success

或:

window.config(bg=SOMECOLOR(e.g:'red'))