如果我调整窗口大小并再次使其全屏显示,我会得到我想要的结果:
面板是最右侧的面板,颜色更黑灰色。 我有面板和主机,我在其中显示面板的内部功能:
def __init_new_trading_bot_panel(self):
self.__remove_all_panels()
self.__mNewBotPanel = NewTradingBotPanel(self, wx.DisplaySize())
self.__mNewBotPanel.Show()
对我来说毫无意义,我尝试在面板上添加 EVT_SHOW 以在渲染后进行更新,但它也不起作用。
代码面板:
import wx, threading
from Resources.Strings import Strings
from Resources.Constants import Constants, Sizes
class NewTradingBotPanel(wx.Panel, threading.Thread):
__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):
wx.Panel.__init__(self, parent, size=size)
threading.Thread.__init__(self)
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.AddSpacer(15)
self.__init_first_box_sizer()
self.__mSecondBox.AddSpacer(15)
self.__init_second_box_sizer()
self.__mSecondBox.AddSpacer(15)
self.__init_third_box_sizer()
self.__mSecondBox.AddSpacer(15)
self.__init_fourth_box_sizer()
self.__mSecondBox.AddSpacer(15)
self.__init_fifth_box_sizer()
self.__mSecondBox.AddSpacer(15)
self.__mMainBox.Add(self.__mSecondBox, 1, wx.ALL | wx.EXPAND)
self.__init_right_panel()
self.__mMainBox.Add(self.__mRightPanel, 1, wx.ALL | wx.EXPAND)
self.SetSizer(self.__mMainBox)
self.Update()
def __init_first_box_sizer(self):
boxSizer = wx.BoxSizer(wx.HORIZONTAL)
boxSizer.AddSpacer(15)
panel = wx.Panel(self)
panel.SetBackgroundColour((75, 75, 75))
self.__mSecondBox.Add(panel, 1, wx.ALL | wx.EXPAND)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
panel.SetSizer(boxSizer)
def __init_second_box_sizer(self):
boxSizer = wx.BoxSizer(wx.HORIZONTAL)
boxSizer.AddSpacer(15)
panel = wx.Panel(self)
panel.SetBackgroundColour((75, 75, 75))
self.__mSecondBox.Add(panel, 1, wx.ALL | wx.EXPAND)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
panel.SetSizer(boxSizer)
def __init_third_box_sizer(self):
boxSizer = wx.BoxSizer(wx.HORIZONTAL)
boxSizer.AddSpacer(15)
panel = wx.Panel(self)
panel.SetBackgroundColour((75, 75, 75))
self.__mSecondBox.Add(panel, 1, wx.ALL | wx.EXPAND)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
panel.SetSizer(boxSizer)
def __init_fourth_box_sizer(self):
boxSizer = wx.BoxSizer(wx.HORIZONTAL)
boxSizer.AddSpacer(15)
panel = wx.Panel(self)
panel.SetBackgroundColour((75, 75, 75))
self.__mSecondBox.Add(panel, 1, wx.ALL | wx.EXPAND)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
panel.SetSizer(boxSizer)
def __init_fifth_box_sizer(self):
boxSizer = wx.BoxSizer(wx.HORIZONTAL)
boxSizer.AddSpacer(15)
panel = wx.Panel(self)
panel.SetBackgroundColour((75, 75, 75))
self.__mSecondBox.Add(panel, 1, wx.ALL | wx.EXPAND)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
boxSizer.Add(self.__get_boxsizer_day_change(panel))
boxSizer.AddSpacer(50)
panel.SetSizer(boxSizer)
def __init_right_panel(self):
self.__mRightPanel = wx.Panel(self)
self.__mRightPanel.SetBackgroundColour((55, 55, 55))
self.__mRightPanel.SetSize((-1, -1))
hbs = wx.BoxSizer(wx.HORIZONTAL)
hbs.AddSpacer(25)
vbs = wx.BoxSizer(wx.VERTICAL)
vbs.AddSpacer(25)
static = wx.StaticText(self.__mRightPanel, label = "Settings To Create a 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)
#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):
bsMarketCap = wx.BoxSizer(wx.VERTICAL)
bsMarketCap.Add(self.__get_boxsizer_max_market_cap())
bsMarketCap.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
bsMarketCap.Add(self.__get_boxsizer_min_market_cap())
return bsMarketCap
def __get_boxsizer_max_market_cap(self):
self.__mtxMaxMarketCap = wx.TextCtrl(self, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
bsMaxMarketCap = wx.BoxSizer(wx.VERTICAL)
bsMaxMarketCap.Add(wx.StaticText(self, 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):
self.__mtxMinMarketCap = wx.TextCtrl(self, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
bsMinMarketCap = wx.BoxSizer(wx.VERTICAL)
bsMinMarketCap.Add(wx.StaticText(self, 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):
bsDayRange = wx.BoxSizer(wx.VERTICAL)
bsDayRange.Add(self.__get_boxsizer_max_day_range())
bsDayRange.AddSpacer(Sizes.SPACER_TRADING_BOT_PANEL_GRID)
bsDayRange.Add(self.__get_boxsizer_min_day_range())
return bsDayRange
def __get_boxsizer_max_day_range(self):
self.__mtxMaxDayRange = wx.TextCtrl(self, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
bsMaxDayRange = wx.BoxSizer(wx.VERTICAL)
bsMaxDayRange.Add(wx.StaticText(self, 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):
self.__mtxMinDayRange = wx.TextCtrl(self, wx.ID_ANY, value = "", size = Sizes.INPUT_TEXT_SIZE_NEW_TRADING_BOT_PANEL)
bsMinDayRange = wx.BoxSizer(wx.VERTICAL)
bsMinDayRange.Add(wx.StaticText(self, label = Strings.STR_MIN_DAY_RANGE, style = wx.ALIGN_CENTRE), 0, wx.EXPAND)
bsMinDayRange.Add(self.__mtxMinDayRange, 0, wx.EXPAND)
return bsMinDayRange
#endregion
#endregion
在主机上我这样做:
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, title=Strings.STR_TRADING_BOT, size=Constants.DISPLAY_SIZE_MAIN_FRAME)
wx.Frame.CenterOnScreen(self)
self.Maximize(True)
self.Show()
self.__init_layout()
def OnCloseMe(self, event):
self.Close(True)
def OnCloseWindow(self, event):
self.Destroy()
我希望面板在启动时显示全屏而不调整窗口大小
如果我删除右侧面板,我会得到与垂直方向上的其他小面板相同的结果,直到我调整窗口大小并使其再次全屏显示。
(浅灰色应将所有屏幕水平放置)
解决方法:
self.Fit()
在面板初始化上。