mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Added dialog for editing templates
This commit is contained in:
parent
2de9f8f9b3
commit
4434a5b971
@ -1 +1,2 @@
|
||||
from .tweetDialogs import tweet, reply, dm, viewTweet, viewNonTweet, poll
|
||||
from .templateDialogs import EditTemplateDialog
|
37
src/wxUI/dialogs/twitterDialogs/templateDialogs.py
Normal file
37
src/wxUI/dialogs/twitterDialogs/templateDialogs.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user