Unsolved Displaying real-time data on a 2nd window
-
@john_hobbyist
Fundamental Python. Nothing special aboutinitUI(self)
.- From within
class Two
:self.do_something(checked)
. - From outside
class Two
:class_two_instance.do_something(checked)
.
- From within
-
This post is deleted! -
In order to start from somewhere, after your very useful comments I did a change in the code so that when the ct changes to call the method def onChanged(self, text) which prints "OK". However, this happens only the first time that ct changes value. All the next times it does not print "OK"...What do I miss here???
-
I may sound harsh but: proper architecture.
I would suggest to start with something really minimal to just learn to use signals and slots properly, how to manage multiple different complex widgets that are only linked together by signals and slots.
-
I am trying! How can I call a method before declaring it?
-
You just don't.
As I already suggested: start with Qt's basics.
- Single widget with signals and slots within it.
- Second widget completely unrelated to the first one
- Connect them only after they both properly work independently
- While doing that: write unit tests
-
@SGaist Thank you, I will try it.
Please tell me a reason that the code runs commands such as open/make a widget + QLinedit + QLabels (I checked it with print commands) but I see only the widget (window) and nothing inside... What is wrong?
-
@john_hobbyist said in Displaying real-time data on a 2nd window:
What is wrong?
Please show the code, else only guessing is possible!
Did you add these widgets to your container widget (main window or whatever)? -
I am trying to embed a grid layout to the right side of the mainwidget. Imagine that I have divided the mainwidget area into 2 areas, left and side. I get this error though:
File "code.py", line 1643, in __init__ mylayout.addWidget(self.imageviewer, 1, 1) TypeError: addWidget(self, QWidget, stretch: int = 0, alignment: Union[Qt.Alignment, Qt.AlignmentFlag] = Qt.Alignment()): argument 3 has unexpected type 'int'
What did I do wrong?
-
Are you sure mylayout is a QGridLayout ?
-
I have it like this:
mylayout = QHBoxLayout()
-
So since it's a QHBoxLayout, why are you trying to use it like a grid layout ?
The error message tells you exactly the problem you have. If you read the method documentation, you'll see that the second parameter shall be a value from the Alignment enum.
-
This post is deleted! -
@john_hobbyist said in Displaying real-time data on a 2nd window:
mylayout.addWidget(self.imageviewer, 1, 1)
You're not reading @SGaist's replies and understanding/acting on them. Anyway, what do you intend this line to do?
-
-
I call the above class each time the mouse pointer changes position. The problem is that nothing is shown..but the print commands that I have embed between the below commands work!
Why?
I call it like this:w = Town() w.show()
This is the class that I call
class Town(QWidget): def __init__(self): super().__init__() import sys from PyQt5.QtWidgets import QWidget,QPushButton,QApplication,QListWidget,QGridLayout,QLabel from PyQt5.QtCore import QTimer,QDateTime from PyQt5 import QtWidgets from PyQt5.QtWidgets import QApplication, QMainWindow from PyQt5 import QtCore win = QWidget() grid=QGridLayout() import pandas ct = pandas.read_csv('CurrentTown.csv') town = QLabel("town:") town.setStyleSheet("border: 1px solid black; background-color: yellow") grid.addWidget(town, 1,1) textEdit_1 = QLineEdit(ct) textEdit_1.setReadOnly(True) grid.addWidget(textEdit_1,1,2) import os os.remove('CurrentTown.csv') self.setLayout(grid) win.setGeometry(100,100,200,100) win.setWindowTitle("Test") win.show() win.update()
-
@john_hobbyist said in Displaying real-time data on a 2nd window:
I call it like this:
Where?
Please show that part of your code.
Also, why do you create a new QWidget in Town which does not contain anything? Town is already a QWidget. -
@jsulm said in Displaying real-time data on a 2nd window:
@john_hobbyist said in Displaying real-time data on a 2nd window:
I call it like this:
Where?
Please show that part of your code.
Also, why do you create a new QWidget in Town which does not contain anything? Town is already a QWidget.You mean this (?) :
win = QWidget() . . . win.setGeometry(100,100,200,100) win.setWindowTitle("Test") win.show() win.update()
So, class Town(QWidget): makes a widget before the previous code...(?)
-
@john_hobbyist said in Displaying real-time data on a 2nd window:
You mean this
Yes. Why do you need win?
All other widgets you create in Town are added to Town. -
@jsulm said in Displaying real-time data on a 2nd window:
@john_hobbyist said in Displaying real-time data on a 2nd window:
You mean this
Yes. Why do you need win?
All other widgets you create in Town are added to Town.And what I do with these?
win.setGeometry(100,100,200,100) win.setWindowTitle("Test") win.show() win.update()
I call them with self???