473,854 Members | 1,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Disabling right click over wx.iehtmlWindow

Subsciber123
87 New Member
I have a window that I have created using Python Card that contains an wx.iehtmlWindow opject inside of it. Does anyone know how to disable right click and/or cause links that would open in new windows to open in the same window?

I am running Windows XP Home.

I am running ActiveState Python 2.4.

Anything that I have tried has done absolutely nothing, because I can't get the events from the wx.iehtmlWindow to filter them for right clicks.
Jan 18 '07 #1
12 4247
bartonc
6,596 Recognized Expert Expert
I have a window that I have created using Python Card that contains an wx.iehtmlWindow opject inside of it. Does anyone know how to disable right click and/or cause links that would open in new windows to open in the same window?

I am running Windows XP Home.

I am running ActiveState Python 2.4.

Anything that I have tried has done absolutely nothing, because I can't get the events from the wx.iehtmlWindow to filter them for right clicks.
This should be the kind of idea to persue. In order to block an event, bind very high in the hierachy and don't call event.Skip(). You can test for conditions when you DO want the event to propagate and then call event.Skip()
Expand|Select|Wrap|Line Numbers
  1. #Boa:Frame:Frame1
  2.  
  3. import wx
  4. import wx.html
  5.  
  6. def create(parent):
  7.     return Frame1(parent)
  8.  
  9. [wxID_FRAME1, wxID_FRAME1HTMLWINDOW1, 
  10. ] = [wx.NewId() for _init_ctrls in range(2)]
  11.  
  12. class Frame1(wx.Frame):
  13.     def _init_ctrls(self, prnt):
  14.         # generated method, don't edit
  15.         wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(431, 243),
  16.                 size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
  17.         self.SetClientSize(wx.Size(392, 223))
  18.  
  19.         self.htmlWindow1 = wx.html.HtmlWindow(id=wxID_FRAME1HTMLWINDOW1, name='htmlWindow1',
  20.                 parent=self, pos=wx.Point(88, 72), size=wx.Size(200, 100),
  21.                 style=wx.html.HW_SCROLLBAR_AUTO)
  22.         self.htmlWindow1.Bind(wx.EVT_LEFT_DOWN, self.OnHtmlWindow1LeftDown)
  23.  
  24.     def __init__(self, parent):
  25.         self._init_ctrls(parent)
  26.  
  27.     def OnHtmlWindow1LeftDown(self, event):
  28.         pass    #  this is here for demonstration ONLY.
  29.         #if IWantThisEvent:
  30.             #event.Skip()
  31.         #else:
  32.             #pass    # to block an event, simply don't call event.Skip()
  33.  
Jan 19 '07 #2
Subsciber123
87 New Member
I suppose that my code will be a little different, seeing as I am using PythonCard, not BoaConstructor. All my child objects (except windows) are created using a resource file, and are stored in self.components .

My class would probably look more like:

Expand|Select|Wrap|Line Numbers
  1. import os
  2. from PythonCard import model  #don't worry about some of these: some are
  3. import wx                    #used in other parts of the program
  4. import thread
  5. from time import sleep
  6.  
  7. class window(model.Background):
  8.  
  9.     def on_initialize(self, event):
  10.         self.components.htmlDisplay.Bind(wx.EVT_LEFT_DOWN, 
  11.             self.on_htmlDisplay_leftDown) #bartonc's line modified
  12.  
  13.     def on_htmlDisplay_leftDown(self, event): #bartonc's function
  14.         if IWantThisEvent:
  15.             event.Skip()
  16.         else:
  17.             DoWhatever
  18.  
