def initializeFinancialDataFile(self): # Store all financial data in a .csv file: self.financialDataStore = open("mediaFilesPackage/FinancialData.csv", "a") #financialDataRead = open("mediaFilesPackage/FinancialData.csv", "r") firstLineString = "Category;Payment Type;Account;Currency;Amount;Expense;Date;Time;Warranty (months)" firstCsvLine = textFileOperations.textFileToString("mediaFilesPackage/FinancialData.csv").split('\n', 1)[0] if firstCsvLine != firstLineString: # Specify content of csv file with first line: self.financialDataStore.write(firstLineString+"\n")
def __init__(self): wx.Frame.__init__(self, None, -1, 'MyContacts', size=(720, 480), style=wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.CAPTION) #load application's icon self.icon = wx.Icon('mediaFilesPackage/contacts.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) #Create Menus menuFile = wx.Menu() save = wx.MenuItem(menuFile, 1, '&Save', 'Save your work!') save.SetBitmap(wx.Image('mediaFilesPackage/save.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()) menuFile.AppendItem(save) exit = wx.MenuItem(menuFile, 2, '&Quit', 'Quit the Application') exit.SetBitmap(wx.Image('mediaFilesPackage/exitIcon.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()) menuFile.AppendItem(exit) menuAbout = wx.Menu() about = wx.MenuItem(menuAbout, 3, '&About MyContacts', 'See information about MyContacts') about.SetBitmap(wx.Image('mediaFilesPackage/about.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()) menuAbout.AppendItem(about) #Create the Menu Bar which contains all of the above Menus menuBar = wx.MenuBar() menuBar.Append(menuFile, "&File") menuBar.Append(menuAbout, "&About") self.SetMenuBar(menuBar) self.CreateStatusBar() #Assign to each menu option an event which will be assigned to a function self.Bind(wx.EVT_MENU, self.OnSaveContacts, id=1) self.Bind(wx.EVT_MENU, self.OnContactsQuit, id=2) self.Bind(wx.EVT_MENU, self.OnAboutMyContacts, id=3) # Create a panel and add to it the text Field: panel = wx.Panel(self, -1) multiLabel = wx.StaticText(panel, -1) gotoMainFolderDirectory.go() contacts = textFileOperations.textFileToString("mediaFilesPackage/contactsFile.txt") self.multiText = wx.TextCtrl(panel, -1,contacts,size=(435, 410), style=wx.TE_MULTILINE) self.multiText.SetInsertionPoint(0) #load MyContacts picture image = wx.Image('mediaFilesPackage/MyContacts.jpg', wx.BITMAP_TYPE_ANY) self.imageBitmap = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(image)) sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6) sizer.AddMany([self.multiText, self.imageBitmap]) panel.SetSizer(sizer) #Set background colour self.SetBackgroundColour('#1485CC')
def OnExport(self, event): dlg = wx.FileDialog(self, "Save project as...", "", "", "CSV File (*.csv) | *.csv", wx.SAVE | wx.OVERWRITE_PROMPT) if dlg.ShowModal() == wx.ID_OK: # Grab the content to be saved content = textFileOperations.textFileToString("mediaFilesPackage/FinancialData.csv") # Open the file for write, write, close self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() filehandle=open(os.path.join(self.dirname, self.filename),'w') filehandle.write(content) filehandle.close() # Get rid of the dialog to keep things tidy dlg.Destroy()
def __init__(self): wx.Frame.__init__(self, None, -1, 'My Notes', size=(720, 480), style=wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.MINIMIZE_BOX | wx.CAPTION) #load application's icon self.icon = wx.Icon('mediaFilesPackage/mynotes.ico', wx.BITMAP_TYPE_ICO) self.SetIcon(self.icon) # Create menu File and add to it menu options menuFile = wx.Menu() save = wx.MenuItem(menuFile, 1, '&Save', 'Save your work!') save.SetBitmap(wx.Image('mediaFilesPackage/save.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()) menuFile.AppendItem(save) exit = wx.MenuItem(menuFile, 2, '&Quit', 'Quit the Application') exit.SetBitmap(wx.Image('mediaFilesPackage/exitIcon.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()) menuFile.AppendItem(exit) # Create menu About and add to it menu options menuAbout = wx.Menu() about = wx.MenuItem(menuAbout, 3, '&About MyNotes', 'See information about MyNotes') about.SetBitmap(wx.Image('mediaFilesPackage/about.png', wx.BITMAP_TYPE_PNG).ConvertToBitmap()) menuAbout.AppendItem(about) # Create menu Bar whare the above menus are placed: menuBar = wx.MenuBar() menuBar.Append(menuFile, "&File") menuBar.Append(menuAbout, "&About") self.SetMenuBar(menuBar) self.CreateStatusBar() self.Bind(wx.EVT_MENU, self.OnSaveNotes, id=1) self.Bind(wx.EVT_MENU, self.OnNotesQuit, id=2) self.Bind(wx.EVT_MENU, self.OnAboutMyNotes, id=3) # Create a panel and add to it the text field: panel = wx.Panel(self, -1) multiLabel = wx.StaticText(panel, -1) notes = textFileOperations.textFileToString("mediaFilesPackage/notesFile.txt") self.multiText = wx.TextCtrl(panel, -1,notes,size=(550, 480), style=wx.TE_MULTILINE) self.multiText.SetInsertionPoint(0) #load MyNotes picture image = wx.Image('mediaFilesPackage/MyNotes.jpg', wx.BITMAP_TYPE_ANY) self.imageBitmap = wx.StaticBitmap(panel, wx.ID_ANY, wx.BitmapFromImage(image)) sizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6) sizer.AddMany([self.multiText, self.imageBitmap]) panel.SetSizer(sizer) #Set background colour self.SetBackgroundColour('#1485CC')
def nameDayDictionaryCreation(): gotoMainFolderDirectory.go() dataString = textFileOperations.textFileToString("mediaFilesPackage/eortes.dat") dataList = dataString.split('\n\n') nameDayDictionary = {} for day in dataList: dayList = day.split("\n") date = dayList[0] date = date.split(" ") date = date[0] dayList.pop(0) dayString = "" for name in dayList: name = name.strip() name = name.replace("(", "") name = name.replace(")", "") namesList = name.split(",") name = "" if len(namesList) > 1: name += "(" for i in range(len(namesList)): namesList[i] = greeklish.greekStringToGreeklishString(namesList[i]) name += namesList[i]+"," if len(namesList) > 1: name += ")" dayString += name+"\n" # put date and names in dictionary # dictionary key: date, format: "day/month" # dictionary value: names, type:String nameDayDictionary.update({date:dayString}) return nameDayDictionary # Uncomment to check function nameDayDictionaryCreation() #print nameDayDictionaryCreation()