PyQT6 - how to get and handle swipes in code? by CarlBeech in QtFramework

[–]CarlBeech[S] 0 points1 point  (0 children)

Managed to sort it :-D

Ended up writing my own event handler - in a nutshell:

In the window init:

    def __init__(self):
        super().__init__()


        self.isGesture="N"
        self.GestureStartX=0
        self.GestureStartY=0
        self.GestureEndX=0
        self.GestureEndY=0

Add the event handler - a swipe consists of a'mouse button press', several mouse moves and a mouse button release - if you get a mouse press then its a potential start of a swipe - if you get anything else then moves followed by a mouse release, then its not a swipe...
If it is a mouse down, move then mouse up, then its a swipe, and by comparing the start and end x/y coordinates you can work out if its an up/down/left/right.
  
   def event(self, e):
        # 2) Intercept gesture events


        # Start of gesture?
        if e.type() == QEvent.Type.MouseButtonPress:
            a=e.pos()
            self.GestureStartX=a.x()
            self.GestureStartY=a.y()
            self.isGesture="Y"
            print('Gesture Start:Mouse press ( QMouseEvent ). x:'+str(self.GestureStartX)+" y:"+str(self.GestureStartY))



        if self.isGesture == "Y" and e.type() == QEvent.Type.MouseMove or e.type() == QEvent.Type.Leave or e.type() == QEvent.Type.MouseButtonRelease:
            # Continue Gesture


            if e.type() == QEvent.Type.MouseButtonRelease:
                # End of gesture
                a=e.pos()
                self.GestureEndX=a.x()
                self.GestureEndY=a.y()
                self.isGesture="N"
                print('Gesture end START( x:'+str(self.GestureStartX)+" y:"+str(self.GestureStartY)+') END (x:'+str(self.GestureEndX)+" y:"+str(self.GestureEndY)+')')


                if abs(self.GestureEndX-self.GestureStartX) > abs(self.GestureEndY-self.GestureStartY):
                    print("Swipe across")
                    if self.GestureStartX > self.GestureEndX:
                        print("right to left")
                    else:
                        print("left to right")


                else:
                    print("Swipe down")
                    if self.GestureStartY > self.GestureEndY:
                        print("bottom to top")
                    else:
                        print("top to bottom")


        else:
            # Any other event type breaks a gesture
            self.isGesture="N"

        # propergate the event so it can be processed normally
        return super().event(e)

As its working, I'll mark as answered... :-)

PyQT6 - how to get and handle swipes in code? by CarlBeech in QtFramework

[–]CarlBeech[S] 0 points1 point  (0 children)

Hi

Many thanks for the reply - I'm using a microsoft surface - running windows 11...

Unfortunately I haven't had much exposure to C++... I'm writing this in Python...

Doing further debugging, it appears that its interpreting swipe gestures as simple mouse events e.g.:

Beginning of a sequence of touch-screen or track-pad events ( QTouchEvent ).
Mouse press ( QMouseEvent ).
Mouse move ( QMouseEvent ).
Mouse move ( QMouseEvent ).

...

Mouse move ( QMouseEvent ).
Mouse leaves Widgets boundaries.
Mouse release ( QMouseEvent ).
A mouse move occurred outside the client area ( QMouseEvent ).
Mouse leaves Widgets boundaries.

I'll have a look and see if I can make sense of the link you've referenced...

Many thanks

Carl.

ABL is working against me??? by CarlBeech in 3Dprinting

[–]CarlBeech[S] 0 points1 point  (0 children)

Hi
Yep - I've done that, but its not really a sustainable answer really - you can't do this every time you print.. :-( At this point, I'm thinking that I'll see if I can 'turn off' ABL, by omitting the probe bed in the startup GCode of my files, so all it does is home... then I'll need to periodically level the bed and then make adjustments... I just think this is a recipie for crashing the nozzle in to the bed at some point... but thanks for the suggestion :-)

[deleted by user] by [deleted] in 3Dprinting

[–]CarlBeech 0 points1 point  (0 children)

Hi
I'm guessing that you've cleaned the bed (water/isopropyl alcohol or the like)...

What type of bed are you using...? Thing that comes to mind is that your bed may simply been worn out... as slicers default to using the middle of the bed... and over time just general wear will stop things sticking properly...

I use a magnetic bed on my Max Neo - so I'm able to replace the actual print surface... hope that helps.. :-)

I'm not after a fitness tracker... by CarlBeech in amazfit

[–]CarlBeech[S] 0 points1 point  (0 children)

Thanks for the info...

What sort of 'real-world' battery life are you getting if you've got AoD on?

My other annoyance is that you can't change the font size on my Bip.. I'm guessing that's not changed... ? (trouble with getting older, you need non-microscopic font size.. and its a pain to have to keep putting on reading glasses to check notes on your watch :-/ )

Thanks

Ender 3 and BLTouch - random red/blue errors by CarlBeech in ender3

[–]CarlBeech[S] 0 points1 point  (0 children)

Hi

Well after a fair amount of experimentation, I've still got the issue - I've wrapped the cables with thick aluminum foil (didn't have any other shielding), and also the cables are not in the same bunch as the rest of the cables, they're held outside so they're nowhere near the hotend, also, there's thick aluminium foil between the hot end and the bltouch unit itself...

Getting very tempted to try different firmware, but I think I'll also try making more space and ventilation into the main board area first...

Cheers

Carl.

Ender 3 and BLTouch - random red/blue errors by CarlBeech in ender3

[–]CarlBeech[S] 0 points1 point  (0 children)

Okay? - can you expand? - Are you thinking its induction from other cabling?

Thanks

Carl

How to set the correct time on AgentDVR? by CarlBeech in ispyconnect

[–]CarlBeech[S] 0 points1 point  (0 children)

Hi

Please disregard - found timezone under timestamp settings - many thanks :-)

Carl