简体   繁体   中英

Switch widget from left splitter to right splitter using wxPython

I have a window with three widgets. Currently aa text box ( TextCrtl ) is taking the entire left size of the window, and on the right size, there is another text box, and under it is a button (I spitted the right side horizontally). My question is, how can I flip the widgets, to have the one long text box on the right side, and the smaller text box and button on the left side. Here is my code so far:

import wx

class Frame(wx.Frame):

    def __init__(self, *args, **kwargs):
        super(Frame, self).__init__(*args, **kwargs)

        self.InitUI()

    def InitUI(self):

        splitter1 = wx.SplitterWindow(self, -1,style=wx.SP_LIVE_UPDATE)
        splitter2 = wx.SplitterWindow(splitter1, -1,style=wx.SP_LIVE_UPDATE)
        self.userEnter = wx.TextCtrl(splitter2, -1)
        self.cbtn = wx.Button(splitter2, label='Close')
        self.results = wx.TextCtrl(splitter1, -1)
        #self.graphs = wx.TextCtrl(splitter1, -1)

        splitter1.SplitVertically(self.results, splitter2)
        splitter2.SplitHorizontally(self.userEnter, self.cbtn)


        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        wx.ID_EXIT = 10
        quitButton = fileMenu.Append(10, 'Quit', 'Quit this program')
        menubar.Append(fileMenu, '&File')
        self.SetMenuBar(menubar)

        self.Bind(wx.EVT_MENU, self.OnQuit, quitButton) 

        self.SetSize((1090,750))
        self.SetTitle('Plancials Booky')
        self.Centre()
        self.Show(True)

    def OnQuit(self, e):
        self.Close()        

def main():     
    app = wx.App()
    Frame(None)
    app.MainLoop()

if __name__=="__main__":
    main()  

Thanks.

只需更改splitter1.SplitVertically的小部件顺序:

splitter1.SplitVertically(splitter2, self.results)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM