wxPython - 面板仅在调整窗口大小后才变为右侧

问题描述 投票:0回答:1

这个问题是我的问题的连续体:

wxPython - 如果框架全屏,面板不会覆盖显示的所有框架

我喜欢解决另一个问题的问题,但基本问题仍然存在。

我删除了一个水平面板,所以现在我在垂直盒子上有 4 个水平面板,右侧有一个面板。 右侧面板的底部和右侧有一点空间。 左侧包含所有面板的 BoxSizer 在左侧和底部都有一个空间。

这是我启动应用程序时的结果:

On Launch

如您所见,面板并未覆盖整个屏幕,右侧也没有空间。

但是如果我调整窗口大小:

Window Resize

我再次将其全屏显示,我得到了我想要的结果,如您所见:

Right Result

我该如何解决这个问题?

这是我的面板类的更新代码:


import wx, threading
from Panels.Base.BasePanel import BasePanel
from Utils.NumberUtils import NumberUtils
from Utils.DesignUtils import DesignUtils
from Resources.Strings import Strings
from Resources.Constants import Constants, Sizes

class NewTradingBotPanel(BasePanel):

    __mMainBox: wx.BoxSizer = None
    __mSecondBox: wx.BoxSizer = None

    __mRightPanel: wx.Panel = None

    __mtxMaxDayChange: wx.TextCtrl = None
    __mtxMinDayChange: wx.TextCtrl = None
    __mtxMaxMarketCap: wx.TextCtrl = None
    __mtxMinMarketCap: wx.TextCtrl = None
    __mtxMaxDayRange: wx.TextCtrl = None
    __mtxMinDayRange: wx.TextCtrl = None
    __mtxMaxWeekRange: wx.TextCtrl = None
    __mtxMinWeekRange: wx.TextCtrl = None
    __mtxMaxMonthRange: wx.TextCtrl = None
    __mtxMinMonthRange: wx.TextCtrl = None
    __mtxMaxYearRange: wx.TextCtrl = None
    __mtxMinYearRange: wx.TextCtrl = None
    __mtxMaxDayVolume: wx.TextCtrl = None
    __mtxMinDayVolume: wx.TextCtrl = None
    __mtxMaxCompanyValue: wx.TextCtrl = None
    __mtxMinCompanyValue: wx.TextCtrl = None
    __mtxMaxRatioCompanyValueMarketCap: wx.TextCtrl = None
    __mtxMinRatioCompanyValueMarketCap: wx.TextCtrl = None
    __mtxMaxBeta: wx.TextCtrl = None
    __mtxMinBeta: wx.TextCtrl = None
    __mtxMaxRatioPE: wx.TextCtrl = None
    __mtxMinRatioPE: wx.TextCtrl = None
    __mtxMaxEPS: wx.TextCtrl = None
    __mtxMinEPS: wx.TextCtrl = None
    __mtxMaxYearTarget: wx.TextCtrl = None
    __mtxMinYearTarget: wx.TextCtrl = None
    __mtxMaxTrailingPE: wx.TextCtrl = None
    __mtxMinTrailingPE: wx.TextCtrl = None
    __mtxMaxForwardPE: wx.TextCtrl = None
    __mtxMinForwardPE: wx.TextCtrl = None
    __mtxMaxPegRatio: wx.TextCtrl = None
    __mtxMinPegRatio: wx.TextCtrl = None
    __mtxMaxPriceSales: wx.TextCtrl = None
    __mtxMinPriceSales: wx.TextCtrl = None
    __mtxMaxPriceBook: wx.TextCtrl = None
    __mtxMinPriceBook: wx.TextCtrl = None
    __mtxMaxCompanyValueRevenue: wx.TextCtrl = None
    __mtxMinCompanyValueRevenue: wx.TextCtrl = None
    __mtxMaxCompanyValueEbitda: wx.TextCtrl = None
    __mtxMinCompanyValueEbitda: wx.TextCtrl = None

    def __init__(self, parent, size):
        super().__init__(parent, size)
        self.__init_layout()

#region - Private Methods
#region - Init Methods
    def __init_layout(self):
        self.__mMainBox = wx.BoxSizer(wx.HORIZONTAL)
        self.__mMainBox.AddSpacer(15)
        
        self.__mSecondBox = wx.BoxSizer(wx.VERTICAL)
        self.__mSecondBox.Fit(self)
        self.__mSecondBox.AddSpacer(15)
        self.__init_main_horizontal_panel(
            self.__get_boxsizer_day_change, 
            self.__get_boxsizer_market_cap, 
            self.__get_boxsizer_day_range,
            self.__get_boxsizer_week_range, 
            self.__get_boxsizer_month_range
        )
        self.__mSecondBox.AddSpacer(15)
        self.__init_main_horizontal_panel(
            self.__get_boxsizer_year_range,
            self.__get_boxsizer_day_volume,
            self.__get_boxsizer_company_value,
            self.__get_boxsizer_ratio_company_value_market_cap,
            self.__get_boxsizer_beta
        )
        self.__mSecondBox.AddSpacer(15)
        self.__init_main_horizontal_panel(
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta
        )
        self.__mSecondBox.AddSpacer(15)
        self.__init_main_horizontal_panel(
           self.__get_boxsizer_beta,
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta,
            self.__get_boxsizer_beta
        )
        self.__mSecondBox.AddSpacer(15)
 
        self.__mMainBox.Add(self.__mSecondBox, 1, wx.ALL | wx.EXPAND)
        vbs = wx.BoxSizer(wx.VERTICAL)
        vbs.AddSpacer(15)
        self.__init_right_panel()
        vbs.Add(self.__mRightPanel, 1, wx.ALL | wx.EXPAND)
        vbs.AddSpacer(15)
        self.__mMainBox.Add(vbs, 1, wx.ALL | wx.EXPAND)
        self.__mMainBox.AddSpacer(25)
    
        self.__init_bind_listeners()
        self.SetSizer(self.__mMainBox)
        self.__mMainBox.Fit(self)
        self.Layout()
        self.Update()
        self.Fit()
        

#region - Panels Methods
    def __init_main_horizontal_panel(self, f1, f2, f3, f4, f5):
        boxSizer = wx.BoxSizer(wx.HORIZONTAL)
        boxSizer.AddSpacer(15)
        panel = wx.Panel(self)
        panel.SetBackgroundColour((88, 88, 88))
        self.__mSecondBox.Add(panel, 1, wx.ALL | wx.EXPAND)
        boxSizer.Add(f1(panel))
        boxSizer.AddSpacer(50)
        boxSizer.Add(f2(panel))
        boxSizer.AddSpacer(50)
        boxSizer.Add(f3(panel))
        boxSizer.AddSpacer(50)
        boxSizer.Add(f4(panel))
        boxSizer.AddSpacer(50)
        boxSizer.Add(f5(panel))
        boxSizer.AddSpacer(50)
        boxSizer.Fit(panel)
        panel.SetSizer(boxSizer)
        panel.Layout()
        panel.Update()    
        panel.Fit()

    def __init_right_panel(self):
        self.__mRightPanel = wx.Panel(self)
        self.__mRightPanel.SetBackgroundColour((66, 66, 66))

        hbs = wx.BoxSizer(wx.HORIZONTAL)
        hbs.AddSpacer(25)
        
        vbs = wx.BoxSizer(wx.VERTICAL)
        vbs.AddSpacer(25)
        static = wx.StaticText(self.__mRightPanel, label = Strings.STR_SETTINGS_TO_CREATE_TRADING_BOT, style = wx.ALIGN_CENTRE)
        vbs.Add(static, 0, wx.EXPAND, 50)
        static.Wrap(self.__mRightPanel.Size[0])
        hbs.Add(vbs)
        
        hbs.AddSpacer(25)

        self.__mRightPanel.SetSizer(hbs)
        self.__mRightPanel.Fit()

#endregion

