Note that there are some explanatory texts on larger screens.

plurals
  1. POClose (red 'x') on GUI Text editor not exiting
    primarykey
    data
    text
    <p>I am trying to learn to build basic GUI's, I have started with a simple text editor. I have been able to get through things so far pretty well, but I am running into a strange issue. When I was going through building it I was able to click the red "X" exit button (top right) of the window and change a few things and restart it. But after defining some functions it seems to have stopped working, the editor launches fine and works with the menu pieces I have used so far but its not letting me "X" out. I have to restart the kernel to get it to close and thats getting annoying. I tried looking through it but I didnt change anything that I know of that should cause this. So I figured I would bring it to the experts and get opinions/experience.</p> <pre><code>#!/user/bin/env python import os import wx class MainWindow(wx.Frame): def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=(500, 300)) self.control=wx.TextCtrl(self, style=wx.TE_MULTILINE) self.CreateStatusBar() filemenu=wx.Menu() About_Menu=filemenu.Append(wx.ID_ABOUT, '&amp;About','Info about') Exit_Menu=filemenu.Append(wx.ID_EXIT,'E&amp;xit','Term') Open_Menu=filemenu.Append(wx.ID_OPEN,'&amp;Open','Open File') menuBar=wx.MenuBar() menuBar.Append(filemenu,'&amp;File') self.SetMenuBar(menuBar) self.Bind(wx.EVT_MENU, self.OnAbout, About_Menu) self.Bind(wx.EVT_MENU, self.OnExit, Exit_Menu) self.Bind(wx.EVT_MENU, self.OnOpen, Open_Menu) self.Show(True) def OnAbout(self,e): dlg=wx.MessageDialog( self, 'The Editor', 'About the Editor', wx.OK) dlg.ShowModal() dlg.Destroy() def OnExit(self,e): dlg=wx.MessageDialog( self, 'Test Exit','Exit', wx.OK) dlg.ShowModal() dlg.Destroy() def OnOpen(self,e): self.dirname='' dlg=wx.FileDialog(self, 'Choose a file', self.dirname, '','*.*', wx.OPEN) if dlg.ShowModal()==wx.ID_OK: self.filename=dlg.GetFilename() self.dirname=dlg.GetDirectory() f=open(os.path.join(self.dirname, self.filename), 'r') self.control.SetValue(f.read()) f.close() dlg.Destroy() app=wx.App(False) frame=MainWindow(None, 'Sample') app.MainLoop </code></pre> <p><img src="https://i.stack.imgur.com/f1IA8.png" alt="This is what i have to restart to get it closed"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload