在 PyGTK 应用程序中嵌入电子表格/表格?
在我的应用程序中,我们希望向用户展示一个典型的电子表格/表格(OO.O/Excel 样式),然后提取值并在内部对它们执行某些操作。
PyGTK 是否有一个预先存在的小部件可以执行此操作? PyGTK 常见问题解答提到GtkGrid,但链接已失效,我在任何地方都找不到 tarball。
In my application, we want to present the user with a typical spreadsheet/table (OO.O/Excel-style), and then pull out the values and do something with them internally.
Is there a preexisting widget for PyGTK that does this? The PyGTK FAQ mentions GtkGrid, but the link is dead and I can't find a tarball anywhere.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
GtkGrid
已被弃用,取而代之的是更强大、更可定制的GtkTreeView
。它可以显示树和列表。要使其像表格一样工作,您必须定义一个
ListStore
将从哪里获取数据,以及TreeViewColumn
用于要显示的每一列,使用CellRenderer
定义如何显示列。这种数据和渲染的分离允许您在单元格上渲染其他控件,例如文本框或图像。GtkTreeView
非常灵活,但由于选项很多,一开始看起来很复杂。为了帮助解决这个问题,相关部分位于PyGTK 教程(尽管您应该完整阅读它,而不仅仅是本节)。为了完整起见,这里有一个示例代码及其在我的系统中运行的屏幕截图:
GtkGrid
is deprecated in favor of the more powerful and more customizableGtkTreeView
.It can display trees and lists. To make it work like a table, you must define a
ListStore
where it will take the data from, andTreeViewColumn
s for each column you want to show, withCellRenderer
s to define how to show the column. This separation of data and render allows you to render other controls on the cell, like text boxes or images.GtkTreeView
is very flexible, but it seems complex at first because of the many options. To help with that, there's the relevant section in the PyGTK tutorial (although you should read it entirely, not just this section).For completeness, here's an example code and a screenshot of it running in my system:
它可能比 .Net 中的 GridView 等需要更多的手动操作,但是 Tree View 小部件可以满足您的需要,甚至更多。请参阅 PyGtk TreeView
It's perhaps a little more manual than, for instance, a GridView in .Net, but the Tree View widget will do what you need and much more. See PyGtk TreeView
您可能会考虑嵌入网页查看器 - 您可以用它做很多事情:http://blog.mypapit.net/2009/09/pymoembed-web-browser-in-python-gtk-application.html
You might consider embedding a web page viewer - you can do a lot with that: http://blog.mypapit.net/2009/09/pymoembed-web-browser-in-python-gtk-application.html