我有一个wxpython列表框,其高度设置为-1,这意味着它将自动设置为窗口的高度。有没有办法在窗口末端留下200px?
所以我觉得我正在寻找的是(window_height - 200),留下200个空间。
-1将达到整个窗口高度。
感谢。
编辑:我似乎无法使用我的代码;
COLORS = ["red", "blue", "black", "yellow", "green"]
NUMBERS = ['0', '1', '2', '3', '4']
image=[];
import random
import wx
class images_tab(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
## random test useless t = wx.StaticText(self, -1, "This is a PageOne object", (20,20))
self.listBox = wx.ListBox(self, size=(200, -1), choices=image, style=wx.LB_SINGLE)
# self.button = wx.Button(self, label="Something else here? Maybe!")
self.sizer = wx.BoxSizer()
self.sizer.Add(self.listBox, proportion=0, flag=wx.ALL | wx.EXPAND, border=5)
# self.sizer.Add(self.button, proportion=1, flag=wx.ALL)
self.SetSizer(self.sizer)
class MyNotebook(wx.Notebook):
def __init__(self, *args, **kwargs):
wx.Notebook.__init__(self, *args, **kwargs)
class MyPanel(wx.Panel):
def __init__(self, *args, **kwargs):
wx.Panel.__init__(self, *args, **kwargs)
self.notebook = MyNotebook(self, size=(220, -1))
Images__tab = images_tab(self.notebook)
# add the pages to the notebook with the label to show on the tab
self.notebook.AddPage(Images__tab, "Click here to lookat pictures")
self.sizer = wx.BoxSizer()
self.sizer.Add(self.notebook, proportion=0, flag=wx.EXPAND)
#self.sizer.Add(self.button, proportion=0) #with button
self.SetSizer(self.sizer)
class MainWindow(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)
self.SetTitle("Python: Pictures")
self.panel = MyPanel(self)
app.frame = wx.Frame(parent=None, id=-1, size=(300,400))
self.Show()
app = wx.App(False)
win = MainWindow(None, size=(600, 400))
app.MainLoop()
答案 0 :(得分:0)
把它放在sizer中:mysizer.Add(myListBox,0,wx.BOTTOM,200)
编辑:或者您可以使用wx.GetDisplaySize()来获取窗口的宽度和高度,从高度减去200并使用它来设置列表框的大小。