Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the New macro dialog is large enough #915

Merged
merged 2 commits into from
Mar 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 30 additions & 14 deletions printrun/pronterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2164,23 +2164,39 @@ def delete_macro(self, macro_name):
self.update_macros_menu()

def new_macro(self, e = None):
dialog = wx.Dialog(self, -1, _("Enter macro name"), size = (260, 85))
panel = wx.Panel(dialog, -1)
vbox = wx.BoxSizer(wx.VERTICAL)
wx.StaticText(panel, -1, _("Macro name:"), (8, 14))
dialog.namectrl = wx.TextCtrl(panel, -1, '', (110, 8), size = (130, 24), style = wx.TE_PROCESS_ENTER)
hbox = wx.BoxSizer(wx.HORIZONTAL)
okb = wx.Button(dialog, wx.ID_OK, _("Ok"), size = (60, 24))
dialog.Bind(wx.EVT_TEXT_ENTER, lambda e: dialog.EndModal(wx.ID_OK), dialog.namectrl)
hbox.Add(okb)
hbox.Add(wx.Button(dialog, wx.ID_CANCEL, _("Cancel"), size = (60, 24)))
vbox.Add(panel)
vbox.Add(hbox, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 10)
dialog.SetSizer(vbox)
dialog = wx.Dialog(self, -1, _("Enter macro name"))
text = wx.StaticText(dialog, -1, _("Macro name:"))
namectrl = wx.TextCtrl(dialog, -1, style = wx.TE_PROCESS_ENTER)
okb = wx.Button(dialog, wx.ID_OK, _("Ok"))
dialog.Bind(wx.EVT_TEXT_ENTER,
lambda e: dialog.EndModal(wx.ID_OK), namectrl)
cancel_button = wx.Button(dialog, wx.ID_CANCEL, _("Cancel"))

# Layout
## Group the buttons horizontally
buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
buttons_sizer.Add(okb, 0)
buttons_sizer.Add(cancel_button, 0)
## Set a minimum size for the name control box
min_size = namectrl.GetTextExtent('Default Long Macro Name')
namectrl.SetMinSize(wx.Size(min_size.width, -1))
## Group the text and the name control box horizontally
name_sizer = wx.BoxSizer(wx.HORIZONTAL)
name_sizer.Add(text, 0, flag = wx.ALIGN_CENTER)
name_sizer.AddSpacer(10)
name_sizer.Add(namectrl, 1, wx.EXPAND)
## Group everything vertically
dialog_sizer = wx.BoxSizer(wx.VERTICAL)
dialog_sizer.Add(name_sizer, 0, border = 10,
flag = wx.LEFT | wx.TOP | wx.RIGHT)
dialog_sizer.Add(buttons_sizer, 0, border = 10,
flag = wx.ALIGN_CENTER | wx.ALL)
dialog.SetSizerAndFit(dialog_sizer)
dialog.Centre()

macro = ""
if dialog.ShowModal() == wx.ID_OK:
macro = dialog.namectrl.GetValue()
macro = namectrl.GetValue()
if macro != "":
wx.CallAfter(self.edit_macro, macro)
dialog.Destroy()
Expand Down