#region - Init Listeners Methods
    def __init_bind_listeners(self):
        self.__mtxMaxDayChange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinDayChange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxMarketCap.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinMarketCap.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxDayRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinDayRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxWeekRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinWeekRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxMonthRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinMonthRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxYearRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinYearRange.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxDayVolume.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinDayVolume.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxCompanyValue.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinCompanyValue.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxRatioCompanyValueMarketCap.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinRatioCompanyValueMarketCap.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxBeta.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinBeta.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxRatioPE.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinRatioPE.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxEPS.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinEPS.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxYearTarget.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinYearTarget.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxTrailingPE.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinTrailingPE.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxForwardPE.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinForwardPE.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxPegRatio.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinPegRatio.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxPriceSales.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinPriceSales.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxPriceBook.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinPriceBook.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxCompanyValueRevenue.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinCompanyValueRevenue.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMaxCompanyValueEbitda.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
        self.__mtxMinCompanyValueEbitda.Bind(wx.EVT_CHAR, self.__listener_check_text_int_value)
#endregion

#region - Listeners Methods
    def __listener_check_text_int_value(self, evt):
        txt = evt.GetEventObject()
        value = chr(evt.GetUnicodeKey())
        if value.isnumeric() or value:
            print("here 3")
            txt.AppendText(value)
#endregion
#endregion

