我的Ubuntu系统上有一个应用程序,使用from tkinter import *
import tkinter as tk
import time
import random
class Example(tk.Frame):
def __init__(self,parent):
tk.Frame.__init__(self)`
#create a canvas
self.canvas = tk.Canvas(width=600, height=250)
self.canvas.pack()
self.road()
self.crossing()
def road(self):
Line1 = self.canvas.create_line(50, 50, 450, 50)
Line2 = self.canvas.create_line(50, 100, 450, 100)
def crossing(self):
CLine1 = self.canvas.create_line(350, 50, 350, 100)
CLine2 = self.canvas.create_line(375, 50, 375, 100)
class Car:
def __init__(self,x1,y1,x2,y2,vx,vy,color,Example):
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
self.vx = vx
self.vy = vy
self.color=color
self.Example = Example
def drawit(self):
self.Example.canvas.create_rectangle(x1,y1,x2,y2,color)
def moveit(self,vx,vy):
self.Example.canvas.move(vx,vy)
if __name__ == "__main__":
root = tk.Tk()
my_canvas = Example(root).pack(fill="both", expand=True)
mycar = Car(60, 60, 125, 90,3,0,"red",Example)
mycar.drawit()
mycar.moveit()
print (mycar.x1)
root.mainloop()
使用AttributeError: type object 'Example' has no attribute 'canvas'
谓词构建。它本身运行正常,但CMake
将其显示为add_executable
,通常应用于共享库:
readelf
有谁知道为什么会这样?
答案 0 :(得分:-1)
在现代发行版上,可执行文件默认编译为与位置无关的代码(参见例如this question),这会导致工具(file
等)认为它们是共享库。我建议你针对各自的工具提交一个bug,以便它们产生更加用户友好的输出。