My Second/Sub window wont show

Good day everyone. I have been at this for a little while but I still cannot get it to work. I am a blind user, using a screen reader trying to create an app which is also accessible to blind users. I have my main window and when I click the “set a new reminder” button on the main window it should open a ‘sub window’ over the main window and that window will close and return to the main window when the create button is pressed. here are the two issues that i am having:

  1. the main window can be seen, however when i press the set a new reminder button, even though the screen reader reads what should be there, when I ask a sighted person to look at it, they say that nothing is there. I have no clue why
  2. my create button wont show.
    I would really appreciate the assistance. here are the two files:

Main.py:

import wx

from SetNew import NewFrame

from NewView import viewFrame

class MyFrame(wx.Frame):

    def __init__(self, *args, **kwds):

        kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE

        wx.Frame.__init__(self, *args, **kwds)

        self.SetSize((400, 300))

        self.SetTitle("TQ Reminders")

        self.panel_1 = wx.Panel(self, wx.ID_ANY)

        welcome = """ Welcome to TQ Reminders!

        Please choose an option below to continue:"""

        label_1 = wx.StaticText(self.panel_1, wx.ID_ANY, label=welcome, style = wx.ALIGN_CENTER)

        label_1.SetFocus()

        self.btn1 = wx.Button(self.panel_1, wx.ID_ANY, "Set A New Reminder")            

        self.Bind(wx.EVT_BUTTON, self.OnSet, self.btn1)

        self.btn2 = wx.Button(self.panel_1, wx.ID_ANY, "View Existing Reminders")            

        self.Bind(wx.EVT_BUTTON, self.OnView, self.btn2)

        v_sizer = wx.BoxSizer(wx.VERTICAL)

        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer.Add(v_sizer, 0, wx.ALL, 5)

        sizer.Add(label_1, 0, wx.ALL|wx.CENTER, 5)

        sizer.Add(self.btn1, 0, wx.ALL |wx.EXPAND , 3)

        sizer.Add(self.btn2, 0, wx.ALL |wx.EXPAND, 3)

        self.panel_1.SetSizer(sizer)

        self.Layout()

   

        self.makeMenuBar()

    def makeMenuBar(self):

        fileMenu = wx.Menu()

        setNewReminderMenuItem = fileMenu.Append(-1, "&Set A New Reminder\tCtrl+N", " Create A New Reminder")

        fileMenu.AppendSeparator()

        exitMenuItem = fileMenu.Append(101, "E&xit\tCtrl+Q", "Close the application")

        #helloItem = fileMenu.Append(-1, "&Hello...\tCtrl-H",

                #"Help string shown in status bar for this menu item")

        #fileMenu.AppendSeparator()

        #exitItem = fileMenu.Append(wx.ID_EXIT)

        helpMenu = wx.Menu()

        aboutItem = helpMenu.Append(wx.ID_ABOUT)

        menuBar = wx.MenuBar()

        menuBar.Append(fileMenu, "&File")

        menuBar.Append(helpMenu, "&Help")

        self.SetMenuBar(menuBar)

        self.Bind(wx.EVT_MENU, self.OnExit, exitMenuItem)

        self.Bind(wx.EVT_MENU, self.OnSet, setNewReminderMenuItem )

        self.Bind(wx.EVT_MENU, self.OnAbout, aboutItem)

    def OnExit(self, event):

        self.Close(True)

    def OnHello(self, event):

        wx.MessageBox("Hello again from wxPython")

    def OnAbout(self, event):

        """Display an About Dialog"""

        wx.MessageBox("This is a wxPython Hello World sample",

                      "About Hello World 2",

                      wx.OK|wx.ICON_INFORMATION)

    def OnSet(self, event):

        self.btn1.Disable()

        self.Hide()

        pop = NewFrame()

    def OnView(self,event):

        pop2 = viewFrame()

       

class MyApp(wx.App):

    def OnInit(self):

        self.frame = MyFrame(None, wx.ID_ANY, "")

        self.SetTopWindow(self.frame)

        self.frame.Show()

        return True

app = MyApp(0)

app.MainLoop()

SetNew.py:

import wx

import wx.adv

class LeftPanel(wx.Panel):

    def __init__(self, parent):

        wx.Panel.__init__(self, parent)

        label = """ Modify the options below for your new reminder.

        Then press CREATE when you are finished."""

        lbl = wx.StaticText(self, label=label)

        lbl.SetFocus()

       

        vbox = wx.BoxSizer(wx.VERTICAL)        

        #vbox.Add(panel, proportion=0, flag=wx.EXPAND | wx.ALL, border=0)

        hbox1 = wx.BoxSizer(wx.VERTICAL)

        hbox2 = wx.BoxSizer(wx.VERTICAL)

        hbox3 = wx.BoxSizer(wx.HORIZONTAL)

        stctext1 = wx.StaticText(self, id = -1, label = "Give your reminder a name:")

        self.t1 = wx.TextCtrl(self)

        hbox1.Add(stctext1, proportion = 0, flag = wx.EXPAND|wx.ALL, border = 5)

        hbox1.Add(self.t1, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)

        stctext2 = wx.StaticText(self, id = -1, label = "Please select the date for your reminder:")

        self.datepicker0 = wx.adv.DatePickerCtrl( self, wx.ID_ANY, wx.DefaultDateTime)  

        hbox2.Add(stctext2, proportion = 0, flag = wx.EXPAND|wx.ALL, border = 5)

        hbox2.Add(self.datepicker, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)

        #stctext3 = wx.StaticText(self, id = -1, label = "Please select the date for your reminder:")

        self.create_btn = wx.Button(self, -1, "create")

        self.Bind(wx.EVT_BUTTON, self.OnDone, self.create_btn)

        #hbox3.Add(stctext3, proportion = 0, flag = wx.EXPAND|wx.ALL, border = 5)

        hbox3.Add(self.create_btn, proportion = 1, flag = wx.EXPAND|wx.ALL, border = 5)

        vbox.Add(hbox1, proportion=0, flag=wx.EXPAND | wx.ALL, border=0)

        vbox.Add(hbox2, proportion=0, flag=wx.EXPAND | wx.ALL, border=0)

        vbox.Add(hbox3, proportion=0, flag=wx.EXPAND | wx.ALL, border=0)

        self.SetSizer(vbox)

   

    def OnRemove(self,event):

        print('do something else')

class MainPanel(wx.Panel):

    def __init__(self, parent):

        wx.Panel.__init__(self, parent)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)

        v_sizer = wx.BoxSizer(wx.VERTICAL)

        left_panel = LeftPanel(self)

        hsizer.Add(left_panel,1,wx.EXPAND)

        self.done_btn = wx.Button(self, -1, "DONE")

        self.Bind(wx.EVT_BUTTON, self.OnDone, self.done_btn)

        v_sizer.Add(hsizer, 1, wx.EXPAND)

        v_sizer.Add(self.done_btn,0, wx.ALL |wx.CENTER, 3)

        self.SetSizer(v_sizer)

    def OnDone(self,event):

        self.Close()

        self.Parent.Destroy()

class NewFrame(wx.Frame):

    def __init__(self):

        wx.Frame.__init__(self, None, title="Set A New Reminder Dialog")

        panel = MainPanel(self)

        self.SetWindowStyle(wx.STAY_ON_TOP)

        self.Show()

It looks like you included the wrong second file, but in general things to watch out for are that the new frame’s Show method is called, and that the frame has a size that is large enough to show its contents. You may also want to use the main frame as the parent of the new frame.

1 Like

thank you very much. It turned out that the window was just not big enough and my sizers were not set up properly