python - 努力让图像出现在我基于 Tkinter 的程序的其他元素后面
问题描述
全新的编程,这是我第一个用任何语言编写的真正项目。
我目前正在为程序编写界面,我想在顶部显示现在和将来会出现的图像、按钮、文本框和其他元素。
我不知道如何将图像移到后面层,不确定这是否是您提出这样一个问题的方式。
这是它当前的显示方式,您可以看到图像与所有内容重叠。
目前看起来如何
到目前为止,这是我的代码:
from tkinter import *
from tkinter import ttk
from PIL import Image, ImageTk, ImageFont, ImageDraw
import tkinter as tk
import subprocess
#wifi scanning into file command
savename = "net.txt"
def wifi():
f= open(savename,"w+")
subprocess.run("wifi scan>"+ savename, shell=True, check=True)
def statustext(): #text that appears when save button is pressed
savestatus = Label(root, text="Scanning and saving complete")
savestatus.grid(row=6, column=3)
def hacktext():
hackstatus= Label(root, text="Not Done Yet")
hackstatus.grid(row=12, column=3)
def readfile():
f= open(savename,"r")
subprocess.run("leafpad " +savename, shell=True, check=True)
def readtext():
openstatus= Label(root, text="Opening in Leafpad...")
openstatus.grid(row=15, column=3)
def hackbut():
hackspac = Label(root)
hackspac.grid(row=12)
hackbutton = Button(text="Hack Password", command=lambda:[(),hacktext()])
hackbutton.bind("<Button-1>")
hackbutton.grid(row=14,column=3)
def textbut():
textspac =Label(root)
textspac.grid(row=15)
textbutton = Button(text="Display Text File", command=lambda:[(),readtext(),readfile()])
textbutton.grid(row=16,column=3)
root = Tk()
scanbutton = Button(text="Scan & Save", command=lambda:[wifi(),statustext(),hackbut(),textbut()])
scanbutton.bind("<Button-1>")
scanbutton.grid(row=11,column=3)
root.geometry ('320x240')
bg = PhotoImage(file="background.gif")
background_label = Label(root, image=bg)
background_label.grid(row=1,column=1)
解决方案
推荐阅读
- python-3.x - 从同级目录导入 - Python 3.7
- javascript - 如何使用 javascript 更改 iframe 内视频的播放速率/速度?
- python - 为什么我的数据无效?(serializer.is_valid() 返回 False)
- python - Tika 在 Windows 上通过 python 抛出 AttributeError
- rust - Rust 中的动态类型实体组件系统
- python - Python 中的 PHP $obj->{$field} 等价物
- numpy - 波士顿数据集上的梯度下降
- spring - Hibernate PESSIMISTIC_WRITE 不锁定数据库并返回 oldValue
- enums - GRAPHQL 基于 Enum 查找项目
- python - 一个 Django 问题:第 17 行的块标记无效:“静态”。您是否忘记注册或加载此标签?