Issue
I am a beginner in Python as well as pyside. I have a .ui file and I want to open it as a second window on clicking a button in main window. I used this code but it closes the main window perhaps because of "self". Please help me out.
class PhoneBook:
def __init__(self):
loader = QUiLoader();
file = QFile("PhoneBook.ui");
file.open(QFile.ReadOnly);
self.ui = loader.load(file);
file.close();
self.ui.pushButton.clicked.connect(self.add);
def __del__ ( self ):
self.ui = None;
def add(self):
loader1 = QUiLoader();
file1 = QFile("Add.ui");
file1.open(QFile.ReadOnly);
self.ui = loader1.load(file1);
file1.close();
self.ui.show();
def show(self):
self.ui.show();
Solution
I'm noob too. About how to make dialog, I think your point is input dialog where you want to enter data for that phonebook. The easiest way I found is such :
txtLabel = "Put some value into dialog"
inputText, ok = QInputDialog.getText(self, "Dialog Name", txtLabel)
if ok:
print ".........."
print inputText
...and that's for the simplest dialog for some string input (QInputDialog). If you need more demanding dialog (and you will, sooner or later), you should use QDialog base class. In that case what exactly you want to put into it, how it will looks like and everything about it's behaviour. On PySide DOCS almost everything is nice explained.
Answered By - Alex
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.