tk

How to make a tkinter Entry field mandatory to enter some text?

孤人 提交于 2020-12-13 03:26:30
问题 like in HTML tag attribute required=required I want make an Entry widget mandatory, the user must enter data in it, otherwise don't proceed to next step. How to do it with tkinter? 回答1: There is no attribute "required" in Tkinter, you need to write a function to check whether the user entered data in the entry or not. Then use this function as the command of the "Next" button. import tkinter as tk def next_step(): if mandatory_entry.get(): # the user entered data in the mandatory entry:

Why can't I display an Image in a tkinter Toplevel() window?

我与影子孤独终老i 提交于 2020-12-08 04:00:36
问题 I'm trying to create a python program tkinter that, upon the pressing of a button, opens a new full screen tkinter window containing an image and plays an audio file - here's my code: from tkinter import * from PIL import Image, ImageTk from playsound import playsound def play(): window = Toplevel() window.attributes('-fullscreen', True) img = ImageTk.PhotoImage(Image.open("pic.png")) label = Label(window, image=img).pack() playsound("song.mp3") buttonWindow = Tk() b = Button(buttonWindow,