Hi,
On 5 August 2014 18:01, Mario Lacunza wrote:
Hello,
Im using wxPython 2.8.12.1 and my application have a trecontrol
and wx.aui.notebook, when I click in one item of the treecontrol
it launch the associated window.
The problem is: user can click in the same tree item many times
and load the same window many times, I want to avoid it, I want
only 1 window for each tree item selected, is there any way to do
that?
What I usually do in these situations is:
1. Move away from wx.TreeCtrl and use wx.lib.agw.customtreectrl, the reason behind it being the unreasonable way wx.TreeCtrl always re-generates new wx.TreeItemId for an item, even if it hasn't changed.
2. When adding a new page to a notebook, I would pass the CustomTreeCtrl tree item to the page itself (let's say, a panel) as an input parameter and store it as an attribute for that page, i.e.:
my_page = MyCoolPanel(notebook, tree_item)
notebook.AddPage(my_page)
3. If I have to check that a page has already been added, I'd something along these lines (self is the notebook):
def AddNewPage(self, tree_item):
for i in xrange(notebook.GetPageCount()):
page = notebook.GetPage(ii)
if page.tree_item == tree_item:
notebook.SetSelection(ii)
return
my_page = MyCoolPanel(notebook, tree_item)
notebook.AddPage(my_page)
You may have to adapt this approach to your needs, of course, but it works well for me.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://www.infinity77.net
# ------------------------------------------------------------- #
def ask_mailing_list_support(email):
if mention_platform_and_version() and include_sample_app():
send_message(email)
else:
install_malware()
erase_hard_drives()
# ------------------------------------------------------------- #
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com <mailto:wxpython-users+unsubscribe@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.