#region - BoxSizer Day Change Methods
    def __get_boxsizer_day_change(self, panel):
        bsDayChange = wx.BoxSizer(wx.VERTICAL)
        bsDayChange.Add(self.__get_boxsizer_max_day_change(panel))
        bsDayChange.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsDayChange.Add(self.__get_boxsizer_min_day_change(panel))
        return bsDayChange

    def __get_boxsizer_max_day_change(self, panel):
        self.__mtxMaxDayChange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxDayChange = wx.BoxSizer(wx.VERTICAL)
        bsMaxDayChange.Add(wx.StaticText(panel, label = Strings.STR_MAX_DAY_CHANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxDayChange.Add(self.__mtxMaxDayChange, 0, wx.EXPAND)
        return bsMaxDayChange

    def __get_boxsizer_min_day_change(self, panel):
        self.__mtxMinDayChange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinDayChange = wx.BoxSizer(wx.VERTICAL)
        bsMinDayChange.Add(wx.StaticText(panel, label = Strings.STR_MIN_DAY_CHANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinDayChange.Add(self.__mtxMinDayChange, 0, wx.EXPAND)
        return bsMinDayChange
#endregion

#region - BoxSizer Market Cap Methods
    def __get_boxsizer_market_cap(self, panel):
        bsMarketCap = wx.BoxSizer(wx.VERTICAL)
        bsMarketCap.Add(self.__get_boxsizer_max_market_cap(panel))
        bsMarketCap.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsMarketCap.Add(self.__get_boxsizer_min_market_cap(panel))
        return bsMarketCap

    def __get_boxsizer_max_market_cap(self, panel):
        self.__mtxMaxMarketCap = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxMarketCap = wx.BoxSizer(wx.VERTICAL)
        bsMaxMarketCap.Add(wx.StaticText(panel, label = Strings.STR_MAX_MARKET_CAP, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxMarketCap.Add(self.__mtxMaxMarketCap, 0, wx.EXPAND)
        return bsMaxMarketCap

    def __get_boxsizer_min_market_cap(self, panel):
        self.__mtxMinMarketCap = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinMarketCap = wx.BoxSizer(wx.VERTICAL)
        bsMinMarketCap.Add(wx.StaticText(panel, label = Strings.STR_MIN_MARKET_CAP, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinMarketCap.Add(self.__mtxMinMarketCap, 0, wx.EXPAND)
        return bsMinMarketCap
#endregion

#region - BoxSizer Day Range Methods
    def __get_boxsizer_day_range(self, panel):
        bsDayRange = wx.BoxSizer(wx.VERTICAL)
        bsDayRange.Add(self.__get_boxsizer_max_day_range(panel))
        bsDayRange.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsDayRange.Add(self.__get_boxsizer_min_day_range(panel))
        return bsDayRange

    def __get_boxsizer_max_day_range(self, panel):
        self.__mtxMaxDayRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxDayRange = wx.BoxSizer(wx.VERTICAL)
        bsMaxDayRange.Add(wx.StaticText(panel, label = Strings.STR_MAX_DAY_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxDayRange.Add(self.__mtxMaxDayRange, 0, wx.EXPAND)
        return bsMaxDayRange

    def __get_boxsizer_min_day_range(self, panel):
        self.__mtxMinDayRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinDayRange = wx.BoxSizer(wx.VERTICAL)
        bsMinDayRange.Add(wx.StaticText(panel, label = Strings.STR_MIN_DAY_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinDayRange.Add(self.__mtxMinDayRange, 0, wx.EXPAND)
        return bsMinDayRange
#endregion

#region - BoxSizer Week Range Methods
    def __get_boxsizer_week_range(self, panel):
        bsWeekRange = wx.BoxSizer(wx.VERTICAL)
        bsWeekRange.Add(self.__get_boxsizer_max_week_range(panel))
        bsWeekRange.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsWeekRange.Add(self.__get_boxsizer_min_week_range(panel))
        return bsWeekRange

    def __get_boxsizer_max_week_range(self, panel):
        self.__mtxMaxWeekRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxWeekRange = wx.BoxSizer(wx.VERTICAL)
        bsMaxWeekRange.Add(wx.StaticText(panel, label = Strings.STR_MAX_WEEK_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxWeekRange.Add(self.__mtxMaxWeekRange, 0, wx.EXPAND)
        return bsMaxWeekRange

    def __get_boxsizer_min_week_range(self, panel):
        self.__mtxMinWeekRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinWeekRange = wx.BoxSizer(wx.VERTICAL)
        bsMinWeekRange.Add(wx.StaticText(panel, label = Strings.STR_MIN_WEEK_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinWeekRange.Add(self.__mtxMinWeekRange, 0, wx.EXPAND)
        return bsMinWeekRange
#endregion

#region - BoxSizer Month Range Methods
    def __get_boxsizer_month_range(self, panel):
        bsMonthRange = wx.BoxSizer(wx.VERTICAL)
        bsMonthRange.Add(self.__get_boxsizer_max_month_range(panel))
        bsMonthRange.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsMonthRange.Add(self.__get_boxsizer_min_month_range(panel))
        return bsMonthRange

    def __get_boxsizer_max_month_range(self, panel):
        self.__mtxMaxMonthRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxMonthRange = wx.BoxSizer(wx.VERTICAL)
        bsMaxMonthRange.Add(wx.StaticText(panel, label = Strings.STR_MAX_MONTH_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxMonthRange.Add(self.__mtxMaxMonthRange, 0, wx.EXPAND)
        return bsMaxMonthRange

    def __get_boxsizer_min_month_range(self, panel):
        self.__mtxMinMonthRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinMonthRange = wx.BoxSizer(wx.VERTICAL)
        bsMinMonthRange.Add(wx.StaticText(panel, label = Strings.STR_MIN_MONTH_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinMonthRange.Add(self.__mtxMinMonthRange, 0, wx.EXPAND)
        return bsMinMonthRange
#endregion

#region - BoxSizer Year Range Methods
    def __get_boxsizer_year_range(self, panel):
        bsYearRange = wx.BoxSizer(wx.VERTICAL)
        bsYearRange.Add(self.__get_boxsizer_max_year_range(panel))
        bsYearRange.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsYearRange.Add(self.__get_boxsizer_min_year_range(panel))
        return bsYearRange

    def __get_boxsizer_max_year_range(self, panel):
        self.__mtxMaxYearRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxYearRange = wx.BoxSizer(wx.VERTICAL)
        bsMaxYearRange.Add(wx.StaticText(panel, label = Strings.STR_MAX_YEAR_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxYearRange.Add(self.__mtxMaxYearRange, 0, wx.EXPAND)
        return bsMaxYearRange

    def __get_boxsizer_min_year_range(self, panel):
        self.__mtxMinYearRange = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinYearRange = wx.BoxSizer(wx.VERTICAL)
        bsMinYearRange.Add(wx.StaticText(panel, label = Strings.STR_MIN_YEAR_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinYearRange.Add(self.__mtxMinYearRange, 0, wx.EXPAND)
        return bsMinYearRange
#endregion

#region - BoxSizer Day Volume Methods
    def __get_boxsizer_day_volume(self, panel):
        bsDayVolume = wx.BoxSizer(wx.VERTICAL)
        bsDayVolume.Add(self.__get_boxsizer_max_day_volume(panel))
        bsDayVolume.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsDayVolume.Add(self.__get_boxsizer_min_day_volume(panel))
        return bsDayVolume

    def __get_boxsizer_max_day_volume(self, panel):
        self.__mtxMaxDayVolume = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxDayVolume = wx.BoxSizer(wx.VERTICAL)
        bsMaxDayVolume.Add(wx.StaticText(panel, label = Strings.STR_MAX_DAY_VOLUME, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxDayVolume.Add(self.__mtxMaxDayVolume, 0, wx.EXPAND)
        return bsMaxDayVolume

    def __get_boxsizer_min_day_volume(self, panel):
        self.__mtxMinDayVolume = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinDayVolume = wx.BoxSizer(wx.VERTICAL)
        bsMinDayVolume.Add(wx.StaticText(panel, label = Strings.STR_MIN_DAY_VOLUME, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinDayVolume.Add(self.__mtxMinDayVolume, 0, wx.EXPAND)
        return bsMinDayVolume
#endregion

#region - BoxSizer Company Value Methods
    def __get_boxsizer_company_value(self, panel):
        bsCompanyValue = wx.BoxSizer(wx.VERTICAL)
        bsCompanyValue.Add(self.__get_boxsizer_max_company_value(panel))
        bsCompanyValue.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsCompanyValue.Add(self.__get_boxsizer_min_company_value(panel))
        return bsCompanyValue

    def __get_boxsizer_max_company_value(self, panel):
        self.__mtxMaxCompanyValue = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxCompanyValue = wx.BoxSizer(wx.VERTICAL)
        bsMaxCompanyValue.Add(wx.StaticText(panel, label = Strings.STR_MAX_COMPANY_VALUE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxCompanyValue.Add(self.__mtxMaxCompanyValue, 0, wx.EXPAND)
        return bsMaxCompanyValue

    def __get_boxsizer_min_company_value(self, panel):
        self.__mtxMinCompanyValue = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinCompanyValue = wx.BoxSizer(wx.VERTICAL)
        bsMinCompanyValue.Add(wx.StaticText(panel, label = Strings.STR_MIN_COMPANY_VALUE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinCompanyValue.Add(self.__mtxMinCompanyValue, 0, wx.EXPAND)
        return bsMinCompanyValue
#endregion

#region - BoxSizer Ratio Company Value Market Cap Methods
    def __get_boxsizer_ratio_company_value_market_cap(self, panel):
        bsRatioCompanyValueMarketCap = wx.BoxSizer(wx.VERTICAL)
        bsRatioCompanyValueMarketCap.Add(self.__get_boxsizer_max_ratio_company_value_market_cap(panel))
        bsRatioCompanyValueMarketCap.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsRatioCompanyValueMarketCap.Add(self.__get_boxsizer_min_ratio_company_value_market_cap(panel))
        return bsRatioCompanyValueMarketCap

    def __get_boxsizer_max_ratio_company_value_market_cap(self, panel):
        self.__mtxMaxRatioCompanyValueMarketCap = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxRatioCompanyValueMarketCap = wx.BoxSizer(wx.VERTICAL)
        bsMaxRatioCompanyValueMarketCap.Add(wx.StaticText(panel, label = Strings.STR_MAX_RATIO_COMPANY_VALUE_MARKET_CAP, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxRatioCompanyValueMarketCap.Add(self.__mtxMaxRatioCompanyValueMarketCap, 0, wx.EXPAND)
        return bsMaxRatioCompanyValueMarketCap

    def __get_boxsizer_min_ratio_company_value_market_cap(self, panel):
        self.__mtxMinRatioCompanyValueMarketCap = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinRatioCompanyValueMarketCap = wx.BoxSizer(wx.VERTICAL)
        bsMinRatioCompanyValueMarketCap.Add(wx.StaticText(panel, label = Strings.STR_MIN_RATIO_COMPANY_VALUE_MARKET_CAP, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinRatioCompanyValueMarketCap.Add(self.__mtxMinRatioCompanyValueMarketCap, 0, wx.EXPAND)
        return bsMinRatioCompanyValueMarketCap
#endregion

#region - BoxSizer BETA Methods
    def __get_boxsizer_beta(self, panel):
        bsBeta = wx.BoxSizer(wx.VERTICAL)
        bsBeta.Add(self.__get_boxsizer_max_beta(panel))
        bsBeta.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsBeta.Add(self.__get_boxsizer_min_beta(panel))
        return bsBeta

    def __get_boxsizer_max_beta(self, panel):
        self.__mtxMaxBeta = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxBeta = wx.BoxSizer(wx.VERTICAL)
        bsMaxBeta.Add(wx.StaticText(panel, label = Strings.STR_MAX_BETA, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxBeta.Add(self.__mtxMaxBeta, 0, wx.EXPAND)
        return bsMaxBeta

    def __get_boxsizer_min_beta(self, panel):
        self.__mtxMinBeta = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinBeta = wx.BoxSizer(wx.VERTICAL)
        bsMinBeta.Add(wx.StaticText(panel, label = Strings.STR_MIN_BETA, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinBeta.Add(self.__mtxMinBeta, 0, wx.EXPAND)
        return bsMinBeta
#endregion

#region - BoxSizer Ratio PE Methods
    def __get_boxsizer_ratio_pe(self, panel):
        bsRatioPE = wx.BoxSizer(wx.VERTICAL)
        bsRatioPE.Add(self.__get_boxsizer_max_ratio_pe(panel))
        bsRatioPE.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsRatioPE.Add(self.__get_boxsizer_min_ratio_pe(panel))
        return bsRatioPE

    def __get_boxsizer_max_ratio_pe(self, panel):
        self.__mtxMaxRatioPE = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMaxRatioPE = wx.BoxSizer(wx.VERTICAL)
        bsMaxRatioPE.Add(wx.StaticText(panel, label = Strings.STR_MAX_RATIO_PE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMaxRatioPE.Add(self.__mtxMaxRatioPE, 0, wx.EXPAND)
        return bsMaxRatioPE

    def __get_boxsizer_min_ratio_pe(self, panel):
        self.__mtxMinRatioPE = wx.TextCtrl(panel, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
        bsMinRatioPE = wx.BoxSizer(wx.VERTICAL)
        bsMinRatioPE.Add(wx.StaticText(panel, label = Strings.STR_MIN_RATIO_PE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
        bsMinRatioPE.Add(self.__mtxMinRatioPE, 0, wx.EXPAND)
        return bsMinRatioPE
#endregion

#region - BoxSizer EPS Methods
    def __get_boxsizer_eps(self, panel):
        bsEPS = wx.BoxSizer(wx.VERTICAL)
        bsEPS.Add(self.__get_boxsizer_max_eps(panel))
        bsEPS.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
        bsEPS.Add(self.__get_boxsizer_min_eps(panel))
        return bsEPS

[...] Code Removed too many chars
        
    

我希望在第一次启动时获得正确的结果,而不是在调整大小并再次使窗口全屏显示后获得正确的结果。

正如您所看到的,问题就像在另一个问题上解决了一样,但是当我添加一些装饰器(例如间距ecc)时,我发现了这些问题。

谢谢!

python wxpython panel boxsizer
1个回答
0
投票

我解决了这个问题。

我只是使用 SplitterWindow 将左右面板包含在带有边框的 BoxSizer 内。

def __init_layout(self):      
        self.__mMainBox = wx.BoxSizer(wx.HORIZONTAL)         

        self.__mMainBox.AddSpacer(10)
        self.__mMainSplitter = wx.SplitterWindow(self)
        self.__init_left_panel()
        self.__init_right_panel()
        self.__mMainSplitter.SplitVertically(self.__mLeftPanel, self.__mRightPanel, round((wx.DisplaySize()[0] / 10 * 7)))
        
        self.__mMainBox.Add(self.__mMainSplitter, 1, wx.EXPAND)
        self.__mMainBox.AddSpacer(10)
        self.SetSizerAndFit(self.__mMainBox)
        self.__mLeftPanel.Fit()
        self.__mLeftPanel.SetupScrolling()

之前:

self.__mMainBox.AddSpacer(10)

第一次使用该应用程序时无法正常工作,现在可以正常工作了。 启动时,应用程序的右侧和左侧有边框,如果我调整它的大小,它不会与面板重叠。

On first go

© www.soinside.com 2019 - 2024. All rights reserved.