Tkinter如何从bg中删除白点

时间:2016-02-04 15:07:23

标签: python python-3.x tkinter

当我将背景颜色设置为与白色不同的颜色时,屏幕中央始终显示一个白色像素。有谁知道我怎么能删除它? 我需要一些帮助! 这是我的代码:

#! usr/bin/python
# Filename: x_Factorial!_GUI.py

import sys, warnings

if sys.version_info[0] < 3:
    warnings.warn("System FAILURE, Python 3.x is required in order to execute this program", RuntimeWarning)
else:
    version_info_num = str(sys.version_info[0]) + "." + str(sys.version_info[1]) + "." + str(sys.version_info[2])
    print("System SUCCESS, You are currently executing this program on Python's version: ", version_info_num)

import tkinter as tk
from tkinter import Entry, Text, StringVar

class Application(tk.Frame):
    def __init__(self, master = None):
        tk.Frame.__init__(self, master)

        self.master.minsize(width = 800, height = 600)
        self.master.update()

        win_width = self.master.winfo_width()
        win_height = self.master.winfo_height()
        scr_xloc = int(self.master.winfo_screenwidth() / 2 - win_width / 2)
        scr_yloc = int(self.master.winfo_screenheight() / 2 - win_height / 2 - 30)

        self.master.geometry("{}x{}+{}+{}".format(win_width, win_height,
                                             scr_xloc, scr_yloc))

        self.master.title("x_Factorial!")
        self.master.configure(bg = "#F06428")

        self.pack(expand = 1)

        self.master.bind("<F11>", self.Toggle_Fullscreen)
        self.State = False

        self.master.bind("<Escape>", self.Quit)

    def Toggle_Fullscreen(self, event):
        self.State = not self.State
        self.master.attributes("-fullscreen", self.State)

    def Quit(self, event):
        root.destroy()

root = tk.Tk()
App = Application(master = root)

App.mainloop()

1 个答案:

答案 0 :(得分:0)

中心的像素是Application类的实例,它是一个Frame。因为您没有在该框架中放置任何小部件,所以它的大小为1x1。

为了使这一点更加明显,请在__init__中的某处添加以下代码行,以制作&#34;像素&#34;更大更蓝的蓝色:

self.configure(background="blue", width=10, height=10)
相关问题