Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 859723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:43:00+00:00 2026-05-15T08:43:00+00:00

I’m trying to display a QLabel (without parent) at a fixed position using PyQt.

  • 0

I’m trying to display a QLabel (without parent) at a fixed position using PyQt. The QLabel functions as a graphic that appears only for a moment, it’s appears in the middle of the screen by default but I can’t find how to move its position.

Any suggestion??

updated:

This is my code, maybe is a problem in the way I’m doing this:

from PyQt4.QtCore import Qt,QTimer
from PyQt4.QtGui import QLabel,QPixmap,QApplication

import os
import subprocess

class BrightnessControl(QLabel):


    def __init__(self,parent=None):

        self.__command__ = "nvclock -S%s"
        self.__imgPath__ = "../../../../ui/alfredozn_vaio/brightness/img/"
        self.__image__ = QPixmap()

        super(BrightnessControl,self).__init__(parent,Qt.SplashScreen)
        #self.loadImg(100)


    def comman(self):
        return self.__command__

    def image(self):
        return self.__image__

    def imgPath(self):
        return self.__imgPath__

    def currentValue(self):
        '''
        Obtenemos el valor actual del smartdimmer
        '''
        res=subprocess.Popen(["smartdimmer","-g"],stdout=subprocess.PIPE)
        return int(res.stdout.readline().split()[-1])

    def loadImg(self,value):
        '''
        Aquí asumimos que el único medio de control será la aplicación, por lo que los valores se moverán en múltiplos de 10 
        '''
        os.system(self.comman() % str(value))
        self.image().load("%s%i.png" % (self.imgPath(),value))
        self.setPixmap(self.image())
        self.setMask(self.image().mask())
        self.update()


if __name__ == "__main__":

    import sys

    app = QApplication(sys.argv)
    try:
        if len(sys.argv) < 2 :
            raise ValueError 
        else:
            val=10
            if sys.argv[1] == "down":
                val*=-1
            elif sys.argv[1] != "up":
                raise ValueError

            form = BrightnessControl()
            val += form.currentValue()
            val = 20 if val < 20 else 100 if val > 100 else val 
            form.loadImg(val)

            #This move function is not working
            form.move(100,100)

            form.show()
            QTimer.singleShot(3000,app.quit)
            app.exec_()
    except ValueError:
        print "Modo de uso: SonyBrightnessControl [up|down]"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:43:00+00:00Added an answer on May 15, 2026 at 8:43 am

    You can use pos property or you can move it calling move() into the label. But it doesn’t always work well. The best method from my experience is to use label.setGeometry() function.

    If you want it in the middle of the screen the code should be like this (Is c++ code, I dont know python sorry):

    label.setGeometry((this->width() - label.sizeHint().width()) / 2), (this->height() - label.sizeHint().height()) / 2, label.sizeHint().width(), label.sizeHint().height());
    

    If you do this into the resizeEvent of the parent you will have it always in the center of it.

    You can also optimize the code saving the sizeHint into a variable to not call it several times.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 475k
  • Answers 475k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer At a glance, your code looks like it's doing a… May 16, 2026 at 4:29 am
  • Editorial Team
    Editorial Team added an answer If you already have a sorted list, which is sorted… May 16, 2026 at 4:29 am
  • Editorial Team
    Editorial Team added an answer Taking Gilbert's advice into account, I decided to create my… May 16, 2026 at 4:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.