wxPython:如何将一个面板放在另一个面板上

发布于 2024-11-30 13:47:15 字数 550 浏览 2 评论 0原文

这是关于 wxPython 的。

我想要 2 个面板,一个放在另一个上:
PanelBG 应该是某种“背景”,有自己的 GridBagSizer 以及子面板、StaticTexts 等;
PanelFG 应该是“前景”面板,也有自己的 GridBagSizer 和一些静态文本、按钮...但背景是透明的,这样 PanelBG 在任何地方都可见PanelFG 不放置小部件。

我需要两个面板都拉伸到框架的所有侧面,即使在调整窗口大小时也是如此,尽管从不改变倒数比例,这就是为什么我不确定是否有办法使用绝对定位。

如果您想知道,我不想使用单个面板的原因是合并 2 个 GridBoxSizer 需要我在 sizer 中放置更多单元格,因为前景和背景的行和列并不总是相同重合,我应该将它们分成许多单元格,网格尺寸增长到数百**2。
由于我想要放在前台的内容需要经常更新和刷新,这将需要每次重新绘制所有单元格,这将需要 10 - 20 秒才能完成操作(经过测试)。仅更新前景只需要百分之一秒。

谢谢你!

This is about wxPython.

I would like to have 2 Panels laying one over the other:
PanelBG should be some sort of a "background", with its own GridBagSizer with subPanels, StaticTexts and so on;
PanelFG should be the "foreground" panel, also with its own GridBagSizer with some StaticTexts, Buttons... but a transparent background, in such a way that PanelBG is visible wherever PanelFG doesn't lay widgets.

I need both Panels to stretch to all the sides of the frame, even when resizing the window, though never changing the reciprocal proportions, that's why I'm not sure if there's a way to use absolute positioning.

In case you are wondering, the reason why I don't want to use a single Panel is that merging the 2 GridBoxSizers would require me to place many many more cells in the sizer, because rows and columns of foreground and background don't always coincide, and I should split them in many cells, with grid dimensions growing up to hundreds**2.
Since the content I want to put in the foreground needs to be updated and refreshed quite often, this would require redrawing all the cells every time, which would take 10 - 20 seconds to complete the operation (tested). Updating only the foreground would require just some hundredths of a second instead.

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山川志 2024-12-07 13:47:15

这至少部分是方向的改变,但可能值得检查您拥有的其他渲染选项。

特别是,我正在考虑 wxWebKit (http://wxwebkit.kosoftworks.com/),它可以让您使用 WebKit 浏览器渲染引擎进行分层等操作。我不确定它是否处于可以提供您需要的一切的阶段,因为我还没有实际使用过它,但即使它不起作用,那么它可能是一种值得尝试的方法 - 使用 HTML/CSS 作为您的一部分显示,同时将整个内容包装在 wxPython 应用程序中。

This would be at least partially a change of direction, but it might be worth examining what other rendering options you have.

In particular, I'm thinking of wxWebKit (http://wxwebkit.kosoftworks.com/), which would let you do layering, etc. using the WebKit browser rendering engine. I'm not sure whether it's at a stage that would provide everything you need since I haven't actually used it, but even if it doesn't work then it may be an approach worth trying - using HTML/CSS for part of your display, while wrapping the whole in a wxPython app.

赠佳期 2024-12-07 13:47:15

据我了解,这是一个日历,其中包含当天的事件的矩形。

简单的事情是使用一个 wxGrid,有七列和四或五行,来表示月份。然后,您可以将事件放入正确日期的网格单元中。 wxGrid 小部件将负责正确刷新所有内容的细节。

使用wxGrid,您可能会失去对确切外观的一些控制,尽管一旦您学习了wxGrid的许多方法,wxGrid就非常灵活且功能丰富,但是您将不必编写大量代码,而这些代码需要大量的调试工作。

As I understand it, this is a calendar with rectangles for the days containing the events for the days.

The simple thing would be to use a wxGrid, with seven columns and four or five rows, to represent the months. You would then place the events into the grid cell for the correct date. The wxGrid widget would look after the details of refreshing everything properly.

Using wxGrid you might lose a little control over the exact appearance, though wxGrid is very flexible and feature rich once you learn its many methods, but you would save yourself having to write large amounts of code that would require significant effort to debug.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文