Something Wrong while I am doing PyQt5 GUI programming

inxi -Fxxz
System:
  Kernel: 5.11.6-zen1-1-zen x86_64 bits: 64 compiler: gcc v: 10.2.1 
  Desktop: GNOME 3.38.3 tk: GTK 3.24.27 wm: gnome-shell dm: GDM Distro: Garuda Linux 
Machine:
  Type: Laptop System: Acer product: TravelMate P243 v: V1.06 serial: <filter> 
  Mobo: Acer model: BA40_HC v: Type2 - Board Version serial: <filter> 
  UEFI [Legacy]: Insyde v: 1.06 date: 08/09/2012 
Battery:
  ID-1: BAT1 charge: N/A condition: N/A volts: 7.8/11.1 model: SANYO AS10D31 
  serial: <filter> status: Unknown 
CPU:
  Info: Dual Core model: Intel Core i3-3110M bits: 64 type: MT MCP arch: Ivy Bridge 
  rev: 9 L2 cache: 3 MiB 
  flags: avx lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 19156 
  Speed: 2311 MHz min/max: 1200/2400 MHz Core speeds (MHz): 1: 2311 2: 2091 3: 2029 
  4: 2026 
Graphics:
  Device-1: Intel 3rd Gen Core processor Graphics vendor: Acer Incorporated ALI 
  driver: i915 v: kernel bus ID: 00:02.0 chip ID: 8086:0166 
  Display: wayland server: X.Org 1.21.0.99 compositor: gnome-shell driver: 
  loaded: intel unloaded: modesetting alternate: fbdev,vesa resolution: 1366x768~60Hz 
  s-dpi: 96 
  OpenGL: renderer: Mesa DRI Intel HD Graphics 4000 (IVB GT2) v: 4.2 Mesa 20.3.4 
  compat-v: 3.0 direct render: Yes 
Audio:
  Device-1: Intel 7 Series/C216 Family High Definition Audio 
  vendor: Acer Incorporated ALI driver: snd_hda_intel v: kernel bus ID: 00:1b.0 
  chip ID: 8086:1e20 
  Sound Server: ALSA v: k5.11.6-zen1-1-zen 
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
  vendor: Acer Incorporated ALI driver: r8169 v: kernel port: 2000 bus ID: 04:00.2 
  chip ID: 10ec:8168 
  IF: enp4s0f2 state: down mac: <filter> 
  Device-2: Broadcom BCM43228 802.11a/b/g/n vendor: Foxconn driver: wl v: kernel 
  port: 2000 bus ID: 09:00.0 chip ID: 14e4:4359 
  IF: wlp9s0 state: up mac: <filter> 
Drives:
  Local Storage: total: 465.76 GiB used: 46.23 GiB (9.9%) 
  ID-1: /dev/sda vendor: Western Digital model: WD5000BPVT-22A1YT0 size: 465.76 GiB 
  speed: 3.0 Gb/s serial: <filter> 
Partition:
  ID-1: / size: 465.76 GiB used: 46.23 GiB (9.9%) fs: btrfs dev: /dev/sda1 
  ID-2: /home size: 465.76 GiB used: 46.23 GiB (9.9%) fs: btrfs dev: /dev/sda1 
  ID-3: /var/log size: 465.76 GiB used: 46.23 GiB (9.9%) fs: btrfs dev: /dev/sda1 
  ID-4: /var/tmp size: 465.76 GiB used: 46.23 GiB (9.9%) fs: btrfs dev: /dev/sda1 
Swap:
  ID-1: swap-1 type: zram size: 2.39 GiB used: 256 KiB (0.0%) priority: 32767 
  dev: /dev/zram0 
  ID-2: swap-2 type: zram size: 2.39 GiB used: 256 KiB (0.0%) priority: 32767 
  dev: /dev/zram1 
  ID-3: swap-3 type: zram size: 2.39 GiB used: 256 KiB (0.0%) priority: 32767 
  dev: /dev/zram2 
  ID-4: swap-4 type: zram size: 2.39 GiB used: 256 KiB (0.0%) priority: 32767 
  dev: /dev/zram3 
Sensors:
  System Temperatures: cpu: 69.0 C mobo: N/A 
  Fan Speeds (RPM): N/A 
Info:
  Processes: 247 Uptime: 1h 50m Memory: 9.57 GiB used: 4.11 GiB (42.9%) Init: systemd 
  v: 247 Compilers: gcc: 10.2.0 clang: 11.1.0 Packages: pacman: 1318 Shell: fish 
  v: 3.1.2 running in: gnome-terminal inxi: 3.3.0

Here is my python coding for generating simple window.

import sys
from PyQt5.QtWidgets import *


class Window(QWidget):

    def __init__(self):
        super().__init__()
        self.setGeometry(1000, 100, 300, 400)
        self.setWindowTitle('Main Window.')

        self.show()


App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec_())

Here , in self.setGeometry function, (1000, 100) represent window position on desktop and (300, 400) represent window size. So, my problem is the window size (300, 400) gives result properly. But window position co - ordinate (1000, 100) is no affecting the position of window.

The two screenshots illustrating my words given below:
1.


2.The position is same but size is different. Even I changed (1000, 100) to (1,1)

I think, may be OS parameters overriding the window position parameter of my program.!!!!!

Well, I modified code a bit to move the main window. Here is modified code:

import sys
from PyQt5.QtWidgets import *
import time


class Window(QWidget):

    def __init__(self):
        super().__init__()
        x,y=1000,100
        for i in range(5,100):
            x=10*i
            y=3*i
            self.setGeometry(x, y, 300, 400)
            self.setWindowTitle('Main Window.')
            time.sleep(0.025)

            self.show()
        print("Done")
        time.sleep(2)
        exit()

App = QApplication(sys.argv)
window = Window()
sys.exit(App.exec_())

And it is working perfectly fine at my PC.
(Yeah, I know a bit of Python stuff too)
:wink:

5 Likes

Thanks, Naman for reply. I removed GNOME and will install dragonized edition alongside with ubuntu, And I will check this code once again in dragonized, and then only I can find if modified code will work again or not.

and btw, I am very lucky to get answer on python as one of mods knows some python stuff.

2 Likes

Ok, Naman your code and my code is working fine in KDE dragonized. But in GNOME it was not working.

Let me boot into GNOME

2 Likes

It is working for me in Gnome(live medium)
I managed to quickly capture 2 screenshots while it was moving in my code.

3 Likes

You can see in my photo window is not moving then, It was then probably my side of problem !!!!!!!!!! Don't know bhai. Sorry, but meine tumhara time waste kiya. Extremely sorry.

1 Like

No problem, but I would still suggest you to try in live medium and report.

2 Likes

ok, I will try code in live medium and check whether its running or not.

1 Like

ok, its working perfectly in GNOME live session.


2 Likes

Conclusion:

You did something wrong with your installation, install again and have fun
:grin:

3 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.