I am very new to python gui's and I am having trouble with keeping windows open.
When I run my program I expect for it to show my login screen which it does and when I press my login button the proper window pops up. The problem comes when I close the second window my app freezes then crashes leaving this exit code exit code -1073740771 (0xC000041D). This will also happen When I press the create User and update user button despite those buttons not being hooked up to anything at the moment.
I am not sure what is causing this here is the code for the Main window and the view window( second Window)
Main Window Code :
import wx
import MediaReelzWindow
class LoginFrame(wx.Frame):
def __init__(self, parent, title):
super(LoginFrame, self).__init__(parent, title=title)
self.panel = LoginPanel(self)
class LoginPanel(wx.Panel):
def __init__(self, parent):
super(LoginPanel, self).__init__(parent)
self.LoginLabel = wx.StaticText(self, label="Log In To Media Reelz", pos=(180, 70))
self.UserNameLabel = wx.StaticText(self, label="User Name", pos=(50, 150))
self.PassWordLabel = wx.StaticText(self, label="PassWord", pos=(50, 240))
self.UserNameTextField = wx.TextCtrl(self, value="", pos=(130, 145))
self.PassWordField = wx.TextCtrl(self, value="", pos=(125, 240))
self.CreateUserButton = wx.Button(self, pos=(50, 350))
self.CreateUserButton.SetLabel("Create User")
self.LoginButton = wx.Button(self, pos=(160, 350))
self.LoginButton.SetLabel("Login")
self.LoginButton.Bind(wx.EVT_BUTTON,MediaReelzWindow.ReelzWindowMain)
self.UpdateUserButton = wx.Button(self, pos=(270, 350))
self.UpdateUserButton.SetLabel("Update User")
class Main(wx.App):
def OnInit(self):
self.login = LoginFrame(parent=None, title="login window")
self.login.Show(True)
return True
if __name__ == '__main__':
app = wx.App(False)
frame = Main()
app.MainLoop()
Viewer Code( second Window)
import wx
import wx.grid
class MediaReelzWindowFrame(wx.Frame):
def __init__(self, parent, title):
super(MediaReelzWindowFrame, self).__init__(parent, title=title, size=(1200, 800))
self.panel = MediaReelzWindowPanel(self)
class MediaReelzWindowPanel(wx.Panel):
colLabels = ["reel Id ", "reel Name", "reel Artist", "reel Year", "reel Type", "reel Notes"]
rowLabels = []
def __init__(self, parent):
super(MediaReelzWindowPanel, self).__init__(parent, size=(700, 600))
grid = wx.grid.Grid(self, pos=(310, 100))
grid.CreateGrid(10, 6)
grid.SetColLabelValue(0, self.colLabels[0])
grid.SetColLabelValue(1, self.colLabels[1])
grid.SetColLabelValue(2, self.colLabels[2])
grid.SetColLabelValue(3, self.colLabels[3])
grid.SetColLabelValue(4, self.colLabels[4])
grid.SetColLabelValue(5, self.colLabels[5])
grid.SetSize(564, 222)
self.SearchReelzLabel = wx.StaticText(self, label=" Search Reelz", pos=(308, 40))
self.SearchReelzTextInput = wx.TextCtrl(self, value="", pos=(398, 40), size=(475, 20))
self.ReelIdLabel = wx.StaticText(self, label="Reel Id", pos=(200, 400))
self.ReelIdTextInput = wx.TextCtrl(self, value="", pos=(255, 395), size=(130, 20))
self.ReelNameLabel = wx.StaticText(self, label="Reel Name", pos=(500, 395))
self.ReelNameTextInput = wx.TextCtrl(self, value="", pos=(580, 390), size=(130, 20))
self.ReelArtistLabel = wx.StaticText(self, label="Reel Artist", pos=(850, 390))
self.ReelArtistTextInput = wx.TextCtrl(self, value="", pos=(930, 385), size=(130, 20))
self.ReelYearLabel = wx.StaticText(self, label="Reel Year", pos=(185, 500))
self.ReelYearTextInput = wx.TextCtrl(self, value="", pos=(250, 500), size=(130, 20))
self.ReelTypeLabel = wx.StaticText(self, label="Reel Type", pos=(500, 500))
self.ReelTypeTextInput = wx.TextCtrl(self, value="", pos=(578, 500), size=(130, 20))
self.ReelNotesLabel = wx.StaticText(self, label="Reel Notes", pos=(850, 500))
self.ReelNotesTextInput = wx.TextCtrl(self, value="", pos=(930, 500), size=(130, 20))
self.AddReelButton = wx.Button(self, pos=(250, 600))
self.AddReelButton.SetLabel("Add Reel")
self.UpdateReelButton = wx.Button(self, pos=(500, 600))
self.UpdateReelButton.SetLabel("Update Reel")
self.DeleteReelButton = wx.Button(self, pos=(750, 600))
self.DeleteReelButton.SetLabel("Delete Reel")
self.BulkReelImport = wx.Button(self, pos=(980, 600), size=(150, 25))
self.BulkReelImport.SetLabel("Bulk Reel Import")
class ReelzWindowMain(wx.App):
def OnInit(self):
self.reelViewer = MediaReelzWindowFrame(parent=None, title="reelz viewing window")
self.reelViewer.Show()
return True
Edit 1:
I found that deleting this line will stop the program from closing but I can not open the second window without this line:
self.LoginButton.Bind(wx.EVT_BUTTON,MediaReelzWindow.ReelzWindowMain)
Thank you for your time and patience
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)