这是我目前遇到的众多错误之一的一个例子 -
Traceback (most recent call last):
File "E:\penguinforce\new code\GUI test 1.py", line 8, in <module>
geometry("560x280")
NameError: name 'geometry' is not defined
以下是我可以从这里收集的其余代码以及互联网tkinter
那些导致我出现问题的代码。
#!/usr/bin/python
__author__ = 'Sudo'
import Tkinter
root = Tkinter
print Tkinter.__file__
print ("Penguin Force")
geometry("560x280")
import socket
import subprocess
import robotparser
#import requests
import sys
import os
photo = PhotoImage(file="PenguinForce2.gif")
label = Label(root, image=photo)
label.pack()
topFrame = Frame(root)
topFrame.pack()
bottomFrame = Frame(root)
bottomFrame.pack(side=BOTTOM)
one = Label(root, text="Created by Sudo", bg="blue", fg="white")
one.pack(side=BOTTOM, fill=X)
def ScanPort():
print "-" * 26
print "Penguin Force Port Scanner"
print "-" * 26
Server = raw_input("Please enter a host name or IP address to scan")
ServerIP = socket.gethostbyname(Server)
Firstport =int(input("Start scanning from this port"))
SecondPort = int(input("To this port"))
print "-" * 80
print "Please wait, we are currently scanning IP/Host for all ports available", ServerIP
print "-" * 80
try:
for port in range(Firstport, SecondPort):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex((ServerIP, port))
if result == 0:
print "Port {}: \t Open".format(port)
else:
print "Port {}: \t closed".format(port)
sock.close()
except socket.error:
print "Couldn't connect to IP/Host!"
sys.exit()
except socket.gaierror:
print "Hostname could not be resolved. Exiting"
sys.exit()
def CrackHouse():
for item in range (999):
params = {"username":"JoeSmith", "password":item}
r = requests.get("http://creative.coventry.ac.uk/eh/web_ch4/welcome.php",
params = params)
if r.text.find("incorrect") >=0:
print "Fails on {0}".format(item)
else:
print "Passcode {0} Ok".format(item)
return item
def ListRestricted():
sites = ['www.google.com','www.coventry.ac.uk', 'www.yahoo.com']
def getDenies(site):
paths =[]
robot = robotparser.RobotFileParser()
robot.set_url("http://"+site+"/robots.txt")
robot.read()
for line in robot.default_entry.rulelines:
not line.allowance and paths.append(line.path)
return set(paths)
for site in sites:
print "Denies for " +site
print "\t" + "\n\t".join(getDenies(site))
def create_contract(self):
name = self.name_entry.get()
address = self.address_entry.get()
def identifyOUI(macaddress):
database = open("data.txt", "r")
for line in database:
if macaddress in line: print line
database.close()
if __name__ == "__main__":
identifyOUI("A4:18:75")
def GenerateReport():
ListRestricted()
print ScanPort()
print CrackHouse()
print identifyOUI()
print ListRestricted()
print ("Documentation generated and saved to file.")
button1 = Button(topFrame, text = "Scan Port", fg="blue", command=ScanPort)
button2 = Button(topFrame, text = "Crack House", fg="blue", command=CrackHouse)
button3 = Button(topFrame, text = "List Restricted", fg="blue", command=ListRestricted)
button4 = Button(topFrame, text = "identifyOUI", fg="blue", command=identifyOUI)
button5 = Button(topFrame, text = "Generate Report (not functional)", fg="blue", command=GenerateReport)
root.rowconfigure((0,1), weight=1)
root.columnconfigure((0,2), weight=1)
button1.grid(row = 0, column = 0, columnspan= 500, sticky = 'EWNS')
button2.grid(row = 1, column = 1, columnspan= 500, sticky = 'EWNS')
button3.grid(row = 2, column = 2, columnspan= 500, sticky = 'EWNS')
button4.grid(row = 3, column = 3, columnspan= 500, sticky = 'EWNS')
button5.grid(row = 4, column = 4, columnspan= 500, sticky = 'EWNS')
root.mainloop()
答案 0 :(得分:1)
几何体,您必须创建一个按钮对象或者您尝试拥有的对象并将其存储在名为fred或您选择的变量中。然后你可以像这样设置fred [“geometry”] =“560x280”。我希望这对你有所帮助。
答案 1 :(得分:0)
root应该是
root = Tkinter.Tk()
root.geometry( “560x280”)
答案 2 :(得分:-1)
如错误所示,未定义geometry
。你打算从某个地方导入它吗?