如何解决如何创建与左侧垂直对齐的选项卡
当我从 Kivy 转移过来时,我对 wxPython 完全陌生,我怎样才能实现一个选项卡菜单,其中选项卡指示器垂直向左对齐而占位符保持在右边?
使用以下代码可以创建具有 4 个选项卡的基本布局。
import wx
# Define the tab content as classes:
class TabOne(wx.Panel):
def __init__(self,parent):
wx.Panel.__init__(self,parent)
t = wx.StaticText(self,-1,"This is the first tab",(20,20))
button = wx.Button(self,label = "Hello World")
class TabTwo(wx.Panel):
def __init__(self,"This is the second tab",20))
class TabThree(wx.Panel):
def __init__(self,"This is the third tab",20))
class TabFour(wx.Panel):
def __init__(self,"This is the last tab",20))
class MainFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,title="wxPython tabs example @pythonspot.com")
# Create a panel and notebook (tabs holder)
p = wx.Panel(self)
nb = wx.Notebook(p)
# Create the tab windows
tab1 = TabOne(nb)
tab2 = TabTwo(nb)
tab3 = TabThree(nb)
tab4 = TabFour(nb)
# Add the windows to tabs and name them.
nb.AddPage(tab1,"Tab 1")
nb.AddPage(tab2,"Tab 2")
nb.AddPage(tab3,"Tab 3")
nb.AddPage(tab4,"Tab 4")
# Set noteboook in a sizer to create the layout
sizer = wx.BoxSizer()
sizer.Add(nb,1,wx.EXPAND)
p.SetSizer(sizer)
if __name__ == "__main__":
app = wx.App()
MainFrame().Show()
app.MainLoop()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。