Added dialog for editing templates

This commit is contained in:
Manuel Cortez 2021-12-21 09:20:59 -06:00
parent 2de9f8f9b3
commit 4434a5b971
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 39 additions and 1 deletions

View File

@ -1 +1,2 @@
from .tweetDialogs import tweet, reply, dm, viewTweet, viewNonTweet, poll
from .tweetDialogs import tweet, reply, dm, viewTweet, viewNonTweet, poll
from .templateDialogs import EditTemplateDialog

View File

@ -0,0 +1,37 @@
# -*- coding: UTF-8 -*-
import wx
class EditTemplateDialog(wx.Dialog):
def __init__(self, template, variables=[], *args, **kwds):
super(EditTemplateDialog, self).__init__(parent=None, title=_("Edit Template"), *args, **kwds)
mainSizer = wx.BoxSizer(wx.VERTICAL)
sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
mainSizer.Add(sizer_1, 1, wx.EXPAND, 0)
label_1 = wx.StaticText(self, wx.ID_ANY, _("Edit template"))
sizer_1.Add(label_1, 0, 0, 0)
self.template = wx.TextCtrl(self, wx.ID_ANY, template)
sizer_1.Add(self.template, 0, 0, 0)
sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Available variables")), wx.HORIZONTAL)
mainSizer.Add(sizer_2, 1, wx.EXPAND, 0)
self.variables = wx.ListBox(self, wx.ID_ANY, choices=["$"+v for v in variables])
self.variables.Bind(wx.EVT_CHAR_HOOK, self.on_keypress)
sizer_2.Add(self.variables, 0, 0, 0)
sizer_3 = wx.StdDialogButtonSizer()
mainSizer.Add(sizer_3, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
self.button_SAVE = wx.Button(self, wx.ID_SAVE)
self.button_SAVE.SetDefault()
sizer_3.AddButton(self.button_SAVE)
self.button_CANCEL = wx.Button(self, wx.ID_CANCEL)
sizer_3.AddButton(self.button_CANCEL)
sizer_3.Realize()
self.SetSizer(mainSizer)
mainSizer.Fit(self)
self.SetAffirmativeId(self.button_SAVE.GetId())
self.SetEscapeId(self.button_CANCEL.GetId())
self.Layout()
def on_keypress(self, event, *args, **kwargs):
if event.GetKeyCode() == wx.WXK_RETURN:
self.template.ChangeValue(self.template.GetValue()+self.variables.GetStringSelection()+", ")
return
event.Skip()