Skip to content

Commit

Permalink
Fix dialog modality when defining new macro.
Browse files Browse the repository at this point in the history
  • Loading branch information
kliment committed Apr 16, 2012
1 parent 05058c5 commit b745987
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,18 @@ def cbutton_save(self,n,bdef,new_n=None):

def cbutton_edit(self,e,button=None):
bedit=ButtonEdit(self)
def okhandler(event):
if event.GetId()==wx.ID_OK:
if n==len(self.custombuttons):
self.custombuttons+=[None]
self.custombuttons[n]=[bedit.name.GetValue().strip(),bedit.command.GetValue().strip()]
if bedit.color.GetValue().strip()!="":
self.custombuttons[n]+=[bedit.color.GetValue()]
self.cbutton_save(n,self.custombuttons[n])
bedit.Destroy()
self.cbuttons_reload()

bedit.Bind(wx.EVT_BUTTON,okhandler)
if button is not None:
n = button.custombutton
bedit.name.SetValue(button.properties[0])
Expand All @@ -934,16 +946,9 @@ def cbutton_edit(self,e,button=None):
n = len(self.custombuttons)
while n>0 and self.custombuttons[n-1] is None:
n -= 1
if bedit.ShowModal()==wx.ID_OK:
if n==len(self.custombuttons):
self.custombuttons+=[None]
self.custombuttons[n]=[bedit.name.GetValue().strip(),bedit.command.GetValue().strip()]
if bedit.color.GetValue().strip()!="":
self.custombuttons[n]+=[bedit.color.GetValue()]
self.cbutton_save(n,self.custombuttons[n])
bedit.Destroy()
self.cbuttons_reload()

bedit.Show()


def cbutton_remove(self,e,button):
n = button.custombutton
self.custombuttons[n]=None
Expand Down Expand Up @@ -1662,6 +1667,7 @@ def __init__(self,macro_name,definition,callback,gcode=False):
topsizer.Fit(self)
self.Show()
self.e.SetFocus()

def save(self,ev):
self.Destroy()
if not self.gcode:
Expand Down Expand Up @@ -1753,6 +1759,8 @@ def __init__(self,pronterface):
topsizer.Add( (0,0),1)
topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0,wx.ALIGN_CENTER)
self.SetSizer(topsizer)
self.handler=None

def macrob_enabler(self,e):
macro = self.command.GetValue()
valid = False
Expand Down

0 comments on commit b745987

Please sign in to comment.