Commit b7459878 authored by Kliment Yanev's avatar Kliment Yanev

Fix dialog modality when defining new macro.

parent 05058c5b
...@@ -916,6 +916,18 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -916,6 +916,18 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
def cbutton_edit(self,e,button=None): def cbutton_edit(self,e,button=None):
bedit=ButtonEdit(self) 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: if button is not None:
n = button.custombutton n = button.custombutton
bedit.name.SetValue(button.properties[0]) bedit.name.SetValue(button.properties[0])
...@@ -934,16 +946,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole): ...@@ -934,16 +946,9 @@ class PronterWindow(wx.Frame,pronsole.pronsole):
n = len(self.custombuttons) n = len(self.custombuttons)
while n>0 and self.custombuttons[n-1] is None: while n>0 and self.custombuttons[n-1] is None:
n -= 1 n -= 1
if bedit.ShowModal()==wx.ID_OK: bedit.Show()
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()
def cbutton_remove(self,e,button): def cbutton_remove(self,e,button):
n = button.custombutton n = button.custombutton
self.custombuttons[n]=None self.custombuttons[n]=None
...@@ -1662,6 +1667,7 @@ class macroed(wx.Dialog): ...@@ -1662,6 +1667,7 @@ class macroed(wx.Dialog):
topsizer.Fit(self) topsizer.Fit(self)
self.Show() self.Show()
self.e.SetFocus() self.e.SetFocus()
def save(self,ev): def save(self,ev):
self.Destroy() self.Destroy()
if not self.gcode: if not self.gcode:
...@@ -1753,6 +1759,8 @@ class ButtonEdit(wx.Dialog): ...@@ -1753,6 +1759,8 @@ class ButtonEdit(wx.Dialog):
topsizer.Add( (0,0),1) topsizer.Add( (0,0),1)
topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0,wx.ALIGN_CENTER) topsizer.Add(self.CreateStdDialogButtonSizer(wx.OK|wx.CANCEL),0,wx.ALIGN_CENTER)
self.SetSizer(topsizer) self.SetSizer(topsizer)
self.handler=None
def macrob_enabler(self,e): def macrob_enabler(self,e):
macro = self.command.GetValue() macro = self.command.GetValue()
valid = False valid = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment