python tkinter button_python-tkinter按钮不显示

news/2024/8/26 14:12:58

当我执行脚本时,背景图像可以正常工作,它将与窗口的大小匹配,但是,我无法显示按钮(它们尚无功能).我对python相当陌生,所以不确定是否将按钮用作事件是一个好主意.任何帮助表示赞赏.

import turtle

import tkinter as tk

from tkinter import *

from PIL import Image,ImageTk

root = Tk()

taxi = (r"C:\directory\image.png")

class App(Frame):

def __init__(self,master,Buttons=None):

Frame.__init__(self,Buttons)

self.columnconfigure(0,weight=1)

self.rowconfigure(0,weight=1)

self.original = Image.open(r"C:\directory\Layout.gif")

self.image = ImageTk.PhotoImage(self.original)

self.display = Canvas(self,bd=0,highlightthickness=0)

self.display.create_image(500,500,image=self.image,anchor=NW,tags="IMG")

self.display.grid(row=0,column=0,sticky=W+E+N+S)

self.pack(fill='both',expand=True)

self.bind("",self.resize)

def resize(self,event):

size = (event.width,event.height)

resized = self.original.resize(size,Image.ANTIALIAS)

self.image = ImageTk.PhotoImage(resized)

self.display.delete("IMG")

self.display.create_image(0,tags="IMG")

def Buttons(self,event):

self.Button1 = tk.Button(master = root,text = "Button1") #,command = forward).pack(side = tk.LEFT)

self.Button1.grid(row=1,column=1)

self.Button2 = tk.Button(master = root,text = "Button2") #,command = forward).pack(side = tk.LEFT)

self.Button2.grid(row=2,column=1)

self.Button3 = tk.Button(master = root,text = "Button3") #,command = forward).pack(side = tk.LEFT)

self.Button3.grid(row=3,column=1)

app = App(root)

app.mainloop()


http://www.niftyadmin.cn/n/2067585.html

相关文章

oracle里面cat,Oracle 12c 中推荐使用 catcon.pl 执行SQL脚本

https://www.cndba.cn/dave/article/225https://www.cndba.cn/dave/article/2251 说明在Oracle 12c中,Oracle 建议使用catcon.pl 脚本来执行SQL 脚本和SQL 语句,其可以在root 和指定的PDB中执行。 Catcon.pl脚本是一个perl 脚本,需要在操作…

面试:做过sql优化吗?

近来面试找工作经常会遇见这种问题: 做过数据库优化吗?大数据量基础过吗?系统反应慢怎么查询? 这咱也没背过啊,面试还老问,现在的网站主要的压力都来自于数据库,频繁的数据库访问经常会使系统瘫…

python动态加载模块_python3使用exec来动态加载模块

xxglsvr.py import sys # locals() 函数来得到一个局部变量字典。 # 之后你就能从局部字典中获取修改过后的变量值了 def main(procName): loc locals() exec("from %s import call_sub" % procName) call_sub loc[‘call_sub‘] call_sub("private " p…

检测接口数据 - Charles使用

1.Charles下载地址 : 百度一下 2.使用方法 : http://blog.devtang.com/2015/11/14/charles-introduction/ 3.charles破解: Registered Name:https://zhile.ioLicense Key: 48891cf209c6d32bf4 破解步骤 董铂然的博客 - 详解https://www.cnblo…

oracle pue考试,oracle分布式事务(理论)

基本概念Local Coordinator:在分布事务中,必须参考其它节点上的数据才能完成自己这部分操作的站点。Global Coordinator:分布事务的发起者,负责协调这个分布事务。Commit Point Site:在分布事务中,首先执行…

python一般做什么项目好_你用 Python 做过什么有趣的数据挖掘/分析项目?

问题 学习了 Python, numpy, scipy 等, 想做一些数据方面的项目,但是之前又没有这方面的经验。所以想知道大家都做过什么有趣的项目, 或者有什么好入手的方向推荐下。(注:本篇文章代码和网址较多…

for循环和数组练习

//公鸡2文&#xff0c;母鸡1文&#xff0c;小鸡半文&#xff0c;每种至少一只&#xff0c;100文买100只鸡有多少种可能var ci 0; for(var g1;g<50;g){for(var m1;m<100;m){for(var x1;x<100;x){if(g*2m*1x*(0.5)100&&gmx100){ci1;console.log("买公鸡&qu…

添加目录 linux,Linux添加库路径的两种方法

/opt/lib需要注意的是&#xff1a;第二种搜索路径的设置方式对于程序连接时的库(包括共享库和静态库)的定位已经足够了&#xff0c;但是对于使用了共享库的程序的执行还是不够的。这是因为为了加快程序执行时对共享库的定位速度&#xff0c;避免使用搜索路径查找共享库的低效率…