Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to remove that messages on console #2

Open
GGTEC opened this issue Jan 8, 2023 · 5 comments
Open

How to remove that messages on console #2

GGTEC opened this issue Jan 8, 2023 · 5 comments

Comments

@GGTEC
Copy link

GGTEC commented Jan 8, 2023

Testing the pyqt-custom-titlebar-setter

I receive that messages on console when i resize or move the window, how i can remove or stop spamming that messages ?
And thanks, you make a god job with that !!

QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore
QPainter::restore: Unbalanced save/restore

@yjg30737
Copy link
Owner

yjg30737 commented Jan 9, 2023

Thanks you.

That message indicates that there are unbalanced number of calls to QPainter::save and QPainter::restore.

And It doesn't happen to me.

Do you use MacOS? Can you show me the code?

That might help me figure out how to solve it

@GGTEC
Copy link
Author

GGTEC commented Jan 9, 2023

Of course!

im using w11

The code is such simple =

`from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtCore import QUrl, Qt
from pyqt_custom_titlebar_setter import CustomTitlebarSetter
from pyqt_style_setter import StyleSetter
from qt_sass_theme import QtSassTheme
import sys

class TextEditor(QWidget):
def init(self):
super().init()
self.__initUi()

def __initUi(self):
    lay = QVBoxLayout()        
    lay.setContentsMargins(0, 0, 0, 0)
    lay.setSpacing(0)
    
    webview = QWebEngineView()
    url = 'Path to HTML file'
    webview.load(QUrl(url))

    lay.addWidget(webview)
    
    self.setLayout(lay)

if name == "main":

app = QApplication(sys.argv)
widget = TextEditor()
StyleSetter.setWindowStyle(widget, theme='dark')
g = QtSassTheme()
g.getThemeFiles(theme='#000000')
g.setThemeFiles(widget)
window = CustomTitlebarSetter.getCustomTitleBarWindow(main_window=widget)
window.show()
sys.exit(app.exec_())`

But have another 'problem' or I don't know how to do this,

The Widget that contains the QWebEngineView does not occupy the entire space of the frame, causing the title bar to drop and there is space above and below the window, in the print screem you can understand (Ignore the close and minimize button, I use this screen in another type of framework
BUG
)

@yjg30737
Copy link
Owner

Now it might work, at least another problem you've brought up

Can't upload this to pypi as a package right now so you have to personally add code below

# to maintain the maximum size intact
def event(self, e):
    if int(e.type()) == 76:
        self.setMaximumHeight(self.sizeHint().height())
    return super().event(e)

in the very end of the
topTitleBarWidget.py script in
pyqt-top-titlebar-widget of
pyqt-custom-titlebar-setter

event() function catches the event

76 stands for LayoutRequest which is one of the QEvent, emit when widget layout needs to be redone.

self.setMaximumHeight(self.sizeHint().height()) is set the maximum height to most appropriate one which can get by sizeHint().height()

I will upload to pypi 10~12 hrs later or maybe more than that

And.. again i've never seen those messages even in the code you provided. As a matter of fact, i'm also use Windows 11.

I wonder which Python version you use..? Mine is Python 3.10

@GGTEC
Copy link
Author

GGTEC commented Jan 10, 2023

Great, the solution worked with my code! Thank you very much.

I'm using python 3.11.0, I'm not using a Venv

@yjg30737
Copy link
Owner

yjg30737 commented Jan 12, 2023

Sorry for belated reply.

I used Python 3.11.1 and global environment to run that and there was no message problem.

Maybe you should upgrade the Python version from 3.11.0 to 3.11.1 but this is just my guessing.

Installing the PyQt all over again is another solution of this.

python -m pip install PyQt5
python -m pip install PyQt5-stubs
python -m pip install PyQtWebEngine --upgrade

If you are using conda environment.. that command might differ (even though i'm using pip and conda at the same environment and there's no problem so far)

Oh, by the way, do you still have that problem?

If so, is the problem that message keep popping up really or harmful to the application? like, does that slow the app down or make it crash? That'll be huge problem.

Frankly i don't know why does that happen in your case. 😔 So only thing i can say is reinstalling the PyQt like anyone can say

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants