- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
下面是一个非常简单的 wxPython 代码,创建一个笔记本,其中有几个包含 TreeCtrl 对象的面板。
使用它,我得到了我想避免的行为:
当我在树中单击时,如果不先在树外单击,则无法直接切换到笔记本的另一页面。这意味着需要单击两次才能更改笔记本页面:一次单击离开树,另一次单击切换页面。
我希望能够通过一次点击来完成此操作。
代码:
import wx
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, wx.ID_ANY)
# Create the notebook
notebook = wx.Notebook(self)
# Put panels in the notebook
notebook.AddPage(TestPanel(notebook), "Page 1")
notebook.AddPage(TestPanel(notebook), "Page 2")
# Display the window
self.Show(True)
class TestPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
# Create the sizer
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)
# Create the tree
tree = wx.TreeCtrl(self)
sizer.Add(tree, 1, wx.EXPAND)
# Create nodes in the tree
root = tree.AddRoot("root")
tree.AppendItem(root, "item 1")
tree.AppendItem(root, "item 2")
tree.AppendItem(root, "item 3")
# Expand the root node
tree.Expand(root)
if __name__ == "__main__":
# Create an application without redirection of stdout/stderr to a window
application = wx.App(False)
# Open a main window
frame = TestFrame()
# Launch the application
application.MainLoop()
最佳答案
这看起来像this bug这应该在 3.0.2 中修复。如果您使用的是早期版本,请升级。
关于python - 避免在笔记本中单击退出 wxPython TreeCtrl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26671970/
我想要一个树控件,我可以右键单击以创建弹出菜单。单击项目菜单时,会发送一个事件,其中包含树中的 ItemData。我不知道该怎么做。到目前为止我所拥有的只是一个简单的弹出菜单生成 # Panel de
我正在使用以下方法遍历 wxpython treectrl 的所有节点。 def get_desired_parent(self, name, selectednode = None): i
我正在使用 wxPython 并得到了一棵包含一些项目的树。现在我需要一个函数,它按名称给我树项对象。 例如:item = self.GetItemByName("我的故事") 我在文档中找不到这样的
下面是一个非常简单的 wxPython 代码,创建一个笔记本,其中有几个包含 TreeCtrl 对象的面板。 使用它,我得到了我想避免的行为: 当我在树中单击时,如果不先在树外单击,则无法直接切换到笔
我正在使用 wxPython 制作一个 python 树可视化工具。它会像这样使用: show_tree([ 'A node with no children', ('A node with chil
我使用 TVN_SELCHANGED 消息来找出用户在项目树(菜单)中选择的内容。 但是,如果用户连续点击同一个项目,则不会出现该消息。 我希望 treeCtrl 在发生 TVN_SELCHANGED
wx.TreeCtrl 的首选大小似乎是当树完全折叠时所有元素适合的最小大小。是否有一种好的(即跨平台兼容)方法来计算树的宽度并展开所有内容?我目前的解决方案是这样的: def max_width(s
我正在尝试在 wx.TreeCtrl 上实现拖放操作,我需要同时处理这两个问题“复制”和“移动”操作(如果用户按住 CTRL)。 首先,我搜索了 wiki举个例子,我很困惑使用哪种方法.. 我应该使用
如何向下面名为 fileTree 的 wx.TreeCtrl 中的附加树项添加额外数据。我将文本文件中的数据读入数组以构建树。树中的附加项是图像的文件名,但我想知道如何将完整的文件路径添加到每个项目。
我尝试在 Windows7 上安装 TkTreectrl 没有成功。 我下载了 2.0.1 版本的包解压并尝试运行 setup.py。那个人总是首先提示文件夹 TkTreectrl 不存在,这是错误的
我正在创建具有数百万个节点的树,但是当我切换到在树控件 (wx.TR_MULTIPLE) 上使用多选时,树上的操作变得更慢,我只单击以选择一个节点,这需要我几秒钟的时间。当我使用单选样式 (wx.TR
我有一个 wx.TreeCtrl用户可以按不同标准(日期、名称、ID、降序、升序等)对项目进行排序的结构。这在 Python 2 中运行良好,但 Python 3(使用 wxPython 4)拒绝排序
当鼠标右键单击事件发生时,有没有办法在类 MSComctlLib.TreeCtrl.2 树 View 中单击节点? 可用的方法包括 TV_nodeClick(ByVal 节点作为对象) 它清楚地提供了
我是一名优秀的程序员,十分优秀!