Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion LibPanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def __init__(self, parent, name):
chargedDomainList = eval(cfg_domain_list) if cfg_domain_list else []

self.tree.Populate(chargedDomainList)

self.tree.UnselectAll()

### search tree that is hide when starting devsimpy (see __do_layout)
self.searchTree = LibraryTree(self, wx.NewIdRef(), wx.DefaultPosition, style=wx.TR_DEFAULT_STYLE|wx.TR_HIDE_ROOT|wx.TR_MULTIPLE|wx.TR_LINES_AT_ROOT|wx.TR_HAS_BUTTONS|wx.SUNKEN_BORDER)
Expand Down Expand Up @@ -107,7 +109,7 @@ def BuildToolbar(self):
Only one of them is pressed at a time. The SetMode() method handles this
"""

tb = wx.ToolBar(self, -1)
tb = wx.ToolBar(self, wx.NewIdRef())
#self.ToolBar = tb
tb.SetToolBitmapSize((16,16))# this required for non-standard size buttons on MSW

Expand Down
12 changes: 5 additions & 7 deletions LibraryTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, *args, **kwargs):
""" Constructor.
"""

wx.TreeCtrl.__init__(self, *args, **kwargs)
super(LibraryTree, self).__init__(*args, **kwargs)

### association between path (key) and tree item (value)
self.ItemDico = {}
Expand Down Expand Up @@ -153,7 +153,6 @@ def Populate(self, chargedDomainList = []):
#).start()
self.InsertNewDomain(absdName, self.root, list(self.GetSubDomain(absdName, self.GetDomainList(absdName)).values())[0])

self.UnselectAll()
wx.CallAfter(self.SortChildren,self.root)

###
Expand Down Expand Up @@ -277,18 +276,17 @@ def OnDelete(self, evt):
""" Delete the item from Tree
"""

item = self.GetSelection()
item = self.GetFocusedItem()
path = self.GetItemPyData(item)

print(item)
if item:
if path and os.path.exists(path):
### msgbox to select what you wan to delete: file or/and item ?
db = DeleteBox(self, wx.NewIdRef(), _("Delete Options"))

if db.ShowModal() == wx.ID_OK:

### delete file
if db.rb2.GetValue():
path = self.GetItemPyData(item)
label = os.path.basename(path)
dial = wx.MessageDialog(None, _('Are you sure to delete the python file %s ?')%(label), label, wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
if dial.ShowModal() == wx.ID_YES:
Expand All @@ -310,7 +308,7 @@ def OnDelete(self, evt):
###TODO unload associated module

else:
wx.MessageBox(_("No model selected!"),_("Delete Manager"))
wx.MessageBox(_("No library selected!"),_("Delete Manager"))

###
def OnNewModel(self, evt):
Expand Down
2 changes: 1 addition & 1 deletion Reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def OnButton(self, evt):
if e_id == wx.ID_CLOSE:
self.Close()
elif e_id == ID_SEND:
frame = SendMailWx()
frame = SendMailWx(None)
msg = self.err_msg
msg = msg.replace("'", '')
frame.messageTxt.SetValue(msg)
Expand Down
14 changes: 9 additions & 5 deletions devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,11 @@ def EnableAbstractionButton(self):
### update text filed
level = self.spin.GetValue()

tb = self.GetToolBar()

### update doward and upward button
self.tb.EnableTool(self.toggle_list[4], level != 0)
self.tb.EnableTool(self.toggle_list[5], level != 0)
tb.EnableTool(self.toggle_list[4], level != 0)
tb.EnableTool(self.toggle_list[5], level != 0)

def OnDeleteRecentFiles(self, event):
""" Delete the recent files list
Expand Down Expand Up @@ -1285,8 +1287,9 @@ def OnSaveFile(self, event):
# Refresh canvas
currentPage.Refresh()

tb = self.GetToolBar()
### enable save button on status bar
self.tb.EnableTool(Menu.ID_SAVE, diagram.modify)
tb.EnableTool(Menu.ID_SAVE, diagram.modify)

#self.statusbar.SetStatusText(_('%s saved')%diagram.last_name_saved)
else:
Expand Down Expand Up @@ -1362,8 +1365,9 @@ def OnSaveAsFile(self, event):
else:
self.nb2.AddEditPage(label, diagram)

tb = self.GetToolBar()
### enable save button on status bar
self.tb.EnableTool(Menu.ID_SAVE, diagram.modify)
tb.EnableTool(Menu.ID_SAVE, diagram.modify)
else:
wx.MessageBox(_('Error saving file.'), _('Error'), wx.OK | wx.ICON_ERROR)

