Skip to content

Commit

Permalink
Improved profiles modification
Browse files Browse the repository at this point in the history
  • Loading branch information
pnprog committed Oct 2, 2018
1 parent f912fce commit 8d51703
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 82 deletions.
4 changes: 3 additions & 1 deletion aq_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ def __init__(self,parent,bot="AQ"):
Label(buttons_frame,text="").grid(row=row,column=1)
row+=1
Label(buttons_frame,text=_("See AQ parameters in \"aq_config.txt\"")).grid(row=row,column=1,columnspan=2,sticky=W)


self.index=-1

self.bot_gtp=AQ_gtp

class AQSettings_old(Frame):
Expand Down
51 changes: 19 additions & 32 deletions gnugo_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,13 +367,26 @@ def __init__(self,parent,bot="GnuGo"):
Button(buttons_frame, text=_("Test"),command=lambda: self.parent.parent.test(self.bot_gtp,self.command,self.parameters)).grid(row=row,column=4,sticky=W)
self.listbox.bind("<Button-1>", lambda e: self.after(100,self.change_selection))

self.index=-1

self.bot_gtp=GnuGo_gtp


def clear_selection(self):
self.index=-1
self.profile.set("")
self.command.set("")
self.parameters.set("")
self.variations.set("")
self.deepness.set("")

def change_selection(self):
try:
index=self.listbox.curselection()[0]
self.index=index
except:
log("No selection")
self.clear_selection()
return
data=self.profiles[index]
self.profile.set(data["profile"])
Expand All @@ -396,22 +409,18 @@ def add_profile(self):
self.empty_profiles()
profiles.append(data)
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.variations.set("")
self.deepness.set("")
self.clear_selection()

def modify_profile(self):
profiles=self.profiles
if self.profile.get()=="":
return
try:
index=self.listbox.curselection()[0]
except:

if self.index<0:
log("No selection")
return
index=self.index

profiles[index]["profile"]=self.profile.get()
profiles[index]["command"]=self.command.get()
profiles[index]["parameters"]=self.parameters.get()
Expand All @@ -420,29 +429,7 @@ def modify_profile(self):

self.empty_profiles()
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.variations.set("")
self.deepness.set("")

def delete_profile(self):
profiles=self.profiles
try:
index=self.listbox.curselection()[0]
except:
log("No selection")
return
self.empty_profiles()
del profiles[index]
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.variations.set("")
self.deepness.set("")
self.clear_selection()


class GnuGoSettings_old(Frame):
Expand Down
46 changes: 17 additions & 29 deletions leela_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,13 +445,24 @@ def __init__(self,parent,bot="Leela"):

self.listbox.bind("<Button-1>", lambda e: self.after(100,self.change_selection))

self.index=-1

self.bot_gtp=Leela_gtp

def clear_selection(self):
self.index=-1
self.profile.set("")
self.command.set("")
self.parameters.set("")
self.timepermove.set("")

def change_selection(self):
try:
index=self.listbox.curselection()[0]
self.index=index
except:
log("No selection")
self.clear_selection()
return
data=self.profiles[index]
self.profile.set(data["profile"])
Expand All @@ -473,50 +484,27 @@ def add_profile(self):
self.empty_profiles()
profiles.append(data)
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.timepermove.set("")
self.clear_selection()

def modify_profile(self):
profiles=self.profiles
if self.profile.get()=="":
return
try:
index=self.listbox.curselection()[0]
except:

if self.index<0:
log("No selection")
return
index=self.index

profiles[index]["profile"]=self.profile.get()
profiles[index]["command"]=self.command.get()
profiles[index]["parameters"]=self.parameters.get()
profiles[index]["timepermove"]=self.timepermove.get()

self.empty_profiles()
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.timepermove.set("")
self.clear_selection()

def delete_profile(self):
profiles=self.profiles
try:
index=self.listbox.curselection()[0]
except:
log("No selection")
return
self.empty_profiles()
del profiles[index]
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.timepermove.set("")



class LeelaSettings_old(Frame):
Expand Down
43 changes: 23 additions & 20 deletions toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2388,12 +2388,22 @@ def __init__(self,parent,bot):
Button(buttons_frame, text=_("Test"),command=lambda: self.parent.parent.test(self.bot_gtp,self.command,self.parameters)).grid(row=row,column=4,sticky=W)
self.listbox.bind("<Button-1>", lambda e: self.after(100,self.change_selection))


self.index=-1

def clear_selection(self):
self.index=-1
self.profile.set("")
self.command.set("")
self.parameters.set("")

def change_selection(self):
try:
index=self.listbox.curselection()[0]
self.index=index
log("Profile",index,"selected")
except:
log("No selection")
self.clear_selection()
return
data=self.profiles[index]
self.profile.set(data["profile"])
Expand All @@ -2406,7 +2416,6 @@ def empty_profiles(self):
for bot in [profile["bot"] for profile in profiles]:
for section in sections:
if bot+"-" in section:
print "removing section",section
grp_config.remove_section(section)
self.update_listbox()

Expand All @@ -2432,45 +2441,39 @@ def add_profile(self):
self.empty_profiles()
profiles.append(data)
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.clear_selection()


def modify_profile(self):
profiles=self.profiles
if self.profile.get()=="":
return
try:
index=self.listbox.curselection()[0]
except:

if self.index<0:
log("No selection")
return
index=self.index

profiles[index]["profile"]=self.profile.get()
profiles[index]["command"]=self.command.get()
profiles[index]["parameters"]=self.parameters.get()

self.empty_profiles()
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.clear_selection()

def delete_profile(self):
profiles=self.profiles
try:
index=self.listbox.curselection()[0]
except:

if self.index<0:
log("No selection")
return
index=self.index

self.empty_profiles()
del profiles[index]
self.create_profiles()

self.profile.set("")
self.command.set("")
self.parameters.set("")
self.clear_selection()


def update_listbox(self):
Expand Down

0 comments on commit 8d51703

Please sign in to comment.