radio widget lists ips

This commit is contained in:
mdipierro
2012-07-26 06:42:28 -05:00
parent 6036609a3e
commit 7fafe4ae7f
2 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-26 06:06:10) dev Version 2.00.0 (2012-07-26 06:42:24) dev
+18 -11
View File
@@ -220,44 +220,48 @@ class web2pyDialog(object):
justify=Tkinter.LEFT).grid(row=0, justify=Tkinter.LEFT).grid(row=0,
column=0, column=0,
sticky=sticky) sticky=sticky)
self.ip = Tkinter.Entry(self.root) self.ips = {}
self.ip.insert(Tkinter.END, self.options.ip) self.selected_ip = Tkinter.StringVar()
self.ip.grid(row=0, column=1, sticky=sticky) for row,ip in enumerate(self.options.ips):
self.ips[ip] = Tkinter.Radiobutton(
self.root,text=ip, variable=self.selected_ip, value=ip)
self.ips[ip].grid(row=row, column=1, sticky=sticky)
if row==0: self.ips[ip].select()
shift = len(self.options.ips)
# Port # Port
Tkinter.Label(self.root, Tkinter.Label(self.root,
text='Server Port:', text='Server Port:',
justify=Tkinter.LEFT).grid(row=1, justify=Tkinter.LEFT).grid(row=shift,
column=0, column=0,
sticky=sticky) sticky=sticky)
self.port_number = Tkinter.Entry(self.root) self.port_number = Tkinter.Entry(self.root)
self.port_number.insert(Tkinter.END, self.options.port) self.port_number.insert(Tkinter.END, self.options.port)
self.port_number.grid(row=1, column=1, sticky=sticky) self.port_number.grid(row=shift, column=1, sticky=sticky)
# Password # Password
Tkinter.Label(self.root, Tkinter.Label(self.root,
text='Choose Password:', text='Choose Password:',
justify=Tkinter.LEFT).grid(row=2, justify=Tkinter.LEFT).grid(row=shift+1,
column=0, column=0,
sticky=sticky) sticky=sticky)
self.password = Tkinter.Entry(self.root, show='*') self.password = Tkinter.Entry(self.root, show='*')
self.password.bind('<Return>', lambda e: self.start()) self.password.bind('<Return>', lambda e: self.start())
self.password.focus_force() self.password.focus_force()
self.password.grid(row=2, column=1, sticky=sticky) self.password.grid(row=shift+1, column=1, sticky=sticky)
# Prepare the canvas # Prepare the canvas
self.canvas = Tkinter.Canvas(self.root, self.canvas = Tkinter.Canvas(self.root,
width=300, width=300,
height=100, height=100,
bg='black') bg='black')
self.canvas.grid(row=3, column=0, columnspan=2) self.canvas.grid(row=shift+2, column=0, columnspan=2)
self.canvas.after(1000, self.update_canvas) self.canvas.after(1000, self.update_canvas)
# Prepare the frame # Prepare the frame
frame = Tkinter.Frame(self.root) frame = Tkinter.Frame(self.root)
frame.grid(row=4, column=0, columnspan=2) frame.grid(row=shift+3, column=0, columnspan=2)
# Start button # Start button
self.button_start = Tkinter.Button(frame, self.button_start = Tkinter.Button(frame,
@@ -359,7 +363,7 @@ class web2pyDialog(object):
if not password: if not password:
self.error('no password, no web admin interface') self.error('no password, no web admin interface')
ip = self.ip.get() ip = self.selected_ip.get()
regexp = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}' regexp = '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
if ip and not re.compile(regexp).match(ip): if ip and not re.compile(regexp).match(ip):
@@ -790,6 +794,9 @@ def console():
global_settings.cmd_options = options global_settings.cmd_options = options
global_settings.cmd_args = args global_settings.cmd_args = args
# detect all ips:
options.ips = ['127.0.0.1']+[ip for ip in socket.gethostbyname_ex('')[2] if not ip.startswith("127.")]+['0.0.0.0']
if options.run_system_tests: if options.run_system_tests:
run_system_tests() run_system_tests()