Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8901717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:25:47+00:00 2026-06-15T01:25:47+00:00

Is there anything wrong with my code? I used 3 sizers in 1 boxsizer

  • 0

Is there anything wrong with my code? I used 3 sizers in 1 boxsizer in main frame. The bottom sizer is used for plotting and the other two are used for user interaction. The most important problem lies in too much blank area exists between 3 sizers now. I want my GUI looks more compact and the plot area should be largers if possible.

    # -*- coding: utf-8 -*- 

###########################################################################
## Python code generated with wxFormBuilder (version Oct  8 2012)
## http://www.wxformbuilder.org/
##
## PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################

import os
import wx
import wx.xrc
import matplotlib
matplotlib.use('WXAgg')
from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import \
    FigureCanvasWxAgg as FigureCanvas, \
    NavigationToolbar2WxAgg as NavigationToolbar
#from numpy import arange, sin, pi

###########################################################################
## Class MainFrame
###########################################################################

class MainFrame ( wx.Frame ):

    def __init__( self, parent ):
        wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"计算机插值 v0.1", pos = wx.DefaultPosition, size = wx.Size( 508,530 ), style = wx.DEFAULT_FRAME_STYLE|wx.FRAME_SHAPED|wx.TAB_TRAVERSAL )

        self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
        self.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) )

        ####################################################################
        self.MainMenu = wx.MenuBar( 0 )
        self.File = wx.Menu()
        self.SaveAs = wx.MenuItem( self.File, wx.ID_ANY, u"另存为...", wx.EmptyString, wx.ITEM_NORMAL )
        self.File.AppendItem( self.SaveAs )

        self.Exit = wx.MenuItem( self.File, wx.ID_ANY, u"退出...", wx.EmptyString, wx.ITEM_NORMAL )
        self.File.AppendItem( self.Exit )

        self.MainMenu.Append( self.File, u"文件" ) 

        self.About_M = wx.Menu()
        self.About = wx.MenuItem( self.About_M, wx.ID_ANY, u"关于", wx.EmptyString, wx.ITEM_NORMAL )
        self.About_M.AppendItem( self.About )

        self.MainMenu.Append( self.About_M, u"关于" ) 

        self.SetMenuBar( self.MainMenu )

        ####################################################################        
        MainSizer = wx.BoxSizer( wx.VERTICAL )

        self.MainPanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
        UserSizer = wx.BoxSizer( wx.VERTICAL )

        upperSizer = wx.BoxSizer( wx.HORIZONTAL )
        ####################################################################

        self.TextExplanation = wx.StaticText( self.MainPanel, wx.ID_ANY, u"请在下面输入框内输入要插值的数,以空格间隔。\n输入范围在(1.2, 2.0)。", wx.DefaultPosition, wx.DefaultSize, 0 )
        self.TextExplanation.Wrap( -1 )
        upperSizer.Add( self.TextExplanation, 0, wx.ALL, 20 )


        upperSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )

        RadioBoxInterpolationChoices = [ u"线性插值", u"抛物线插值" ]
        self.RadioBoxInterpolation = wx.RadioBox( self.MainPanel, wx.ID_ANY, u"插值种类", wx.DefaultPosition, wx.DefaultSize, RadioBoxInterpolationChoices, 1, wx.RA_SPECIFY_COLS )
        self.RadioBoxInterpolation.SetSelection( 1 )
        upperSizer.Add( self.RadioBoxInterpolation, 0, wx.ALL, 5 )


        UserSizer.Add( upperSizer, 1, wx.ALL|wx.EXPAND|wx.SHAPED, 5 )

        lowerSizer = wx.BoxSizer( wx.HORIZONTAL )

        self.TextCtrVal = wx.TextCtrl( self.MainPanel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
        lowerSizer.Add( self.TextCtrVal, 0, wx.ALL, 20 )


        lowerSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )

        self.ButtonCal = wx.Button( self.MainPanel, wx.ID_ANY, u"计算", wx.DefaultPosition, wx.DefaultSize, 0 )
        lowerSizer.Add( self.ButtonCal, 0, wx.ALL, 20 )

        self.ButtonCls = wx.Button( self.MainPanel, wx.ID_ANY, u"清空", wx.DefaultPosition, wx.DefaultSize, 0 )
        lowerSizer.Add( self.ButtonCls, 0, wx.ALL, 20 )


        UserSizer.Add( lowerSizer, 1, wx.EXPAND|wx.SHAPED, 5 )

        PlotSizer = wx.BoxSizer( wx.VERTICAL )

        #################################################
        p1 = PlotPanel(self)
        PlotSizer.Add(p1, 1, wx.EXPAND |wx.ALL,1)

        #################################################    
        UserSizer.Add( PlotSizer, 1, wx.EXPAND, 5 )


        self.MainPanel.SetSizer( UserSizer )
        self.MainPanel.Layout()
        UserSizer.Fit( self.MainPanel )
        MainSizer.Add( self.MainPanel, 1, wx.EXPAND |wx.ALL, 1 )


        self.SetSizer( MainSizer )
        self.Layout()

        self.Centre( wx.BOTH )

        # Connect Events
        self.Bind( wx.EVT_MENU, self.SaveAsFile, id = self.SaveAs.GetId() )
        self.Bind( wx.EVT_MENU, self.ExitNow, id = self.Exit.GetId() )
        self.Bind( wx.EVT_MENU, self.Dialog, id = self.About.GetId() )
        self.TextCtrVal.Bind( wx.EVT_TEXT_ENTER, self.Calculate )
        self.ButtonCal.Bind( wx.EVT_BUTTON, self.Calcualte )
        self.ButtonCls.Bind( wx.EVT_BUTTON, self.ClearPlot )

        # Necessary varibles
        selection = self.RadioBoxInterpolation.GetSelection()       

    def __del__( self ):
        pass

    # Virtual event handlers, overide them in your derived class
    def SaveAsFile( self, event ):
        event.Skip()

    def ExitNow( self, event ):
        self.Close(True) 

    def Dialog( self, event ):
        dlg = wx.MessageDialog( self, u"Test", u"Test", wx.OK)
        dlg.ShowModal() 
        dlg.Destroy() 

    def Calculate( self, event ):
        event.Skip()

    def Calcualte( self, event ):
        event.Skip()

    def ClearPlot( self, event ):
        event.Skip()