I haven't tested it yet, but it will probably work with these minor modifications.
Jan 19 '07 #3
Subsciber123
87 New Member
Now that I've tested it, it doesn't work. There are no exceptions or anything. I switched the wx.EVT_LEFT_DOW N with wx.EVT_RIGHT_DO WN, and had the function that I bound print "blah". I didn't get any "blah"'s printed, and the context menu still worked in wx.iehtmlWindow . My guess is that wx.iehtmlWindow is catching the events (since it is an activex control of IE), and not putting the events through my program before evaluating them. Any ideas?
Jan 19 '07 #4
Subsciber123
87 New Member
Just as an afterthought, maybe I could put a clear picture in front of it, and relay click events that I approve to the wx.iehtmlWindow . I have no idea how I would do this, though.
Jan 19 '07 #5
bartonc
6,596 Recognized Expert Expert
Now that I've tested it, it doesn't work. There are no exceptions or anything. I switched the wx.EVT_LEFT_DOW N with wx.EVT_RIGHT_DO WN, and had the function that I bound print "blah". I didn't get any "blah"'s printed, and the context menu still worked in wx.iehtmlWindow . My guess is that wx.iehtmlWindow is catching the events (since it is an activex control of IE), and not putting the events through my program before evaluating them. Any ideas?
Don't know if
class window(model.Ba ckground):
is an event handler class, but if it is you might try binding to the window instead of the iehtmlWindow. It's worth a shot, anyway.
Jan 19 '07 #6
Subsciber123
87 New Member
It may help for me to describe a little how PythonCard works (or at least how it is persieved to work).

model.Backgroun d is contained inside PythonCard.

PythonCard takes the file that you import it from (say, "window.py" ), and any top level windows that you create uses the associated resource file (in this case, "window.rsrc.py ") to create the windows with objects in them.

In a class, PythonCard does all the binding for you: all you have to do is create a function with a name of the form
"on_[name of object in window]_[name of event](self,event):"
or
"on_[name of event](self,event):"
for events bound to every object in the window.

For example, "on_htmlDisplay _documentComple te(self,event): "
gets called whenever htmlDisplay finishes loading a document.

I am not sure how to bind the entire window to an event, just how to bind every object in the window to an event (they are not the same thing).

Any suggestions would be helpful. I also recommend that you look into PythonCard yourself. Firstly, it makes creating windows really easy, and secondly, it will help you understand my problem better.
Jan 19 '07 #7
Subsciber123
87 New Member
Okay, now I've gotten the chance to try to bind the window to an arbitrary function, and nothing happens:
Expand|Select|Wrap|Line Numbers
  1. import os
  2. from PythonCard import model  #don't worry about some of these: some are
  3. import wx                    #used in other parts of the program
  4. import thread
  5. from time import sleep
  6.  
  7. class window(model.Background):
  8.  
  9.     def on_initialize(self, event):
  10.         self.Bind(wx.EVT_LEFT_DOWN,   
  11.             self.on_htmlDisplay_leftDown)
  12.  
  13.     def on_htmlDisplay_leftDown(self, event):
  14.     print "leftDown event"
  15.     event.skip()
  16.  
There are no errors, but nothing is printed no matter where on the screen I click, or right click, or middle click, whatever.

I am thinking that the only solution is to put a clear image in front of it, and transfer click events that I approve of to the wx.iehtmlWindow .

If anybody has any ideas on how to do this, please let me know!
Jan 21 '07 #8
bartonc
6,596 Recognized Expert Expert
Okay, now I've gotten the chance to try to bind the window to an arbitrary function, and nothing happens:
Expand|Select|Wrap|Line Numbers
  1. import os
  2. from PythonCard import model  #don't worry about some of these: some are
  3. import wx                    #used in other parts of the program
  4. import thread
  5. from time import sleep
  6.  
  7. class window(model.Background):
  8.  
  9.     def on_initialize(self, event):
  10.         self.Bind(wx.EVT_LEFT_DOWN,   
  11.             self.on_htmlDisplay_leftDown)
  12.  
  13.     def on_htmlDisplay_leftDown(self, event):
  14.     print "leftDown event"
  15.     event.skip()
  16.  
There are no errors, but nothing is printed no matter where on the screen I click, or right click, or middle click, whatever.

I am thinking that the only solution is to put a clear image in front of it, and transfer click events that I approve of to the wx.iehtmlWindow .

If anybody has any ideas on how to do this, please let me know!
I'd be curious to know if on_initialize() is truly being called. If it is, then the model.Backgroun d class is not handling events properly because this should work.
I'm near the end of a large project with a deadline looming. Otherwise I would take some time to prove my thoughts regarding PyCard.
Jan 21 '07 #9
Subsciber123
87 New Member
A good article on how binding works in wxPython is located at:
http://wiki.wxpython.o rg/index.cgi/self.Bind_vs._s elf.button.Bind

