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

Unable to set window Icon #64

Open
slahy opened this issue Feb 13, 2018 · 1 comment
Open

Unable to set window Icon #64

slahy opened this issue Feb 13, 2018 · 1 comment
Assignees

Comments

@slahy
Copy link

slahy commented Feb 13, 2018

the following code is not setting the icon on the BaseWidget

from pysettings import conf
import settings
conf+=settings

from pyforms import BaseWidget
import pyforms
from os import path
from PyQt4 import QtGui 

class WinForm(BaseWidget):
    
    def __init__(self):
        ROOT_DIR = path.dirname(path.abspath(__file__))
        iconPath = path.join(ROOT_DIR, 'logo2.ico')
        print iconPath
        
        BaseWidget.__init__(self,'WinForm')
        #BaseWidget.setWindowIcon(self, QtGui.QIcon(iconPath))
        self.setWindowIcon(QtGui.QIcon(iconPath))
   
if __name__ == "__main__":
    pyforms.start_app( WinForm, geometry=(200, 200, 500, 400) )

Is this a bug or is there an issue with my code.

@Josef-A
Copy link

Josef-A commented Mar 14, 2019

I had the same problem. I am new to Qt. But I think that the method setWindowIcon should be a method to the main window. My solution is like this:

from pysettings import conf
import settings
conf+=settings

from pyforms import BaseWidget
import pyforms
from os import path
from PyQt4 import QtGui 

class WinForm(BaseWidget):
    
    def __init__(self):
        BaseWidget.__init__(self,'WinForm')

    def init_form(self):
        super(WinForm, self).init_form()
        ROOT_DIR = path.dirname(path.abspath(__file__))
        iconPath = path.join(ROOT_DIR, 'logo2.ico')
        print iconPath
        self.app_main_window.setWindowIcon(QtGui.QIcon(iconPath))
   
if __name__ == "__main__":
    pyforms.start_app( WinForm, geometry=(200, 200, 500, 400) )

I had to use init_form since the reference to the app_main_window isn't set when _init_ is runned

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

No branches or pull requests

3 participants