我有一个wx 2.8(Python 2.7)基本GUI,可在按下下一个按钮时切换面板。打开GUI时,它会最大化。出于某种原因,在Windows 7/10上,整个窗口调整到最小尺寸,但在Ubuntu 14.04上,它没有。有人可以告诉我这里我做错了什么吗?我不希望窗口调整大小,我希望它保持最大化。整个代码如下:
#!/usr/bin/env python
import wx
class MainWindow(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY, "Test")
self.SetMinSize((1000, 700))
self.Maximize(True)
self.panel_one = Panel_One(self)
self.panel_two = Panel_Two(self)
self.panel_three = Panel_Three(self)
self.panel_two.Hide()
self.panel_three.Hide()
self.PanelSizer = wx.BoxSizer(wx.VERTICAL)
self.PanelSizer.Add(self.panel_one, 1, wx.CENTER|wx.EXPAND|wx.ALL)
self.PanelSizer.Add(self.panel_two, 1, wx.CENTER|wx.EXPAND|wx.ALL)
self.PanelSizer.Add(self.panel_three, 1, wx.CENTER|wx.EXPAND|wx.ALL)
self.SetSizer(self.PanelSizer)
self.Center()
def ShowPanelTwo(self, event):
self.panel_one.Hide()
self.panel_two.Show()
self.panel_two.TopSizer.Fit(self)
def ShowPanelThree(self, event):
self.panel_two.Hide()
self.panel_three.Show()
self.panel_three.TopSizer.Fit(self)
class Panel_One(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.parent = parent
self.list = wx.ListCtrl(self, wx.ID_ANY, style = wx.LC_REPORT | wx.BORDER_SUNKEN)
self.list.InsertColumn(0, 'List 1')
self.nextbutton = wx.Button(self, wx.ID_ANY, label="Next", size=(80,-1))
self.nextbutton.Bind(wx.EVT_BUTTON, self.parent.ShowPanelTwo)
self.VSizer = wx.BoxSizer(wx.VERTICAL)
self.HSizer = wx.BoxSizer(wx.HORIZONTAL)
self.TopSizer = wx.BoxSizer(wx.VERTICAL)
self.VSizer.Add(self.list, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.HSizer.Add(self.VSizer, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.TopSizer.Add(self.HSizer, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.TopSizer.Add(self.nextbutton, 0, wx.EXPAND, 5)
self.SetSizer(self.TopSizer)
class Panel_Two(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.parent = parent
self.list = wx.ListCtrl(self, wx.ID_ANY, style = wx.LC_REPORT | wx.BORDER_SUNKEN)
self.list.InsertColumn(0, 'List 2')
self.nextbutton = wx.Button(self, wx.ID_ANY, label="Next", size=(80,-1))
self.nextbutton.Bind(wx.EVT_BUTTON, self.parent.ShowPanelThree)
self.VSizer = wx.BoxSizer(wx.VERTICAL)
self.HSizer = wx.BoxSizer(wx.HORIZONTAL)
self.TopSizer = wx.BoxSizer(wx.VERTICAL)
self.VSizer.Add(self.list, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.HSizer.Add(self.VSizer, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.TopSizer.Add(self.HSizer, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.TopSizer.Add(self.nextbutton, 0, wx.EXPAND, 5)
self.SetSizer(self.TopSizer)
class Panel_Three(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.parent = parent
self.list = wx.ListCtrl(self, wx.ID_ANY, style = wx.LC_REPORT | wx.BORDER_SUNKEN)
self.list.InsertColumn(0, 'List 3')
self.VSizer = wx.BoxSizer(wx.VERTICAL)
self.HSizer = wx.BoxSizer(wx.HORIZONTAL)
self.TopSizer = wx.BoxSizer(wx.VERTICAL)
self.VSizer.Add(self.list, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.HSizer.Add(self.VSizer, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.TopSizer.Add(self.HSizer, 1, wx.ALIGN_CENTER|wx.EXPAND, 5)
self.SetSizer(self.TopSizer)
if __name__ == '__main__':
app = wx.App(False)
frame = MainWindow()
frame.Show()
app.MainLoop()
答案 0 :(得分:1)
尝试用Error:Failed to complete Gradle execution.
Cause:
Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/2.10/userguide/gradle_daemon.html
Please read the following process output to find out more:
-----------------------
Error occurred during initialization of VM
Could not reserve enough space for object heap
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
替换self.whatever.TopSizer.Fit(self)
行。你不想改变self.Layout()
所做的任何事情的大小,你只需要根据sizer的布局算法来布置面板的内容。