P
P
PRoGRamm_InG2021-08-28 16:46:32
PyQt
PRoGRamm_InG, 2021-08-28 16:46:32

How to change font size according to its size and PyQt5 label size?

How to resize text according to its size and PyQt5 label's size?

If the font size is too large, then it often goes beyond the label. In my project, the text changes to unknown to me, so I need to somehow automate the change in font size in accordance with its size and the size of the label.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
F
friday, 2014-07-11
@JIakki

Each time the function is called, a new variable is declared and a new interval is created. The interval stops, but not the one that was created during the previous call, but a new one.

var snake = { 
     interval : {
    right : function (start){
      if( start == "stop"){
        clearInterval(this.inter);
      } else {
        this.inter = setInterval(function(){}, 500)
      }
    }
  }
};

snake.interval.right();
snake.interval.right("stop");

In this case, the interval id will be in snake.interval.inter, and calling with "stop" will stop it.

L
Lorem Ipsum, 2014-07-11
@nobodynoone

Because when you handle the 'stop' parameter, you still start an infinite loop and naturally the script does not reach the check for start=='stop'.
You need to create a generic element and 2 functions for start and stop. For more details and even with examples on the stack, follow this link .

A
Alex Kheben, 2014-07-11
@zBit

Are there any errors in the console?

S
Sergey Melnikov, 2014-07-11
@mlnkv

var snake = { 
  interval : {
    interval_id: null,
    right : function (stop){
      if (stop) {
        return clearInterval(this.interval_id);
      }
      if (this.interval_id) {
        clearInterval(this.interval_id);
      }
      this.interval_id = setInterval(snake.functions.moveRight, 500);
    }
  }
}
snake.interval.right();
snake.interval.right(true);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question