Expand Down Expand Up @@ -2038,7 +2042,7 @@ def OnAbout(self, event):
def OnContact(self, event):
""" Launches the mail program to contact the DEVSimPy author. """

frame = SendMailWx()
frame = SendMailWx(None)
frame.Show()

##-------------------------------------------------------------------
Expand Down
94 changes: 55 additions & 39 deletions wxPyMail.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import sys
import urllib.request, urllib.parse, urllib.error
import wx
import wx.lib.agw.hyperlink as hl

_ = wx.GetTranslation

Expand All @@ -39,27 +40,25 @@
from email.message import Message

class SendMailWx(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, -1, _('New Email Message (From Google account)'),
size=(600,400))
self.panel = wx.Panel(self, wx.NewIdRef())

def __init__(self, *args, **kw):
super(SendMailWx, self).__init__(*args, **kw)

# set your email address here
self.email = 'your_email@gmail.com'

self.filepaths = []
self.currentDir = os.getcwd()

self.InitUI()

def InitUI(self):

self.panel = wx.Panel(self, wx.NewIdRef())

self.createMenu()
self.createToolbar()
self.createWidgets()
# try:
# print sys.argv
# self.parseURL(sys.argv[1])
# except Exception, e:
# print 'Unable to execute parseURL...'
# print e

self.createWidgets()
self.layoutWidgets()

self.attachTxt.Hide()
Expand All @@ -81,19 +80,20 @@ def createMenu(self):
def createToolbar(self):
tb = wx.ToolBar(self, wx.NewIdRef(), name='tb', style=wx.TB_HORIZONTAL | wx.NO_BORDER)
tb.SetToolBitmapSize((16,16))
sendTool = tb.AddTool(-1, _('Send'), wx.Bitmap(os.path.join(ICON_PATH_16_16,'mail.png')), _('Sends Email'))
sendTool = tb.AddTool(wx.NewIdRef(), _('Send'), wx.Bitmap(os.path.join(ICON_PATH_16_16,'mail.png')), _('Sends Email'))
self.Bind(wx.EVT_MENU, self.OnSend, sendTool)
tb.Realize()
self.SetToolBar(tb)

def createWidgets(self):
p = self.panel

font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
self.fromLbl = wx.StaticText(p, wx.NewIdRef(), _('From'), size=(60,-1))
self.fromLbl = wx.StaticText(p, wx.NewIdRef(), _('From:'), size=(70,-1))
self.fromTxt = wx.TextCtrl(p, wx.NewIdRef(), self.email)
self.toLbl = wx.StaticText(p, wx.NewIdRef(), _('To:'), size=(60,-1))
self.toLbl = wx.StaticText(p, wx.NewIdRef(), _('To:'), size=(70,-1))
self.toTxt = wx.TextCtrl(p, wx.NewIdRef(), 'capocchi_l@univ-corse.fr')
self.subjectLbl = wx.StaticText(p, wx.NewIdRef(), _(' Subject:'), size=(60,-1))
self.subjectLbl = wx.StaticText(p, wx.NewIdRef(), _('Subject:'), size=(70,-1))
self.subjectTxt = wx.TextCtrl(p, wx.NewIdRef(), '')
self.attachBtn = wx.Button(p, wx.NewIdRef(), _('Attachments'))
self.attachTxt = wx.TextCtrl(p, wx.NewIdRef(), '', style=wx.TE_MULTILINE)
Expand All @@ -102,6 +102,18 @@ def createWidgets(self):

self.messageTxt = wx.TextCtrl(p, wx.NewIdRef(), '', style=wx.TE_MULTILINE)

# Web link with underline rollovers, opens in same window
self.url = hl.HyperLinkCtrl(self.panel, -1, "Allow the access to Google for your less secure app", pos=(100, 150), URL="https://myaccount.google.com/lesssecureapps?pli=1")

self.url.AutoBrowse(True)
self.url.SetColours("BLUE", "BLUE", "BLUE")
self.url.EnableRollover(True)
self.url.SetUnderlines(False, False, True)
self.url.SetBold(True)
#self.url.OpenInSameWindow(True)
self.url.SetToolTip(wx.ToolTip("In a nutshell, google is not allowing you to log in via smtplib because it has flagged this sort of login as 'less secure', so what you have to do is go to this link while you're logged in to your google account, and allow the access"))
self.url.UpdateLink()

self.Bind(wx.EVT_BUTTON, self.onAttach, self.attachBtn)
self.Bind(wx.EVT_BUTTON, self.onAttachEdit, self.editAttachBtn)

Expand All @@ -117,11 +129,11 @@ def layoutWidgets(self):
attachSizer = wx.BoxSizer(wx.HORIZONTAL)

