Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何编辑代码以使';下一个';按钮是否指向同一窗口中的空白页?(不是新窗口)_Python 3.x_Oop_Tkinter_Canvas_Screen - Fatal编程技术网

Python 3.x 如何编辑代码以使';下一个';按钮是否指向同一窗口中的空白页?(不是新窗口)

Python 3.x 如何编辑代码以使';下一个';按钮是否指向同一窗口中的空白页?(不是新窗口),python-3.x,oop,tkinter,canvas,screen,Python 3.x,Oop,Tkinter,Canvas,Screen,您好,上面的代码可以完全正常工作,但我不知道如何让“下一步”按钮创建一个新的空白屏幕(稍后我会设计这个屏幕,但现在是空白的,以减少复杂性)。我不能使用顶层,因为我不想打开一个全新的窗口,但我希望它在同一个窗口中打开(一个屏幕退出,另一个屏幕打开)。如何用一个非常简单的代码做到这一点??(按钮位于画布上)您可以使用delete方法删除画布上的所有内容。如果您传递文本字符串“all”,它将删除画布上的所有内容 from tkinter import Tk, Canvas, Frame, BOTH f

您好,上面的代码可以完全正常工作,但我不知道如何让“下一步”按钮创建一个新的空白屏幕(稍后我会设计这个屏幕,但现在是空白的,以减少复杂性)。我不能使用顶层,因为我不想打开一个全新的窗口,但我希望它在同一个窗口中打开(一个屏幕退出,另一个屏幕打开)。如何用一个非常简单的代码做到这一点??(按钮位于画布上)

您可以使用
delete
方法删除画布上的所有内容。如果您传递文本字符串“all”,它将删除画布上的所有内容

from tkinter import Tk, Canvas, Frame, BOTH
from tkinter import *
from tkinter import Tk

#Welcome screen

root = Tk()
root.configure(bg = "steel blue")


canvas = Canvas(root, bg = "steel blue", highlightthickness = 0)
canvas.config(width = 350, height = 250)

#canvas.config(width = root.winfo_screenwidth(), height = root.winfo_screenheight() )
canvas.pack()

#Making of the round rectangle

class Rectangle:

    def round_rectangle(x1, y1, x2, y2, radius=25, **kwargs):

        points = [x1+radius, y1,
                  x1+radius, y1,
                  x2-radius, y1,
                  x2-radius, y1,
                  x2, y1,
                  x2, y1+radius,
                  x2, y1+radius,
                  x2, y2-radius,
                  x2, y2-radius,
                  x2, y2,
                  x2-radius, y2,
                  x2-radius, y2,
                  x1+radius, y2,
                  x1+radius, y2,
                  x1, y2,
                  x1, y2-radius,
                  x1, y2-radius,
                  x1, y1+radius,
                  x1, y1+radius,
                  x1, y1]

        return canvas.create_polygon(points, **kwargs, smooth=True)

    my_rectangle = round_rectangle(10, 60, 330, 250, radius=20, outline = "black", fill="white")

canvas.place(relx=0.5, rely=0.5,anchor=CENTER)

def UserIdentification():
    newWindow = Toplevel(root)

Next_button=Button(root,text = "Next", anchor = W, command = UserIdentification)
Next_button.configure(width = 10, bg = "black", fg = "blue" ,borderwidth = 4)
Next_button = canvas.create_window(150, 200, anchor=NW, window=Next_button)

canvas.create_text(170, 100, text = "Hey there, welcome to DeliverToday! \nWe bring your needs right at your doorstep ~ \nhave a great journey ahead!")  

root.mainloop()

看一看。“空白屏幕”是否意味着你想要一个没有画布的屏幕,或者你想要保存画布,但是删除画布上的所有东西吗?表单标签站点可能会帮助我稍后,当我继续向空白屏幕添加东西时,但不能用这个特殊的问题来创建一个空白屏幕,抱歉!我所说的“空白屏幕”是指带有画布的屏幕,因为我仍然需要一些带有文本的方块和其他东西。哦,谢谢!!这只是一个供进一步参考的快速问题,因为我正在尝试制作一个具有多个屏幕的基本应用程序,所以如果我想要一个没有画布的屏幕(比如说,如果该特定屏幕仅包含文本或其他内容),该怎么办?@khushi:那么只需销毁画布并添加其他内容。哦,好的!非常感谢你!!
def UserIdentification():
    canvas.delete("all")