就像我有这个代码我正在编辑/修改以使其工作,任何帮助?
继承人我的错误
Traceback (most recent call last):
File "C:\Users\Andrew\Desktop\Injector.py", line 42, in <module>
f = Injector()
File "C:\Users\Andrew\Desktop\Injector.py", line 18, in __init__
self.__openInjector()
File "C:\Users\Andrew\Desktop\Injector.py", line 33, in __openInjector
Tkinter.Button(root, text='Inject!', command=self.runInjectorCode).pack()
NameError: name 'Tkinter' is not defined
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
try:
# for Python2
from Tkinter import *
except ImportError:
# for Python3
from tkinter import *
class Injector:
def __openInjector(self):
root = Tk()
root.geometry('600x400')
root.title('Toontown Rewritten Injector')
root.resizable(False, False)
def __init__(self):
self.code = ''
self.__openInjector()
def runInjectorCode(self):
exec(self.code.get(1.0, 'end'), globals())
def __openInjector(self):
root = Tk()
root.geometry('600x400')
root.title('Toontown Rewritten Injector')
root.resizable(False, False)
frame = Frame(root)
self.code = Text(frame, width=70, height=20)
self.code.pack(side='left')
Tkinter.Button(root, text='Inject!', command=self.runInjectorCode).pack()
scroll = Scrollbar(frame)
scroll.pack(fill='y', side='right')
scroll.config(command=self.code.yview)
self.code.config(yscrollcommand=scroll.set)
frame.pack(fill='y')
f = Injector()
f.go()
Run Code Online (Sandbox Code Playgroud)
请帮助我不知道我做错了什么.我对这个python的东西很新,我修改了另一个根本不起作用的代码.但这必须以某种方式
Tkinter.Button(root, text='Inject!', command=self.runInjectorCode).pack()
Run Code Online (Sandbox Code Playgroud)
应该
Button(root, text='Inject!', command=self.runInjectorCode).pack()
Run Code Online (Sandbox Code Playgroud)
当您键入行时,from Tkinter import *它意味着您不再需要引用它们,Tkinter.Thing()而是应该Thing()直接引用它们
有关如何导入python模块的快速阅读,请参阅此内容,因为它将在未来为您节省大量的调试工作
| 归档时间: |
|
| 查看次数: |
390 次 |
| 最近记录: |