def OnImport(self, event): dlg = wx.FileDialog(self.m_parent, message('import_from_file'), itrade_config.dirImport, "", "*.txt", wx.OPEN | wx.FILE_MUST_EXIST) if dlg.ShowModal() == wx.ID_OK: dirname = dlg.GetDirectory() filename = dlg.GetFilename() file = os.path.join(dirname, filename) if itrade_config.verbose: print 'Import file %s for quote %s' % (file, self.m_quote.key()) # clear everything self.m_quote.flushTrades() # import the file self.m_quote.loadTrades(file) self.m_quote.saveTrades() # be sure indicators have been updated self.m_quote.compute() iTradeInformation(self, message('imported_from_file') % file, message('import_from_file')) dlg.Destroy() dlg = None # force a refresh on the root window if self.m_wincb: self.m_wincb.OnRefresh() if dlg: dlg.Destroy()
def OnImport(self,event): dlg = wx.FileDialog(self.m_parent, message('import_from_file'), itrade_config.dirImport, "", "*.txt", wx.OPEN|wx.FILE_MUST_EXIST) if dlg.ShowModal() == wx.ID_OK: dirname = dlg.GetDirectory() filename = dlg.GetFilename() file = os.path.join(dirname,filename) if itrade_config.verbose: print 'Import file %s for quote %s' % (file,self.m_quote.key()) # clear everything self.m_quote.flushTrades() # import the file self.m_quote.loadTrades(file) self.m_quote.saveTrades() # be sure indicators have been updated self.m_quote.compute() iTradeInformation(self, message('imported_from_file') % file, message('import_from_file')) dlg.Destroy() dlg = None # force a refresh on the root window if self.m_wincb: self.m_wincb.OnRefresh() if dlg: dlg.Destroy()
def OnCancel(self, event): if self.m_dirty: #__dlg = wx.MessageDialog(self, message('listquote_dirty_save'), message('listquote_save_desc'), wx.CANCEL | wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) #__idRet = dlg.ShowModal() #__xdlg.Destroy() idRet = iTradeYesNo(self, message('listquote_dirty_save'), message('listquote_save_desc'), bCanCancel=True) if idRet == wx.ID_YES: self.OnSave(None) res = True elif idRet == wx.ID_NO: #__xdlg = wx.MessageDialog(self, message('listquote_nodirty_save'), message('listquote_save_desc'), wx.OK | wx.ICON_INFORMATION) #__xdlg.ShowModal() #__xdlg.Destroy() iTradeInformation(self, message('listquote_nodirty_save'), message('listquote_save_desc')) res = True else: res = False else: res = True if res: self.EndModal(wx.ID_CANCEL)
def OnSave(self,event): self.m_dirty = False quotes.saveListOfQuotes() #__xdlg = wx.MessageDialog(self, message('listquote_saved'), message('listquote_save_desc'), wx.OK | wx.OK | wx.ICON_INFORMATION) #__xdlg.ShowModal() #__xdlg.Destroy() iTradeInformation(self, message('listquote_saved'), message('listquote_save_desc'))
def OnSave(self, event): self.m_dirty = False quotes.saveListOfQuotes() #__xdlg = wx.MessageDialog(self, message('listquote_saved'), message('listquote_save_desc'), wx.OK | wx.OK | wx.ICON_INFORMATION) #__xdlg.ShowModal() #__xdlg.Destroy() iTradeInformation(self, message('listquote_saved'), message('listquote_save_desc'))
def OnTest(self,event): u = self.wxUsernameCtrl.GetValue().strip() p = self.wxPasswordCtrl.GetValue().strip() ret = self.m_connector.login(u,p) self.m_connector.logout() if ret: #__xdlg = wx.MessageDialog(self, message('login_test_ok'), message('login_testdesc') + ' - ' + self.m_connector.name(), wx.OK | wx.ICON_INFORMATION) iTradeInformation(self, message('login_test_ok'), message('login_testdesc') + ' - ' + self.m_connector.name()) else: #__xdlg = wx.MessageDialog(self, message('login_test_nok'), message('login_testdesc') + ' - ' + self.m_connector.name(), wx.OK | wx.ICON_INFORMATION) iTradeError(self, message('login_test_nok'), message('login_testdesc') + ' - ' + self.m_connector.name())
def OnExport(self,event): dlg = wx.FileDialog(self.m_parent, message('export_to_file'), itrade_config.dirExport, "", "*.txt", wx.SAVE|wx.OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: dirname = dlg.GetDirectory() filename = dlg.GetFilename() file = os.path.join(dirname,filename) if itrade_config.verbose: print 'Export file %s for quote %s' % (file,self.m_quote.key()) self.m_quote.saveTrades(file) iTradeInformation(self,message('exported_to_file') % file, message('export_to_file')) # dlg.Destroy()
def OnTest(self, event): u = self.wxUsernameCtrl.GetValue().strip() p = self.wxPasswordCtrl.GetValue().strip() ret = self.m_connector.login(u, p) self.m_connector.logout() if ret: #__xdlg = wx.MessageDialog(self, message('login_test_ok'), message('login_testdesc') + ' - ' + self.m_connector.name(), wx.OK | wx.ICON_INFORMATION) iTradeInformation( self, message('login_test_ok'), message('login_testdesc') + ' - ' + self.m_connector.name()) else: #__xdlg = wx.MessageDialog(self, message('login_test_nok'), message('login_testdesc') + ' - ' + self.m_connector.name(), wx.OK | wx.ICON_INFORMATION) iTradeError( self, message('login_test_nok'), message('login_testdesc') + ' - ' + self.m_connector.name())
def OnExport(self,event): dlg = wx.FileDialog(self.m_parent, message('export_to_file'), itrade_config.dirExport, "", "*.txt", wx.SAVE|wx.OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: dirname = dlg.GetDirectory() filename = dlg.GetFilename() file = os.path.join(dirname,filename) info('Export file %s' % file) self.m_quote.saveTrades(file) #__xdlg2 = wx.MessageDialog(self, message('exported_to_file') % file, message('export_to_file'), wx.OK | wx.ICON_INFORMATION) #__xdlg2.ShowModal() #__xdlg2.Destroy() iTradeInformation(self,message('exported_to_file') % file, message('export_to_file')) # dlg.Destroy()
def OnImport(self,event): dlg = wx.FileDialog(self.m_parent, message('import_from_file'), itrade_config.dirImport, "", "*.txt", wx.OPEN|wx.FILE_MUST_EXIST) if dlg.ShowModal() == wx.ID_OK: dirname = dlg.GetDirectory() filename = dlg.GetFilename() file = os.path.join(dirname,filename) info('Import file %s' % file) self.m_quote.loadTrades(file) self.m_quote.saveTrades() # __xdlg2 = wx.MessageDialog(self, message('imported_from_file') % file, message('import_from_file'), wx.OK | wx.ICON_INFORMATION) # __xdlg2.ShowModal() # __xdlg2.Destroy() iTradeInformation(self, message('imported_from_file') % file, message('import_from_file')) dlg.Destroy()
def OnCheckSoftware(self,e): # can be long ... wx.SetCursor(wx.HOURGLASS_CURSOR) url = itrade_config.checkNewRelease() # restore wx.SetCursor(wx.STANDARD_CURSOR) if url=='ok': iTradeInformation(self,message('checksoftware_uptodate'),message('checksoftware_title')) elif url=='dev': iTradeInformation(self,message('checksoftware_development'),message('checksoftware_title')) elif url=='err': iTradeError(self,message('checksoftware_error'),message('checksoftware_title')) else: if iTradeYesNo(self,message('checksoftware_needupdate'),message('checksoftware_title'))==wx.ID_YES: iTradeLaunchBrowser(url,new=True)
def OnCancel(self,event): if self.m_dirty: #__dlg = wx.MessageDialog(self, message('listquote_dirty_save'), message('listquote_save_desc'), wx.CANCEL | wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION) #__idRet = dlg.ShowModal() #__xdlg.Destroy() idRet = iTradeYesNo(self, message('listquote_dirty_save'), message('listquote_save_desc'),bCanCancel=True) if idRet == wx.ID_YES: self.OnSave(None) res = True elif idRet == wx.ID_NO: #__xdlg = wx.MessageDialog(self, message('listquote_nodirty_save'), message('listquote_save_desc'), wx.OK | wx.ICON_INFORMATION) #__xdlg.ShowModal() #__xdlg.Destroy() iTradeInformation(self, message('listquote_nodirty_save'), message('listquote_save_desc')) res = True else: res = False else: res = True if res: self.EndModal(wx.ID_CANCEL)