How to create function module and connect in with menu.py
Unsolved
General and Desktop
-
I'm so sorry, I'm new to pyqt5 and qt designer, maybe this is a stupid question but help me pls..
The problem is that I'm getting circular import error since in menu.py I'm importing functions.py and in functions.py I am importing menu.pySo this is my menu.py
from PyQt5 import QtCore, QtGui, QtWidgets import functions class CompleterDelegate(QtWidgets.QStyledItemDelegate): def initStyleOption(self, option, index): super(CompleterDelegate, self).initStyleOption(option, index) # option.font.setFamily('Montserrat') # option.palette.setBrush(QtGui.QPalette.Text, QtGui.QColor(112,112,112)) option.font.setBold(True) option.displayAlignment = QtCore.Qt.AlignCenter class Ui_Menu(object): def get_data(self, model): model.setStringList( ["one", "two", "three", "four", "python", "pyqt", "vasyl petrovych"] ) "this is a function i want to import from functions.py" #def move_symptom(self): # selected = self.symptoms_list.currentItem().text() # item = QtWidgets.QListWidgetItem() # self.symptoms_list.takeItem(self.symptoms_list.currentRow() ) # self.selected_symptoms_list.addItem( item ) # item.setText( selected ) # self.symptoms_list.clearSelection() ... ... ...
and this is my functions.py
import menu from PyQt5 import QtCore, QtGui, QtWidgets class AppFunctions(menu.Ui_Menu): def move_symptom(self): selected = menu.ui.self.symptoms_list.currentItem().text() item = QtWidgets.QListWidgetItem() menu.ui.self.symptoms_list.takeItem(menu.ui.self.symptoms_list.currentRow()) menu.ui.self.selected_symptoms_list.addItem( item ) item.setText( selected ) menu.ui.self.symptoms_list.clearSelection()
Thanks in advance!
-
Hi,
You should move your code so that you don't need that circular import.
That said, code generated from designer definition shall not be modified. You usually import these file in your own code that will build stuff on top of it.