def __init__(self):
wx.Frame.__init__(self,None,-1,"快速启动",size=(650,520))
panel=wx.Panel(self,-1)
cmd=wx.StaticText(panel,-1,"cmd:")
self.stringtext=wx.TextCtrl(panel,-1," ",size=(500,-1))
self.button = wx.Button(panel,-1,label='Run',size=(60,30))
self.button.Enable(False)
self.Bind(wx.EVT_TEXT,self.OnEnter,self.stringtext)
self.Bind(wx.EVT_BUTTON,self.OpenFile,self.button)
head = wx.FlexGridSizer(rows=1,cols=3,hgap=5,vgap=5)
head.AddMany([cmd,self.stringtext,self.button])
text =wx.StaticBox(panel, -1, 'setting')
bsizer = wx.StaticBoxSizer(text, wx.VERTICAL)
control = wx.TextCtrl(panel,style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
bsizer.Add(control, flag=wx.EXPAND|wx.ALL)
sizer = self.LayoutPanel(head, bsizer)
panel.SetSizer(sizer)
def LayoutPanel(self, head, days):
bsizer = wx.BoxSizer(wx.VERTICAL)
bsizer.Add(head, flag=wx.EXPAND)
bsizer.Add(days, flag=wx.EXPAND)
return bsizer
5 个解决方案
#1
真心推荐换用PyQt,wx曾经把我搞惨了,don't ask me why
#2
def __init__(self):
...
bsizer.Add(control, 1, wx.EXPAND|wx.ALL)
...
def LayoutPanel(self, head, days):
...
bsizer.Add(days, 1, wx.EXPAND)
...
...
bsizer.Add(control, 1, wx.EXPAND|wx.ALL)
...
def LayoutPanel(self, head, days):
...
bsizer.Add(days, 1, wx.EXPAND)
...
#3
proportion 参数为0,1,2时具体代表什么?我看网上说应该是个相对值是个倍数关系。不知道怎么理解。
#4
我想通过快捷键改变窗口的控件显示,但是按down键后显示的不对。这是什么原因?
def __init__(self):
wx.Frame.__init__(self,None,-1,"快速启动",size=(650,520))
self.panel=wx.Panel(self,-1)
cmd=wx.StaticText(self.panel,-1,"cmd:")
self.stringtext=wx.TextCtrl(self.panel,-1," ",size=(500,-1))
self.button = wx.Button(self.panel,-1,label='Run',size=(60,30))
self.button.Enable(False)
self.Bind(wx.EVT_TEXT,self.OnEnter,self.stringtext)
self.Bind(wx.EVT_BUTTON,self.OpenFile,self.button)
#用sizer控制界面布局
self.head = wx.FlexGridSizer(rows=1,cols=3,hgap=5,vgap=5)
self.head.AddMany([cmd,self.stringtext,self.button])
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.LayoutPanelHide(self.head)
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.LayoutPanelHide(self.head)
elif keycode == wx.WXK_DOWN:
self.LayoutPanelShow()
else:
event.Skip()
def LayoutPanelHide(self, head):
self.sizer.Add(head, flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
def LayoutPanelShow(self):
text =wx.StaticBox(self.panel, -1, 'setting')
bsizer = wx.StaticBoxSizer(text, wx.VERTICAL)
control = wx.TextCtrl(self.panel,style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
bsizer.Add(control,1, flag=wx.EXPAND|wx.ALL)
self.sizer.Add(bsizer,1,flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
def __init__(self):
wx.Frame.__init__(self,None,-1,"快速启动",size=(650,520))
self.panel=wx.Panel(self,-1)
cmd=wx.StaticText(self.panel,-1,"cmd:")
self.stringtext=wx.TextCtrl(self.panel,-1," ",size=(500,-1))
self.button = wx.Button(self.panel,-1,label='Run',size=(60,30))
self.button.Enable(False)
self.Bind(wx.EVT_TEXT,self.OnEnter,self.stringtext)
self.Bind(wx.EVT_BUTTON,self.OpenFile,self.button)
#用sizer控制界面布局
self.head = wx.FlexGridSizer(rows=1,cols=3,hgap=5,vgap=5)
self.head.AddMany([cmd,self.stringtext,self.button])
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.LayoutPanelHide(self.head)
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.LayoutPanelHide(self.head)
elif keycode == wx.WXK_DOWN:
self.LayoutPanelShow()
else:
event.Skip()
def LayoutPanelHide(self, head):
self.sizer.Add(head, flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
def LayoutPanelShow(self):
text =wx.StaticBox(self.panel, -1, 'setting')
bsizer = wx.StaticBoxSizer(text, wx.VERTICAL)
control = wx.TextCtrl(self.panel,style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
bsizer.Add(control,1, flag=wx.EXPAND|wx.ALL)
self.sizer.Add(bsizer,1,flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
#5
面板的动态改变我是通过下面的方法实现的,虽然感觉有点假,但是效果也算达到了。
另外请教个问题,函数里是通过上下方向键来判断的。但实际我是想用ctrl+方向键来判断。
怎么能加上ctrl键?
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.sizer.Hide(self.bsizer)
self.SetClientSize((650,40))
elif keycode == wx.WXK_DOWN:
self.sizer.Show(self.bsizer)
self.SetClientSize((650,520))
else:
event.Skip()
self.sizer.Layout()
另外请教个问题,函数里是通过上下方向键来判断的。但实际我是想用ctrl+方向键来判断。
怎么能加上ctrl键?
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.sizer.Hide(self.bsizer)
self.SetClientSize((650,40))
elif keycode == wx.WXK_DOWN:
self.sizer.Show(self.bsizer)
self.SetClientSize((650,520))
else:
event.Skip()
self.sizer.Layout()
#1
真心推荐换用PyQt,wx曾经把我搞惨了,don't ask me why
#2
def __init__(self):
...
bsizer.Add(control, 1, wx.EXPAND|wx.ALL)
...
def LayoutPanel(self, head, days):
...
bsizer.Add(days, 1, wx.EXPAND)
...
...
bsizer.Add(control, 1, wx.EXPAND|wx.ALL)
...
def LayoutPanel(self, head, days):
...
bsizer.Add(days, 1, wx.EXPAND)
...
#3
proportion 参数为0,1,2时具体代表什么?我看网上说应该是个相对值是个倍数关系。不知道怎么理解。
#4
我想通过快捷键改变窗口的控件显示,但是按down键后显示的不对。这是什么原因?
def __init__(self):
wx.Frame.__init__(self,None,-1,"快速启动",size=(650,520))
self.panel=wx.Panel(self,-1)
cmd=wx.StaticText(self.panel,-1,"cmd:")
self.stringtext=wx.TextCtrl(self.panel,-1," ",size=(500,-1))
self.button = wx.Button(self.panel,-1,label='Run',size=(60,30))
self.button.Enable(False)
self.Bind(wx.EVT_TEXT,self.OnEnter,self.stringtext)
self.Bind(wx.EVT_BUTTON,self.OpenFile,self.button)
#用sizer控制界面布局
self.head = wx.FlexGridSizer(rows=1,cols=3,hgap=5,vgap=5)
self.head.AddMany([cmd,self.stringtext,self.button])
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.LayoutPanelHide(self.head)
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.LayoutPanelHide(self.head)
elif keycode == wx.WXK_DOWN:
self.LayoutPanelShow()
else:
event.Skip()
def LayoutPanelHide(self, head):
self.sizer.Add(head, flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
def LayoutPanelShow(self):
text =wx.StaticBox(self.panel, -1, 'setting')
bsizer = wx.StaticBoxSizer(text, wx.VERTICAL)
control = wx.TextCtrl(self.panel,style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
bsizer.Add(control,1, flag=wx.EXPAND|wx.ALL)
self.sizer.Add(bsizer,1,flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
def __init__(self):
wx.Frame.__init__(self,None,-1,"快速启动",size=(650,520))
self.panel=wx.Panel(self,-1)
cmd=wx.StaticText(self.panel,-1,"cmd:")
self.stringtext=wx.TextCtrl(self.panel,-1," ",size=(500,-1))
self.button = wx.Button(self.panel,-1,label='Run',size=(60,30))
self.button.Enable(False)
self.Bind(wx.EVT_TEXT,self.OnEnter,self.stringtext)
self.Bind(wx.EVT_BUTTON,self.OpenFile,self.button)
#用sizer控制界面布局
self.head = wx.FlexGridSizer(rows=1,cols=3,hgap=5,vgap=5)
self.head.AddMany([cmd,self.stringtext,self.button])
self.sizer = wx.BoxSizer(wx.VERTICAL)
self.LayoutPanelHide(self.head)
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.LayoutPanelHide(self.head)
elif keycode == wx.WXK_DOWN:
self.LayoutPanelShow()
else:
event.Skip()
def LayoutPanelHide(self, head):
self.sizer.Add(head, flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
def LayoutPanelShow(self):
text =wx.StaticBox(self.panel, -1, 'setting')
bsizer = wx.StaticBoxSizer(text, wx.VERTICAL)
control = wx.TextCtrl(self.panel,style=wx.TE_MULTILINE|wx.TE_LINEWRAP)
bsizer.Add(control,1, flag=wx.EXPAND|wx.ALL)
self.sizer.Add(bsizer,1,flag=wx.EXPAND)
self.panel.SetSizer(self.sizer)
#5
面板的动态改变我是通过下面的方法实现的,虽然感觉有点假,但是效果也算达到了。
另外请教个问题,函数里是通过上下方向键来判断的。但实际我是想用ctrl+方向键来判断。
怎么能加上ctrl键?
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.sizer.Hide(self.bsizer)
self.SetClientSize((650,40))
elif keycode == wx.WXK_DOWN:
self.sizer.Show(self.bsizer)
self.SetClientSize((650,520))
else:
event.Skip()
self.sizer.Layout()
另外请教个问题,函数里是通过上下方向键来判断的。但实际我是想用ctrl+方向键来判断。
怎么能加上ctrl键?
def OnKeyDown(self, event):
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
self.sizer.Hide(self.bsizer)
self.SetClientSize((650,40))
elif keycode == wx.WXK_DOWN:
self.sizer.Show(self.bsizer)
self.SetClientSize((650,520))
else:
event.Skip()
self.sizer.Layout()