mikorians
Posts: 33
Joined: Sun Dec 07, 2014 3:43 am

Startx python script - no mouse [SOLVED]

Thu Feb 04, 2016 11:27 am

I'm a noob.
Using RPI B+, Wheezy.
No normal problems with mouse.
I can start LDE with startx, no mouse or other problems. I have my pi configured to start at command line prompt.
I'm trying to conserve resources by only having 1 window application.
So...
I type: startx /....python /.....myapp.py
(Exact default paths - I forget)
And I am presented with my program. Yay. there's a white borderline around the edge of the screen.
But no pointer, no function (tried blindly, clicking around). I have no key bindings yet, so keyboard unknown.
It runs just fine if I just type startx and then click up python and run my script. But I don't think I need the whole GUI, do I?

So there must be a startx flag or a script thingy I need to know?
Can anyone assist me?
Last edited by mikorians on Sat Mar 05, 2016 7:20 pm, edited 1 time in total.

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: Startx python script - no mouse

Mon Feb 08, 2016 12:25 pm

That should work. What UI library are you using in your Python program (PyGame, tkinter, something else)?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

mikorians
Posts: 33
Joined: Sun Dec 07, 2014 3:43 am

Re: Startx python script - no mouse

Mon Feb 08, 2016 10:44 pm

Just plain tkinter and python 2.
My program doesn't make any direct mouse references yet, just creates widgets and the window.
I can't understand why no mouse at all. I should add a key binding so I can quit, but I think ctrl-c got me out... And also ctrl-alt-f1 (new command line)

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: Startx python script - no mouse

Tue Feb 09, 2016 1:33 pm

No experience myself but I have read people running for example Chromium browser in 'kiosk mode' as the only X application. Maybe tkinter does not play well with the window manager (that should provide the mouse as far as I understand).
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

hihiuztrewq
Posts: 1
Joined: Mon Feb 29, 2016 6:15 pm

Re: Startx python script - no mouse

Mon Feb 29, 2016 6:16 pm

Hey, did you find a solution?

mikorians
Posts: 33
Joined: Sun Dec 07, 2014 3:43 am

Re: Startx python script - no mouse

Tue Mar 01, 2016 5:06 am

Nope.
But I can only say it's a standard tkinter window with a canvas.
I'd originally installed Raspian with the GUI on, I wanted to reduce overhead so I somehow (with help I'd read here) got the automatic startx turned off and set it to autolog me in and drop to the prompt successfully. It puts a delay and a notice in my boot, but works. I noted a white line at the edge of the screen when I invoke my python script, if any of this helps.

mikorians
Posts: 33
Joined: Sun Dec 07, 2014 3:43 am

Re: Startx python script - no mouse [SOLVED]

Sat Mar 05, 2016 7:31 pm

Hey! Presto! I got lucky!

1. I plugged in another mouse. Invisible mouse clicks started working!

2. I read about making the pointer invisible in python.

Wound up with the answer by permutation and recombination.

Turns out tkinter lets you make your mouse invisible on a PER WIDGET basis. I had a whole window canvas - triple trouble!

Under my window init code I had to use:
self.master.config(cursor = 'none')
self.master.show = False
self.master.update_idletasks()
self.master.config(cursor = '')
self.master.show = True
self.master.update_idletasks()

Then, under my widget creator for my canvas I put:
self.canvas.config(cursor = '')

AND there was a big X pointer!

I hope this odd bit of research helps the whole community!

mikorians
Posts: 33
Joined: Sun Dec 07, 2014 3:43 am

Re: Startx python script - no mouse [SOLVED]

Sat Mar 05, 2016 7:35 pm

OH YEAH,
I'd also done this:
cd /usr/share/icons
mv Adwaita Adwaita_mine

And the ugly white line at the edge of the screen?

Under my tkinter window creation:
self.place(x=-1, y=0, width=641, height=400)
self.createWidgets()... Etc.

Return to “Python”