pygtk:无法在顶级小部件上设置父级
我正在开发一个有 Glade GUI 的项目。
我需要主窗口有 2 个部分,由 gtk.Hpaned 小部件(水平窗格)划分。
左窗格将有一个类似工具栏的按钮布局,可能有 3 个或更多。
我需要的是一种创建不同窗口并将它们显示在主窗口的右侧窗格上的方法。这样,当我单击按钮 1 时,子窗口 1 将出现在右侧窗格中。单击按钮2,子窗口2将出现在右侧窗格中。
我不想让窗口左右弹出,而是想将它们重新设置到这个 gtk.Hpaned 的右窗格中。
你如何使用 pygtk 在 python 中做到这一点?
I'm working on a project that has a glade GUI.
I need the main window to have 2 section, divided by a gtk.Hpaned widget (horizontal panes).
The left pane would have a tool-bar like layout of buttons, maybe 3 or more.
What I need is a way to create different windows and display them on the right pane of the main window. This way, when I click button 1, subwindow1 will appear in the right pane. Click button2, subwindow2 will appear on the right pane.
Instead of having windows pop-up left and right, I want to reparent them to the right pane of this gtk.Hpaned widged.
How do you do this in python with pygtk?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你试试这个吗?
reparent() 方法将小部件从一个 gtk.Container 移动到另一个。
Do you try this?
The reparent() method moves a widget from one gtk.Container to another.
您可以在右侧窗格中放置一个笔记本,而不是创建窗口。然后将之前的所有窗口创建为页面。单击该按钮即可在笔记本中显示相应的页面。
Instead of creating windows you could put a notebook in the right pane. Then create all the previous windows as pages. Click on the button can then show the appropriate page in the notebook.
我建议您使用盒子来放置窗格。从一个水平框开始,它基本上将充当您的主窗口:
然后是两个用于窗格的垂直框:
then add whatever buttons you like to your panes:
(with a VERTICAL Box, pack_start will add the child widget you specify (btnN above) to the top of the box, and continue down as you keep calling pack_start. HORIZONTAL will go left to right.)
Then finally add your vertical boxes to the main horizontal box, and ultimately add the horizontal box to your main window.
听起来您想将窗口小部件添加到右侧框中。我无法回答这是否可能,因为我认为 Window 更被视为更高级别的容器。我想将一些文本框等打包到右侧框中会更有意义。不知道为什么要添加窗口小部件。来吧,尝试一下。
I would recommend using boxes for your panes. Start with a horizonatal Box that will essentially act as your main window:
then two vertical boxes for your panes:
then add whatever buttons you like to your panes:
(with a VERTICAL Box, pack_start will add the child widget you specify (btnN above) to the top of the box, and continue down as you keep calling pack_start. HORIZONTAL will go left to right.)
Then finally add your vertical boxes to the main horizontal box, and ultimately add the horizontal box to your main window.
It sounds like you want to add window widgets to the right-hand box. I can't answer if that is possible as I assume Window is more regarded as a higher level Container. I imagine it would make more sense to pack into the right side box some text boxes, etc. Not sure why you would want to add a Window widget. Go ahead and give it a try.