"Hans-Peter Jansen" <hpj at urpla.net> wrote in message
news:200909010902.06605.hpj at urpla.net...
> Am Dienstag, 1. September 2009 schrieb Grant Tang:
>> Hi,
>> We have an software EMAN2 which choose PyQt4 to implement the GUI
>> interface. Which works fine until recently I upgrade my PyQt4 to 4.5.4.
>> After the upgrading, I lose response to all mouse event, including mouse
>> clicking on a 2D/3D image and mouse wheel (I use wheel to zoom in or out
>> of image). I tried PyQt4 4.5.2, still no response for all mouse event.
>> The mouse works perfectly fine for PyQt4 4.4.4. I doubt all 4.5 versions
>> will not work. Could somebody help?
>>>> I post some pieces of code for my mouse wheel event, hope it help:
>> class Main2DWindowEventHandler(BoxEventsHandler):
>> def __connect_Signals_to_slots(self):
>> QtCore.QObject.connect(self.main_2d_window.emitter(),
>> QtCore.SIGNAL('mousewheel'), self.mouse_wheel())
> ^^
> This looks wrong: calling the function, instead of leaving a reference,
> while mouse_wheel() does not look like returning any callable.
>>>> class EMImage2DEmitMouseMode(EMImage2DMouseEvents):
>> def mouse_wheel(self, event):
>> seld.mediator.emit(QtCore.SIGNAL('mousewheel'), event)
> ^^^^
> self?
>>>>> #actual slot function
>> class EMImage2DModule(EMGUIModule):
>> def weelEvent(self, event):
> ^^^^^^^^^
> wheelEvent?
>>> #blah, blah
>> I tried to print out message in this slot function. It prints out in
>> PyQt4.4.4 but nothing got printed in PyQt4.5.*.
>>>> Since it works fine with PyQt4 4.4.4 and previous versions. I doubt
>> something new in 4.5.* make it not work.
>> If PyQt 4.5 events wouldn't work, guess how many complaints would arrive?
> This is all so basic, that I doubt, the problem is in PyQt.
>> Please provide a minimum self-containing example of your issue.
>> Pete
Sorry for the typos. We found out the error source and fixed it. But I still
need help to understand why.
We have this class defined:
#code 1, works in PyQt4.4.4. mouse event no reponse in PyQt 4.5.4
class EMImage2DWidget(QtOpenGL.QGLWidget, EMEventRerouter):
After we swiched the order of the inheritance, mouse works in PyQt.4.5.4:
#code 2, works fine in PyQt 4.5.4
class EMImage2DWidget(EMEventRerouter, QtOpenGL.QGLWidget):
The __init__ function for class EMImage2DWidget:
-------------------------------------------------------------------------------------------------
class EMImage2DWidget(QtOpenGL.QGLWidget,EMEventRerouter):
def __init__(self, em_image_2d_module):
fmt=QtOpenGL.QGLFormat()
fmt.setDoubleBuffer(True)
#fmt.setSampleBuffers(True)
fmt.setDepth(1)
QtOpenGL.QGLWidget.__init__(self,fmt)
EMEventRerouter.__init__(self,em_image_2d_module) # makes self.target
self.initimageflag = True
self.setFocusPolicy(Qt.StrongFocus)
self.setMouseTracking(True)
-------------------------------------------------------------------------------------------------
The code for EMEventRerouter:
-------------------------------------------------------------------------------------------------
class EMEventRerouter:
def __init__(self,target=None):
if target != None:
self.target = weakref.ref(target)
self.orig_target = weakref.ref(target)
else:
self.target = None
self.orig_target = None
self.selected_object = None
self.multi_selected_objects = [] # as grown using "ctrl-click"
selection, for event master slave relationships
def lock_target(self,target):
self.target = target
def unlock_target(self):
self.target = self.orig_target # will this work in the weak ref approach
???
def set_target(self,target):
self.target = weakref.ref(target)
self.orig_target = weakref.ref(target)
# self.target = target
# self.orig_target = target
def mousePressEvent(self, event):
if self.target != None: self.target().mousePressEvent(event)
def wheelEvent(self,event):
if self.target != None: self.target().wheelEvent(event)
def mouseMoveEvent(self,event):
if self.target != None: self.target().mouseMoveEvent(event)
def mouseReleaseEvent(self,event):
if self.target != None: self.target().mouseReleaseEvent(event)
def mouseDoubleClickEvent(self,event):
if self.target != None: self.target().mouseDoubleClickEvent(event)
def keyPressEvent(self,event):
if self.target != None: self.target().keyPressEvent(event)
def dropEvent(self,event):
if self.target != None: self.target().dropEvent(event)
def closeEvent(self,event) :
if self.target != None: self.target().closeEvent(event)
def dragEnterEvent(self,event):
if self.target != None: self.target().dragEnterEvent(event)
def keyPressEvent(self,event):
if self.target != None: self.target().keyPressEvent(event)
def leaveEvent(self,event):
try:
if self.target != None: self.target().leaveEvent(event)
except: print "leave failed"
def get_core_object(self):
if self.target == None: return None
else: return self.target()
def get_target(self):
if self.target == None: return None
else: return self.target() # use this one instead of the above
-------------------------------------------------------------------------------------------------
We use EMEventRerouter to handle all mouse and keyboard event.
The situation is code1 works for PyQt 4.4.4. We have to change to code2 to
make mouse event works. In the ___init__ function, the
self.setMouseTracking(True) or self.setMouseTracking(False) doesn't matter
in PyQt 4.5.4.
Can sombody explain this to me?
Thanks.
Grant
More information about the PyQt
mailing list
‘She has never mentioned her father to me. Was he—well, the sort of man whom the County Club would not have blackballed?’ "We walked by the side of our teams or behind the wagons, we slept on the ground at night, we did our own cooking, we washed our knives by sticking them into the ground rapidly a few times, and we washed our plates with sand and wisps of grass. When we stopped, we arranged our wagons in a circle, and thus formed a 'corral,' or yard, where we drove our oxen to yoke them up. And the corral was often very useful as a fort, or camp, for defending ourselves against the Indians. Do you see that little hollow down there?" he asked, pointing to a depression in the ground a short distance to the right of the train. "Well, in that hollow our wagon-train was kept three days and nights by the Indians. Three days and nights they stayed around, and made several attacks. Two of our men were killed and three were wounded by their arrows, and others had narrow escapes. One arrow hit me on the throat, but I was saved by the knot of my neckerchief, and the point only tore the skin a little. Since that time I have always had a fondness for large neckties. I don't know how many of the Indians we killed, as they carried off their dead and wounded, to save them from being scalped. Next to getting the scalps of their enemies, the most important thing with the Indians is to save their own. We had several fights during our journey, but that one was the worst. Once a little party of us were surrounded in a small 'wallow,' and had a tough time to defend ourselves successfully. Luckily for us, the Indians had no fire-arms then, and their bows and arrows were no match for our rifles. Nowadays they are well armed, but there are[Pg 41] not so many of them, and they are not inclined to trouble the railway trains. They used to do a great deal of mischief in the old times, and many a poor fellow has been killed by them." As dusk came on nearly the whole population of Maastricht, with all their temporary guests, formed an endless procession and went to invoke God's mercy by the Virgin Mary's intercession. They went to Our Lady's Church, in which stands the miraculous statue of Sancta Maria Stella Maris. The procession filled all the principal streets and squares of the town. I took my stand at the corner of the Vrijthof, where all marched past me, men, women, and children, all praying aloud, with loud voices beseeching: "Our Lady, Star of the Sea, pray for us ... pray for us ... pray for us ...!" It had not occurred to her for some hours after Mrs. Campbell had told her of Landor's death that she was free now to give herself to Cairness. She had gasped, indeed, when she did remember it, and had put the thought away, angrily and self-reproachfully. But it returned now, and she felt that she might cling to it. She had been grateful, and she had been faithful, too.[Pg 286] She remembered only that Landor had been kind to her, and forgot that for the last two years she had borne with much harsh coldness, and with a sort of contempt which she felt in her unanalyzing mind to have been entirely unmerited. Gradually she raised herself until she sat quite erect by the side of the mound, the old exultation of her half-wild girlhood shining in her face as she planned the future, which only a few minutes before had seemed so hopeless. After he had gloated over Sergeant Ramsey, Shorty got his men into the road ready to start. Si placed himself in front of the squad and deliberately loaded his musket in their sight. Shorty took his place in the rear, and gave out: The groups about each gun thinned out, as the shrieking fragments of shell mowed down man after man, but the rapidity of the fire did not slacken in the least. One of the Lieutenants turned and motioned with his saber to the riders seated on their horses in the line of limbers under the cover of the slope. One rider sprang from each team and ran up to take the place of men who had fallen. "As long as there's men and women in the world, the men 'ull be top and the women bottom." Then, in the house, the little girls were useful. Mrs. Backfield was not so energetic as she used to be. She had never been a robust woman, and though her husband's care had kept her well and strong, her frame was not equal to Reuben's demands; after fourteen years' hard labour, she suffered from rheumatism, which though seldom acute, was inclined to make her stiff and slow. It was here that Caro and Tilly came in, and Reuben began to appreciate his girls. After all, girls were needed in a house—and as for young men and marriage, their father could easily see that such follies did not spoil their usefulness or take them from him. Caro and Tilly helped their grandmother in all sorts of ways—they dusted, they watched pots, they shelled peas and peeled potatoes, they darned house-linen, they could even make a bed between them. HoME一级毛片视频免费公开
ENTER NUMBET 0018www.yaodaojia360.com.cn www.caifeiyu.net.cn www.b017.com.cn dzledu.com.cn fxqj269.com.cn jdcg.net.cn knva.com.cn hadxsw.com.cn tqdv.com.cn zyongjia.com.cn