1

I write a program in python3.6 under PyCharm in Ubuntu 18.04 I want to pop up a jpg-file on specific window-coordinates. The only possible way to do this seems to be usage of eog and wmctrl.

I did not find an imageviewer, who is able to position the jpg-file exatly where i want (not eog, qiv, ..or others, they miss these options)

So I use eog filename.jpg to pop ist up. Then the wmctrl-command to place it on the screen

Doing on console in unix(Ubuntu):

eog filename.jpg --> eog pops it up centered.

wmctrl -a filename.jpg -e 0,10,0,600,2000 --> places it, where I want

(It doesn't matter from which directory I call eog, it also can be with directory /home/user/......(filename.jpg). For wmctrl in each case only filename.jpg is sufficent. (Also "wmctrl -r filename....... works)

Doing the same from Pythone-console, it works perfectly, too.

But: when I do the some from programcode with

cmd = "eog filename.jpg"

os.system(cmd) (or os.system("cmd"), pop-up of the file centered on the screen works

BUT:

cmd = "wmctrl -a filename.jpg -e 0,10,0,600,2000"

os.systems(cmd) -------> nothing happens, as if the os.system() command is ignored

Any idea, what could be wrong is appreciated !

(I first thought, I run into problems with filename and specific characters, but it also happens with simple names like test.jpg or so.)

on Python-console i also use cmd =........... and os.system(cmd) after "import os"

d_kennetz
  • 5,219
  • 5
  • 21
  • 44
user3367867
  • 565
  • 1
  • 7
  • 19

1 Answers1

0

Sorry: I solved it by myself.

It only needs a pause before the wmctrl-command is fired !

import time

time.sleep(2) does the job (may be, 1 second also is enough)

(doing it on the console, through typing you get the pause automatically)

user3367867
  • 565
  • 1
  • 7
  • 19
  • You need to indent your code when you post so that it is more readable to others. Also, blocks of relevant code shouldn't be intermingled with text. – d_kennetz Jan 03 '19 at 23:14