To answer your query, on_initialize is being called; I know because there are many other things in there such that if it were not called, the program would come crashing to the ground.

According to that article, the more specific the binding is, the sooner it will be called on the hierarchy. For example:
Expand|Select|Wrap|Line Numbers
  1. self.Bind(wx.EVT_BUTTON, self.OnButton1, self.button)
  2. self.button.Bind(wx.EVT_BUTTON, self.OnButton2)
Given that code, if OnButton2 does not call event.Skip(), then OnButton1 will NEVER be called.

Apparently, the iehtmlWindow must be the highest point on the hierarchy, and is not calling event.Skip(). That is not surprising, considering that it is an activex control of Microsoft IE. Because why would Microsoft think that anybody using their program with an activex control would want to filter events [said with sarcasm ;)]?

The only thing that I can think of right now is something that I have suggested before. That would be to put a clear gif image in front of the iehtmlWindow, and relay click events that I approve of. I don't know how to do this, and anything easier would be great.
Jan 21 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

20
2182
by: dukeleto | last post by:
I know this is an annoying thing on some sites. I have set some images in an online gallery to have their own java po up window that is set to be the same size as the image. I would like to set ONLY the pop up window so it does not allow th user to right click. Now I did a search, and found some options, but when you right click it gives the user an annoying pop up saying stuff like "you cant d
7
6207
by: Robert | last post by:
Can I programmatically disable the right click context menu?
1
3012
by: Todd7 | last post by:
I am writing a python program to load a pdf file into an IEHtmlWindow which displays it through adobe acrobat reader 7. Depending on the buttons the user clicks, the program moves it to another subdirectory with a new name. I am using python 2.4 with wxpython 2.6 on a windowsxp machine. I encounter a permission denied error when trying to move the file. It appears to be caused due to the loading of the pdf file into the IEHtmlWindow....
12
2284
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer. Select the TextEditor->Html->Validation tree option in the left-hand side of the
6
1838
by: emmajoh | last post by:
Hi I'm trying to disable IE contextmenu (on a right click) as I want to create my own. The problem is that since I've installed the latest version of the google desktop, the script doesn't work. No other script I found on the Internet is working anymore. As you can see below, I've tried to catch every event I'm aware of: ___________________________
0
1007
by: gjzusenet | last post by:
Hi I've been using an IEHtmlWindow in my script with no problems, but it seems that for people with a clean installation of XP SP2 it fails like such: Traceback (most recent call last): File "htmlloader.py", line 509, in load File "PythonCard\model.pyo", line 340, in __init__ File "PythonCard\resource.pyo", line 86, in __init__
1
2819
by: kebabkongen | last post by:
Hi, I'm working on a JavaScript that is enabling / disabling a select element according to whether a checkbox is selected or not. This works fine in Firefox, but in Internet Explorer (v 6.0.2900) it appears wierd: When I disable the selevt element in IE, it continues to appear as enabled (falsely) until I try changing it. When I click on it, updates itself as grey as to indicate that it is disabled.
5
1962
by: hp_1981 | last post by:
Hi Is there anyway avoiding users to save my web pages? this idea came to my mind when I tried to save a web page, but in the middle of saving progress something like the following error occurred: "unable to save the page...". on the other hand, once, I saved a web page successfully, but when I opened it the characters were completely unreadable. unfortunately I can't remember the url now but if you know any way to restrict users,
1
1857
by: Farsheed Ashouri | last post by:
Hi everyone. I create a little browser with wxpython and IEHtmlWindow. But I have a little problem here. When I press enter in the html page, The focus goes to another panel. Why this happens? I want to load a html page and it have textares and user should able to press enter inside html page. This is the code for creating it: #===================Code Begin ==========================
0
9901
marktang
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...
0
11024
Oralloy
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...
0
10679
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10756
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,...
0
9513
agi2029
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...
0
5941
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4560
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
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3186
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.