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 use pyqtconfig module #25

Open
Zythyr opened this issue Jun 20, 2020 · 2 comments
Open

Unable to use pyqtconfig module #25

Zythyr opened this issue Jun 20, 2020 · 2 comments

Comments

@Zythyr
Copy link

Zythyr commented Jun 20, 2020

I am unable to import or run the pyqtconfig module. Below is example of error I get. I have PySide2 and PyQt5 installed already.

PS C:\Users\MyUsername> python -m pyqtconfig.demo
Traceback (most recent call last):
  File "C:\Users\MyUsername\anaconda3\lib\runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "C:\Users\MyUsername\anaconda3\lib\runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "C:\Users\MyUsername\anaconda3\lib\site-packages\pyqtconfig\__init__.py", line 1, in <module>
    from .config import *
  File "C:\Users\MyUsername\anaconda3\lib\site-packages\pyqtconfig\config.py", line 11, in <module>
    from .qt import (QComboBox, QCheckBox, QAction,
ImportError: cannot import name 'QComboBox' from 'pyqtconfig.qt' (C:\Users\MyUsername\anaconda3\lib\site-packages\pyqtconfig\qt.py)
PS C:\Users\MyUsername>
@kushfest
Copy link

I'm getting the exact same error message.

@meramsey
Copy link

meramsey commented Jul 5, 2020

Yeah likewise.

I just changed mine to use the regular qtpy module which i have installed.

import sys
from pyqtconfig import ConfigManager

from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import (QVariant, Qt, QMutex, QMutexLocker, QSettings,
                              QObject, Signal)
from qtpy.QtWidgets import (QComboBox, QCheckBox, QAction,
                                 QActionGroup, QPushButton, QSpinBox,
                                 QDoubleSpinBox, QPlainTextEdit, QLineEdit,
                                 QListWidget, QSlider, QButtonGroup,
                                 QTabWidget, QApplication, QGridLayout,
                                 QTextEdit, QWidget, QMainWindow)

class MainWindow(QMainWindow):

    def __init__(self):
        super(MainWindow, self).__init__()

        self.setWindowTitle('PyQtConfig Demo')
        self.config = ConfigManager()

        CHOICE_A = 1
        CHOICE_B = 2
        CHOICE_C = 3
        CHOICE_D = 4

        map_dict = {
            'Choice A': CHOICE_A,
            'Choice B': CHOICE_B,
            'Choice C': CHOICE_C,
            'Choice D': CHOICE_D,
        }

        self.config.set_defaults({
            'number': 13,
            'text': 'hello',
            'active': True,
            'combo': CHOICE_C,
        })

        gd = QGridLayout()

        sb = QSpinBox()
        gd.addWidget(sb, 0, 1)
        self.config.add_handler('number', sb)

        te = QLineEdit()
        gd.addWidget(te, 1, 1)
        self.config.add_handler('text', te)

        cb = QCheckBox()
        gd.addWidget(cb, 2, 1)
        self.config.add_handler('active', cb)

        cmb = QComboBox()
        cmb.addItems(map_dict.keys())
        gd.addWidget(cmb, 3, 1)
        self.config.add_handler('combo', cmb, mapper=map_dict)

        self.current_config_output = QTextEdit()
        gd.addWidget(self.current_config_output, 0, 3, 3, 1)

        self.config.updated.connect(self.show_config)

        self.show_config()

        self.window = QWidget()
        self.window.setLayout(gd)
        self.setCentralWidget(self.window)

    def show_config(self):
        self.current_config_output.setText(str(self.config.as_dict()))

# Create a Qt application
app = QApplication(sys.argv)
app.setOrganizationName("PyQtConfig")
app.setOrganizationDomain("martinfitzpatrick.name")
app.setApplicationName("PyQtConfig")

w = MainWindow()
w.show()
app.exec_()  # Enter Qt application main loop

image

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

3 participants