i am sorry to bother you once again, but another problem has occurred, now, the save as dialog is acting up as well with a different error, first i shall post the traceback and after that will be the code, and please note, i tried my best to solve this problem before posting up her again
Traceback (most recent call last):
File "window.py", line 46, in <module>
frame = GUI()
File "window.py", line 15, in __init__
self.Bind(wx.EVT_MENU, self.SaveAs, saveas)
NameError: name 'saveas' is not defined
and here is the code
import os
import wx
class GUI(wx.Frame):
def __init__(self):
super().__init__(parent=None, title='Spirit')
controls = wx.Panel(self)
text_field = wx.TextCtrl(controls,style = wx.TE_MULTILINE|wx.TE_PROCESS_TAB|wx.TE_NOHIDESEL)
menuBar = wx.MenuBar()
firstMenu = wx.Menu()
new = firstMenu.Append(wx.ID_NEW, "New")
open = firstMenu.Append(wx.ID_OPEN, "Open")
self.Bind(wx.EVT_MENU, self.Open, open)
save = firstMenu.Append(wx.ID_SAVE, "Save")
saveAs = firstMenu.Append(wx.ID_SAVEAS, "Save As")
self.Bind(wx.EVT_MENU, self.SaveAs, saveas)
print = firstMenu.Append(wx.ID_PRINT, "Print")
ExitApp = firstMenu.Append(wx.ID_EXIT, 'Quit')
menuBar.Append(firstMenu, "&file")
secondMenu = wx.Menu()
undo = secondMenu.Append(wx.ID_UNDO,"Undo")
cut = secondMenu.Append(wx.ID_CUT, "Cut")
copy = secondMenu.Append(wx.ID_COPY, "Coppy")
paste = secondMenu.Append(wx.ID_PASTE, "Paste")
delete = secondMenu.Append(wx.ID_DELETE, "Delete")
find = secondMenu.Append(wx.ID_FIND, "Find")
selectAll = secondMenu.Append(wx.ID_SELECTALL, "Select All")
menuBar.Append(secondMenu, "edit")
self.SetMenuBar(menuBar)
def Open(self, event):
openFileDialog = wx.FileDialog(frame, "Open", "", "",
"text files (*.txt)|*.txt",
wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
openFileDialog.ShowModal()
print(openFileDialog.GetPath())
openFileDialog.Destroy()
def SaveAs(self, event):
saveFileDialog = wx.FileDialog(frame, "saveas", "", "",
"text files (*.txt)|*.txt",
wx.FD_SAVE|wx.FD_OVERWRITE_PROMPT)
saveFileDialog.ShowModal()
print(saveFileDialog.GetPath())
saveFileDialog.Destroy()
self.Show()
if __name__ == '__main__':
app = wx.App()
frame = GUI()
frame.Show()
app.MainLoop()
hopefully, this is the last error i will have to bother people with