22 VERSION =
'v.00.01 --- 2010 April 12'
26 if sys.version_info[0] >= 3:
28 import tkinter.font
as tkFont
29 import tkinter.messagebox
as tkMessageBox
45 if not 'profile' in dir():
71 tk_Font_monospace = tkFont.Font(tk_Win, size=10, family=
'courier')
80 tkMessageBox.showinfo(
'About...',
84 (c) Olivier Pirson --- DragonSoft
90 Python {3}""".format(VERSION, DSPython.DS_web, DSPython.VERSION, sys.version))
94 def cmd_change_n(event=None):
111 if tkMessageBox.askyesno(
'Quit?',
'Quit Natural Tk?'):
119 tk_Label_n_10.config(text=
'n = ' + str(n))
120 tk_Label_n_2.config(text=
bin(n))
121 tk_Label_n_3.config(text=
'0t{0}'.format(nbsystem.to_str(n, b=3)))
122 tk_Label_n_16.config(text=hex(n))
124 primaries = (factors.primaries(n)
if n > 0
126 tk_Label_factors.config(text=(factors.primaries_str(primaries, times=
' . ')
if primaries !=
None
128 tk_Label_div_nb.config(text=unichr(957) +
'(n) = '
129 + (str(factors.divisors_nb(primaries))
if primaries !=
None
131 tk_Label_div_sum.config(text=unichr(963) +
'(n) = '
132 + (str(factors.divisors_sum(primaries))
if primaries !=
None
135 tk_Label_mobius.config(text=unichr(956) +
'(n) = '
136 + (str(factors.mobius(primaries))
if primaries !=
None
138 tk_Label_rad.config(text=
'rad(n) = '
139 + (str(factors.primaries_to_n(factors.rad(primaries)))
142 tk_Label_totient.config(text=unichr(966) +
'(n) = '
143 + (str(factors.totient(primaries))
if primaries !=
None
146 tk_Label_4sqr.config(text=
'GR(n) = '
147 + (str(factors.nb_in_integers_4sqr(primaries))
if primaries !=
None
155 tk_Win.title(
'Natural Tk')
156 tk_Win.resizable(0,0)
157 tk_Win.protocol(
'WM_DELETE_WINDOW', cmd_quit)
161 tk_Frame = tk.Frame(tk_Win)
164 tk_Entry_n = tk.Entry(tk_Frame, width=20)
165 tk_Entry_n.insert(tk.END,
'')
166 tk_Entry_n.bind(
'<Return>', cmd_change_n)
167 tk_Entry_n.pack(side=tk.LEFT)
169 tk.Frame(tk_Frame, width=10).pack(side=tk.LEFT)
170 tk.Button(tk_Frame, text=
'About', command=cmd_about).pack(side=tk.LEFT)
171 tk.Button(tk_Frame, text=
'Quit', command=cmd_quit).pack(side=tk.LEFT)
173 tk_Frame.pack(side=tk.TOP, fill=tk.X)
176 tk_Frame = tk.Frame(tk_Win)
178 tk_Label_n_10 = tk.Label(tk_Frame, font=tk_Font_monospace)
179 tk_Label_n_10.pack(side=tk.RIGHT, fill=tk.X)
180 tk_Frame.pack(side=tk.TOP, fill=tk.X)
182 tk_Frame = tk.Frame(tk_Win)
184 tk_Label_n_2 = tk.Label(tk_Frame, font=tk_Font_monospace)
185 tk_Label_n_2.pack(side=tk.RIGHT, fill=tk.X)
186 tk_Frame.pack(side=tk.TOP, fill=tk.X)
188 tk_Frame = tk.Frame(tk_Win)
190 tk_Label_n_3 = tk.Label(tk_Frame, font=tk_Font_monospace)
191 tk_Label_n_3.pack(side=tk.RIGHT, fill=tk.X)
192 tk_Frame.pack(side=tk.TOP, fill=tk.X)
194 tk_Frame = tk.Frame(tk_Win)
196 tk_Label_n_16 = tk.Label(tk_Frame, font=tk_Font_monospace)
197 tk_Label_n_16.pack(side=tk.RIGHT, fill=tk.X)
198 tk_Frame.pack(side=tk.TOP, fill=tk.X)
201 tk_Frame = tk.Frame(tk_Win, height=5)
202 tk_Frame.pack(side=tk.TOP)
204 tk_Frame = tk.Frame(tk_Win)
206 tk_Label_factors = tk.Label(tk_Frame, font=tk_Font_monospace)
207 tk_Label_factors.pack(side=tk.RIGHT, fill=tk.X)
208 tk_Frame.pack(side=tk.TOP, fill=tk.X)
210 tk_Frame = tk.Frame(tk_Win)
212 tk_Label_div_nb = tk.Label(tk_Frame, font=tk_Font_monospace)
213 tk_Label_div_nb.pack(side=tk.RIGHT, fill=tk.X)
214 tk_Frame.pack(side=tk.TOP, fill=tk.X)
216 tk_Frame = tk.Frame(tk_Win)
218 tk_Label_div_sum = tk.Label(tk_Frame, font=tk_Font_monospace)
219 tk_Label_div_sum.pack(side=tk.RIGHT, fill=tk.X)
220 tk_Frame.pack(side=tk.TOP, fill=tk.X)
223 tk_Frame = tk.Frame(tk_Win)
225 tk_Label_mobius = tk.Label(tk_Frame, font=tk_Font_monospace)
226 tk_Label_mobius.pack(side=tk.RIGHT, fill=tk.X)
227 tk_Frame.pack(side=tk.TOP, fill=tk.X)
229 tk_Frame = tk.Frame(tk_Win)
231 tk_Label_rad = tk.Label(tk_Frame, font=tk_Font_monospace)
232 tk_Label_rad.pack(side=tk.RIGHT, fill=tk.X)
233 tk_Frame.pack(side=tk.TOP, fill=tk.X)
235 tk_Frame = tk.Frame(tk_Win)
237 tk_Label_totient = tk.Label(tk_Frame, font=tk_Font_monospace)
238 tk_Label_totient.pack(side=tk.RIGHT, fill=tk.X)
239 tk_Frame.pack(side=tk.TOP, fill=tk.X)
241 tk_Frame = tk.Frame(tk_Win)
243 tk_Label_4sqr = tk.Label(tk_Frame, font=tk_Font_monospace)
244 tk_Label_4sqr.pack(side=tk.RIGHT, fill=tk.X)
245 tk_Frame.pack(side=tk.TOP, fill=tk.X)