473,705 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Some issue with right click in TreeCtrl

Hello All,

Please find the code for a simple wx.TreeCtrl code. Whenever I right click
on any item in the Tree, I see the function, 'OnSelChanged' gets called

What I've just done is that I've associated the function 'OnRightClick' with
wx.EVT_TREE_ITE M_RIGHT_CLICK. And in this function, I say
self.tree.Selec tItem(evt.GetIt em(),True) to select the item and then so some
action for right click.

Can any one help.

Thanks & Regards,

*Please find the code in the attachment and also below:-*

import wx
tests = ["All Tests",
["suite2","test0 3","test04"],
class TestFrame(wx.Fr ame):
def __init__(self):
wx.Frame.__init __(self, None, title="Simple Tree", size=(400,500))
# Create the tree
self.tree = wx.TreeCtrl(sel f)
# Add a root node
root = self.tree.AddRo ot(tests[0])
# Add nodes from our data set
self.AddTreeNod es(root, tests, 0)
# Bind some interesting events
self.Bind(wx.EV T_TREE_SEL_CHAN GED, self.OnSelChang ed, self.tree)
self.Bind(wx.EV T_TREE_ITEM_RIG HT_CLICK, self.OnRightCli ck,
# Expand the first level
self.tree.Expan d(root)

def AddTreeNodes(se lf, father, aTestList,count ):
if type(aTestList) == type([]):
l = len(aTestList)
i = 0
while i < l:
if i == 0:
if count ==1:
father = self.tree.Appen dItem(father, aTestList[i])
self.AddTreeNod es(father, aTestList[i],
i = i + 1
if type(aTestList) == type(""):
self.tree.Appen dItem(father, aTestList)

def OnRightClick(se lf, evt):
self.tree.Selec tItem(evt.GetIt em(),True)
print 'In OnRightClick Function...',se lf.GetItemText( evt.GetItem())

def GetItemText(sel f, item):
if item:
return self.tree.GetIt emText(item)
return ""

def OnSelChanged(se lf, evt):
print "OnSelChang ed: ", self.GetItemTex t(evt.GetItem() )

app = wx.PySimpleApp( redirect=True)
frame = TestFrame()

Jun 27 '08 #1
0 1066

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Martin Drautzburg | last post by:
In the wx demoy TreeCtrl.py I find the following code, that should have no effect but seems to be needed nevertheless. class TestTreeCtrlPanel(wx.Panel): def __init__(self, parent, log): , isz) fldridx = il.Add(wx.ArtProvider_GetBitmap(wx.ART_FOLDER, wx.ART... self.tree.SetImageList(il)
by: mitsura | last post by:
Hi, I am writing a program in Python and I am using wx.Python for the GUI. I have no prior GUI and Python experience so that's why I turn to the specialists for aid. Basically, my app is a wx.tree object with items. You can click on each item and set some properties of the item (Pydata). To set the properties of an item you click on the item and then a 'Set item properties' window pops up. However, I am looking for a way that you can...
by: damjanu | last post by:
Hi All; I need little help. I have a datasheet form. I allow user to do 'filter by selection'. My form contains a column with values. As user changes selections, I want to calculate totals. I can do this the first time the form loads.
by: Lars Grøtteland | last post by:
Hello! Having problems about right clicking on an item in a tree control. The item that is clicked on is not the right one. If I have three items in a tree. Here is my problem. I click on the first item with normal click. I click on the third item with the right click mouse. In this event I had a messagebox telling me which item is selected, and this one comes out with the first item no mather what. I also tried to get into the...
by: Smithers | last post by:
My ASP.NET app enables users to upload photos - after which they can optionally rotate the photo (90 degrees to the left or right). They just click a link that causes a postback, and server-side code then manipulates the image file - after which the aspx page refreshes on the client, showing the rotated version of the photo. In testing I have observed that sometimes the image will in fact get rotated (on the server), but the aspx page in...
by: Saketh | last post by:
Hello, everyone. I am a writing an application that I want to make a stripped-down framework of Leo for Cornell note-taking. I have one TreeCtrl, a menu, and a status bar. There are two classes currently - the Application class and the Frame class. The Frame class contains all of the event handling, such as OnAbout and OnExit. I am trying to add keyboard shortcuts. When someone hits Ctrl-I, I want a new node to be added at the...
by: AlmasKhan01 | last post by:
Hi I have been for sometime now been working on a MineSweeper program and I'm 90% complete on it it involves a window interface and is quite simple but the issue is not. The program is long(to me) and includes maybe 4 classes and lots of code I was wondering if anyone would mind taking a look at it for me, I know thats a lot to ask of someone that knows nothing of me, but this problem is killing me and I have spent many hours trying to figure...
by: raja11112222 | last post by:
Hi, I am Using MFC, In that, I used Icon in the treeCtrl , My problem is I need to place two icons continously in the tree . Is there any possible way to do. Thanks
by: SAL | last post by:
Hello, I'm trying to include a popup in the ItemTemplate of a gridview row. The ItemTemplate for the field contains a textbox and when the user clicks in the textbox I want a popup panel to show allowing the user to make a selection from the popup window. I have enabled AJAX extensions and have a working sample outside of a gridview. However, when I click in the textbox of a gridview row, all I see is a really small square instead of the...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.