If I resize the window and I make it full screen again I get the result I desire:
After resize window and full screen
The panel is the one on the far right with a more black grey color. I have the panel and a mainframe where I show the panel inside doing:
def __init_new_trading_bot_panel(self):
self.__remove_all_panels()
self.__mNewBotPanel = NewTradingBotPanel(self, wx.DisplaySize())
self.__mNewBotPanel.Show()
Makes no sense to me, I tried to add an EVT_SHOW on the panel to do a Update after it renderized but it doesn't work too.
Code panel:
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
On the MainFrame I do:
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()
I expect the panel to show full screen on start without resizing the window
If I remove the right panel I get the same with other little panels on vertical until I resize the window and make it again full screen.
BEFORE RESIZE AND FULL SCREEN WITHOUT RIGHT PANEL
(The Light grey should take all the screen in horizontal)
Solved with:
self.Fit()
on the Panel init:
def __init__(self, parent, size):
wx.Panel.__init__(self, parent, size=size)
threading.Thread.__init__(self)
self.__init_layout()
def __init_layout(self):
[.. Code ..]
self.Update()
self.Fit() # HERE AFTER UPDATE
Check answer here for more info and a solution about other problems I found on the same program: wxPython - Panels become right only after Window Resized