###########################################################################
## Class PlotPanel
###########################################################################

class PlotPanel(wx.Panel):
    def __init__(self,parent):
        wx.Panel.__init__(self,parent, -1,size=(300,530))
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.figure = matplotlib.figure.Figure(figsize=(5,4))
        self.axes = self.figure.add_subplot(111)
        self.y_max = 2.0
        self.canvas = FigureCanvas(self,-1,self.figure)

        self.sizer.Add(self.canvas,proportion =1, border = 5,flag = wx.ALL | wx.EXPAND)
        self.SetSizer(self.sizer)

if __name__ == '__main__': 
    app = wx.PySimpleApp()
    app.frame = MainFrame(None)
    app.frame.Show()
    app.MainLoop()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:25:48+00:00Added an answer on June 15, 2026 at 1:25 am

    I changed two lines of code, and think it might be what you are looking for.

    UserSizer.Add( upperSizer, 0, wx.EXPAND, 5 )
    

    and

    UserSizer.Add( lowerSizer, 0, 0, 5 )
    

    Here is the updated code:

        # -*- coding: utf-8 -*-
    
    ###########################################################################
    ## Python code generated with wxFormBuilder (version Oct  8 2012)
    ## http://www.wxformbuilder.org/
    ##
    ## PLEASE DO "NOT" EDIT THIS FILE!
    ###########################################################################
    
    import os
    import wx
    import wx.xrc
    import matplotlib
    matplotlib.use('WXAgg')
    from matplotlib.figure import Figure
    from matplotlib.backends.backend_wxagg import \
        FigureCanvasWxAgg as FigureCanvas, \
        NavigationToolbar2WxAgg as NavigationToolbar
    #from numpy import arange, sin, pi
    
    ###########################################################################
    ## Class MainFrame
    ###########################################################################
    
    class MainFrame ( wx.Frame ):
    
        def __init__( self, parent ):
            wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"计算机插值 v0.1", pos = wx.DefaultPosition, size = wx.Size( 508,530 ), style = wx.DEFAULT_FRAME_STYLE|wx.FRAME_SHAPED|wx.TAB_TRAVERSAL )
    
            self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
            self.SetForegroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_3DLIGHT ) )
    
            ####################################################################
            self.MainMenu = wx.MenuBar( 0 )
            self.File = wx.Menu()
            self.SaveAs = wx.MenuItem( self.File, wx.ID_ANY, u"另存为...", wx.EmptyString, wx.ITEM_NORMAL )
            self.File.AppendItem( self.SaveAs )
    
            self.Exit = wx.MenuItem( self.File, wx.ID_ANY, u"退出...", wx.EmptyString, wx.ITEM_NORMAL )
            self.File.AppendItem( self.Exit )
    
            self.MainMenu.Append( self.File, u"文件" )
    
            self.About_M = wx.Menu()
            self.About = wx.MenuItem( self.About_M, wx.ID_ANY, u"关于", wx.EmptyString, wx.ITEM_NORMAL )
            self.About_M.AppendItem( self.About )
    
            self.MainMenu.Append( self.About_M, u"关于" )
    
            self.SetMenuBar( self.MainMenu )
    
            ####################################################################
            MainSizer = wx.BoxSizer( wx.VERTICAL )
    
            self.MainPanel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
            UserSizer = wx.BoxSizer( wx.VERTICAL )
    
            upperSizer = wx.BoxSizer( wx.HORIZONTAL )
            ####################################################################
    
            self.TextExplanation = wx.StaticText( self.MainPanel, wx.ID_ANY, u"请在下面输入框内输入要插值的数,以空格间隔。\n输入范围在(1.2, 2.0)。", wx.DefaultPosition, wx.DefaultSize, 0 )
            self.TextExplanation.Wrap( -1 )
            upperSizer.Add( self.TextExplanation, 0, wx.ALL, 20 )
    
    
            upperSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
    
            RadioBoxInterpolationChoices = [ u"线性插值", u"抛物线插值" ]
            self.RadioBoxInterpolation = wx.RadioBox( self.MainPanel, wx.ID_ANY, u"插值种类", wx.DefaultPosition, wx.DefaultSize, RadioBoxInterpolationChoices, 1, wx.RA_SPECIFY_COLS )
            self.RadioBoxInterpolation.SetSelection( 1 )
            upperSizer.Add( self.RadioBoxInterpolation, 0, wx.ALL, 5 )
    
    
            UserSizer.Add( upperSizer, 0, wx.EXPAND, 5 )
    
            lowerSizer = wx.BoxSizer( wx.HORIZONTAL )
    
            self.TextCtrVal = wx.TextCtrl( self.MainPanel, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
            lowerSizer.Add( self.TextCtrVal, 0, wx.ALL, 20 )
    
    
            lowerSizer.AddSpacer( ( 0, 0), 1, wx.EXPAND, 5 )
    
            self.ButtonCal = wx.Button( self.MainPanel, wx.ID_ANY, u"计算", wx.DefaultPosition, wx.DefaultSize, 0 )
            lowerSizer.Add( self.ButtonCal, 0, wx.ALL, 20 )
    
            self.ButtonCls = wx.Button( self.MainPanel, wx.ID_ANY, u"清空", wx.DefaultPosition, wx.DefaultSize, 0 )
            lowerSizer.Add( self.ButtonCls, 0, wx.ALL, 20 )
    
    
            UserSizer.Add( lowerSizer, 0, 0, 5 )
    
            PlotSizer = wx.BoxSizer( wx.VERTICAL )
    
            #################################################
            p1 = PlotPanel(self)
            PlotSizer.Add(p1, 1, wx.EXPAND |wx.ALL,1)
    
            #################################################
            UserSizer.Add( PlotSizer, 1, wx.EXPAND, 5 )
    
    
            self.MainPanel.SetSizer( UserSizer )
            self.MainPanel.Layout()
            UserSizer.Fit( self.MainPanel )
            MainSizer.Add( self.MainPanel, 1, wx.EXPAND |wx.ALL, 1 )
    
    
            self.SetSizer( MainSizer )
            self.Layout()
    
            self.Centre( wx.BOTH )
    
            # Connect Events
            self.Bind( wx.EVT_MENU, self.SaveAsFile, id = self.SaveAs.GetId() )
            self.Bind( wx.EVT_MENU, self.ExitNow, id = self.Exit.GetId() )
            self.Bind( wx.EVT_MENU, self.Dialog, id = self.About.GetId() )
            self.TextCtrVal.Bind( wx.EVT_TEXT_ENTER, self.Calculate )
            self.ButtonCal.Bind( wx.EVT_BUTTON, self.Calcualte )
            self.ButtonCls.Bind( wx.EVT_BUTTON, self.ClearPlot )
    
            # Necessary varibles
            selection = self.RadioBoxInterpolation.GetSelection()
    
        def __del__( self ):
            pass
    
        # Virtual event handlers, overide them in your derived class
        def SaveAsFile( self, event ):
            event.Skip()
    
        def ExitNow( self, event ):
            self.Close(True)
    
        def Dialog( self, event ):
            dlg = wx.MessageDialog( self, u"Test", u"Test", wx.OK)
            dlg.ShowModal()
            dlg.Destroy()
    
        def Calculate( self, event ):
            event.Skip()
    
        def Calcualte( self, event ):
            event.Skip()
    
        def ClearPlot( self, event ):
            event.Skip()
    
    ###########################################################################
    ## Class PlotPanel
    ###########################################################################
    
    class PlotPanel(wx.Panel):
        def __init__(self,parent):
            wx.Panel.__init__(self,parent, -1,size=(300,530))
            self.sizer = wx.BoxSizer(wx.VERTICAL)
            self.figure = matplotlib.figure.Figure(figsize=(5,4))
            self.axes = self.figure.add_subplot(111)
            self.y_max = 2.0
            self.canvas = FigureCanvas(self,-1,self.figure)
    
            self.sizer.Add(self.canvas,proportion =1, border = 5,flag = wx.ALL | wx.EXPAND)
            self.SetSizer(self.sizer)
    
    if __name__ == '__main__':
        app = wx.PySimpleApp()
        app.frame = MainFrame(None)
        app.frame.Show()
        app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anything wrong with this code or can this be done more efficiently?
Is there anything wrong with this code? My entity is not getting updated. public
Php novice. 1.Is there anything wrong with this PHP & MySQL code? include_once db_login.php
Is there anything wrong or inherently unsafe about the way I've programmed this? I'm
Is there anything wrong with having a single class (one .h) implemented over multiple
Is there anything wrong with checking so many things in this unit test?: ActualModel
i just wondering is there any performance issue or anything thing wrong if that
is there anything more comfortable than this to detect a special page? The page
Is there anything like asp.net transactions in Android SQLite? I am doing some processing
is there anything special I need to do to get ASP.NET MVC3 enabled on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.