我已将用户更改为netbean中的user.properties中的信息,
import tkinter
import sys
from fractions import gcd
CURRENT_LABELS = []
def pythagorean_primitive(a, b, c):
"""returns True if a,b,c are pythagorean primitives, False otherwise"""
return a**2 + b**2 == c**2 and gcd(a, b) == 1
def generate_results(n):
"""lists each triplet of distinct integers <n that is a pythagorean primitive"""
results = []
for a in range(1, n):
for b in range(a, n):
for c in range(b, n):
if pythagorean_primitive(a, b, c):
results.append([a, b, c])
return results
def generate_labels(sequence):
"""returns a list of tkinter labels from the sequence provided"""
labels = []
for elt in sequence:
a, b, c = elt[0], elt[1], elt[2]
labels.append(tkinter.Label(root, text='[' + str(a) + ', '+ str(b) + ", " + str(c) + "]"))
return labels
def destroy_old():
"""purges the current tkinter labels from root, and destroys them"""
global CURRENT_LABELS
for elt in CURRENT_LABELS:
elt.grid_forget()
elt.destroy()
def show_new_labels(sequence):
"""assembles a new display of tkinter labels from the sequence provided"""
r, c = 1, 0
for label in sequence:
label.grid(row=r, column=c, ipadx=5, ipady=5, sticky='W''E')
r += 1
if not r % 10:
r = 1
c += 1
def event_handler(event):
"""deals with the input of a number in the Entry field"""
global CURRENT_LABELS
x = int(e1.get()) # get max number
results = generate_results(x)
try:
destroy_old()
except IndexError:
pass
CURRENT_LABELS = generate_labels(results)
show_new_labels(CURRENT_LABELS)
def close(): # close program
tkinter.sys.exit(0)
sys.exit(0)
root = tkinter.Tk() # establish main gui
root.title('Generator')
e1 = tkinter.Entry(root)
assert isinstance(e1, object) # only method I've found to allow for Entry().grid()
e1.grid(ipadx=5, ipady=5, sticky='W''E')
root.bind('<Return>', event_handler) # bind to Enter, cleaner and quicker than a button
root.mainloop()
但它只能在php文件中工作,而不能在js(javascript)文件@author name中工作?如何在JS中获取@author ...!