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.
12 4239 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() - #Boa:Frame:Frame1
-
-
import wx
-
import wx.html
-
-
def create(parent):
-
return Frame1(parent)
-
-
[wxID_FRAME1, wxID_FRAME1HTMLWINDOW1,
-
] = [wx.NewId() for _init_ctrls in range(2)]
-
-
class Frame1(wx.Frame):
-
def _init_ctrls(self, prnt):
-
# generated method, don't edit
-
wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt, pos=wx.Point(431, 243),
-
size=wx.Size(400, 250), style=wx.DEFAULT_FRAME_STYLE, title='Frame1')
-
self.SetClientSize(wx.Size(392, 223))
-
-
self.htmlWindow1 = wx.html.HtmlWindow(id=wxID_FRAME1HTMLWINDOW1, name='htmlWindow1',
-
parent=self, pos=wx.Point(88, 72), size=wx.Size(200, 100),
-
style=wx.html.HW_SCROLLBAR_AUTO)
-
self.htmlWindow1.Bind(wx.EVT_LEFT_DOWN, self.OnHtmlWindow1LeftDown)
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
-
def OnHtmlWindow1LeftDown(self, event):
-
pass # this is here for demonstration ONLY.
-
#if IWantThisEvent:
-
#event.Skip()
-
#else:
-
#pass # to block an event, simply don't call event.Skip()
-
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: - import os
-
from PythonCard import model #don't worry about some of these: some are
-
import wx #used in other parts of the program
-
import thread
-
from time import sleep
-
-
class window(model.Background):
-
-
def on_initialize(self, event):
-
self.components.htmlDisplay.Bind(wx.EVT_LEFT_DOWN,
-
self.on_htmlDisplay_leftDown) #bartonc's line modified
-
-
def on_htmlDisplay_leftDown(self, event): #bartonc's function
-
if IWantThisEvent:
-
event.Skip()
-
else:
-
DoWhatever
-
I haven't tested it yet, but it will probably work with these minor modifications.
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?
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.
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.
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.
Okay, now I've gotten the chance to try to bind the window to an arbitrary function, and nothing happens: - import os
-
from PythonCard import model #don't worry about some of these: some are
-
import wx #used in other parts of the program
-
import thread
-
from time import sleep
-
-
class window(model.Background):
-
-
def on_initialize(self, event):
-
self.Bind(wx.EVT_LEFT_DOWN,
-
self.on_htmlDisplay_leftDown)
-
-
def on_htmlDisplay_leftDown(self, event):
-
print "leftDown event"
-
event.skip()
-
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!
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: - import os
-
from PythonCard import model #don't worry about some of these: some are
-
import wx #used in other parts of the program
-
import thread
-
from time import sleep
-
-
class window(model.Background):
-
-
def on_initialize(self, event):
-
self.Bind(wx.EVT_LEFT_DOWN,
-
self.on_htmlDisplay_leftDown)
-
-
def on_htmlDisplay_leftDown(self, event):
-
print "leftDown event"
-
event.skip()
-
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.
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: - self.Bind(wx.EVT_BUTTON, self.OnButton1, self.button)
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
by: Robert |
last post by:
Can I programmatically disable the right click context menu?
|
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....
|
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
|
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:
___________________________
| |
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__
|
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.
|
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,
|
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 ==========================
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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...
| |
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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: 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...
| |