fromSizer.Add(self.fromLbl, 0)
fromSizer.Add(self.fromTxt, 1, wx.EXPAND)
fromSizer.Add(self.fromTxt, 1, wx.EXPAND|wx.ALL)
toSizer.Add(self.toLbl, 0)
toSizer.Add(self.toTxt, 1, wx.EXPAND)
toSizer.Add(self.toTxt, 1, wx.EXPAND|wx.ALL)
subjSizer.Add(self.subjectLbl, 0)
subjSizer.Add(self.subjectTxt, 1, wx.EXPAND)
subjSizer.Add(self.subjectTxt, 1, wx.EXPAND|wx.ALL)
attachSizer.Add(self.attachBtn, 0, wx.ALL, 5)
attachSizer.Add(self.attachTxt, 1, wx.ALL|wx.EXPAND, 5)
attachSizer.Add(self.editAttachBtn, 0, wx.ALL, 5)
Expand All @@ -131,8 +143,13 @@ def layoutWidgets(self):
mainSizer.Add(subjSizer, 0, wx.ALL|wx.EXPAND, 5)
mainSizer.Add(attachSizer, 0, wx.ALL|wx.EXPAND, 5)
mainSizer.Add(self.messageTxt, 1, wx.ALL|wx.EXPAND, 5)
self.panel.SetSizer(mainSizer)
self.panel.Layout()
mainSizer.Add(self.url, 1, wx.ALL|wx.EXPAND, 5)

self.SetTitle(('New Email Message (From Google account)'))

self.panel.SetSizerAndFit(mainSizer)
self.panel.SetAutoLayout(True)
self.Fit()

def parseURL(self, url):
# split out the mailto
Expand Down Expand Up @@ -362,7 +379,6 @@ def onCancel(self, event):
self.Close()

def onDelete(self, event):
print('in onDelete')
numberOfPaths = len(self.filepaths)
for item in range(numberOfPaths):
val = self.chkList.IsChecked(item)
Expand All @@ -384,9 +400,9 @@ def __init__(self, server):
self.loggedIn = False

# widgets
userLbl = wx.StaticText(self, wx.NewIdRef(), _('Username:'), size=(50, -1))
userLbl = wx.StaticText(self, wx.NewIdRef(), _('Username:'), size=(70, -1))
self.userTxt = wx.TextCtrl(self, wx.NewIdRef(), '', size=(150, -1))
passwordLbl = wx.StaticText(self, wx.NewIdRef(), _('Password:'), size=(50, -1))
passwordLbl = wx.StaticText(self, wx.NewIdRef(), _('Password:'), size=(70, -1))
self.passwordTxt = wx.TextCtrl(self, wx.NewIdRef(), '', size=(150, -1),
style=wx.TE_PROCESS_ENTER|wx.TE_PASSWORD)
loginBtn = wx.Button(self, wx.ID_YES, _('Login'))
Expand All @@ -412,7 +428,7 @@ def __init__(self, server):
mainSizer.Add(passwordSizer, 0, wx.ALL, 0)
mainSizer.Add(btnSizer, 0, wx.ALL|wx.CENTER, 5)

self.SetSizer(mainSizer)
self.SetSizerAndFit(mainSizer)
self.Fit()
self.Layout()

Expand All @@ -426,19 +442,19 @@ def OnLogin(self, event):
If correct, the email will attempt to be sent. If incorrect, the user
will be notified.
'''
#try:
user = self.userTxt.GetValue()
pw = self.passwordTxt.GetValue()
self.server.starttls()
self.server.ehlo()
res = self.server.login(user, pw)
self.loggedIn = True
self.OnClose('')
#except:
# message = _('Your username or password is incorrect. Please try again.')
# dlg = wx.MessageDialog(None, message, _('Login Error'), wx.OK|wx.ICON_EXCLAMATION)
# dlg.ShowModal()
# dlg.Destroy()
try:
user = self.userTxt.GetValue()
pw = self.passwordTxt.GetValue()
self.server.starttls()
self.server.ehlo()
res = self.server.login(user, pw)
self.loggedIn = True
self.OnClose('')
except:
message = _('Your username or password is incorrect. Please try again.')
dlg = wx.MessageDialog(None, message, _('Login Error'), wx.OK|wx.ICON_EXCLAMATION)
dlg.ShowModal()
dlg.Destroy()

def OnClose(self, event):
self.Close()
Expand All @@ -448,6 +464,6 @@ def OnClose(self, event):
# Start program
if __name__ == '__main__':
app = wx.App()
frame = SendMailWx()
frame = SendMailWx(None)
frame.Show()
app.MainLoop()