如何使用 tkinter 替换背景颜色? [英] How do i replace the color of my background using tkinter?

查看:101
本文介绍了如何使用 tkinter 替换背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在我已经放置一些文本和按钮之后用白色填充我的整个背景.我需要将它从屏幕上完全清除,以便我可以在新页面上放置一些新文本和按钮.我应该使用什么方法?这对我真的很有帮助.

I want to be able to fill my entire background with white after i have already put some text and buttons on it. I need it to be completely cleared off the screen, so i can put some new text and buttons on the new page.What method should i use? This would be really helpful for me.

    if usr_name in usrs_info:
        if usr_pwd == usrs_info[usr_name]:
            tkinter.messagebox.showinfo(title='Welcome', message='How are you? ' + usr_name)
        # 如果用户名匹配成功,而密码输入错误,则会弹出'Error, your password is wrong, try again.'
        else:
            tkinter.messagebox.showerror(message='Error, your password is wrong, try again.')
    else:  # 如果发现用户名不存在
        is_sign_up = tkinter.messagebox.askyesno('Welcome! ', 'You have not sign up yet. Sign up now?')
        # 提示需不需要注册新用户
        if is_sign_up:
            usr_sign_up()

推荐答案

from tkinter import *
roht = Tk() 
roht.configure(bg = "red") 
roht.mainloop() 

这篇关于如何使用 tkinter 替换背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