It looks like you're new here. If you want to get involved, click one of these buttons!
More Edits trying too add QDialogButtonBox and trying to display it
Any help would be appreciated
#ButtonBox
self.first = QLineEdit(self)
self.second = QLineEdit(self)
buttonBox = QDialogButtonBox.new(self);
layout = QFormLayout(self)
layout.addRow("First text", self.first)
layout.addRow("Second text", self.second)
layout.addWidget(buttonBox)
self.setLayout(layout)
self.setWindowTitle("Form Layout - KLayout")
def getInputs(self):
return (self.first.text(), self.second.text())
So Deleted Previous Post after Banging the mouse all day here is the Code For pya GUI
with several examples, much simpler and cleaner
import pya
class GuiDialog(pya.QDialog):
"""
This class implements a Gui Dialog With Several Examples
"""
view = pya.Application.instance().main_window().current_view()
def __init__(self, parent = None):
""" Dialog constructor """
super(GuiDialog, self).__init__()
# text input
text= QInputDialog.getText(self, 'getText', 'Enter text', QLineEdit.Normal, "")
print(text)
# multi-line input
text = QInputDialog.getMultiLineText(self, 'getMultiLineText', 'Story', "Enter story")
print(text)
# enter double
double = QInputDialog.getDouble(self, 'getDouble', 'Enter double', 22.33, -10000, 10000, 2)
print(double)
# enter integer
int= QInputDialog.getInt(self, 'getInteger', 'Enter number', 25, 0, 100, 1)
print(int)
# select option
items = ["Spring", "Summer", "Fall", "Winter"]
item = QInputDialog.getItem(self, 'getItem', 'Favourite season', items, 0, False)
print(item)
# Instantiate the dialog and make it visible initially.
# Passing the main_window will make it stay on top of the main window.
dialog = GuiDialog(pya.Application.instance().main_window())
Comments
@tagger5896 Thanks too for sharing this ... although I sense some frustration and I can't see your original post. I hope the issues have not been too severe.
Matthias
Matthias
The scope is too document all the gui inputs ,
documentation is sparse, and I think it will help.
I am stuck with the following from a previous post
I see how it get's the click but can't get the inputs from the text inputs too print out
or cancel or end the button click.
Yes it's frustrating , I can copy paste all online QDialog examples into Spyder and works as supplied
not so much with Klayout
Hi @tagger5896 ,
Maybe I can help you with your struggle. Could you quickly explain what you are trying to accomplish with the click?
I am not exactly sure what you are trying to accomplish, but the text is in
first.text
orsecond.text
from your example. So if you just print out those it works.I have a somewhat more complex Qt-Dialog in my repo https://github.com/sebastian-goeldi/kgit/blob/master/python/kgit/menu.py , though I never finished it because it is too slow and unresponsive (at least for my taste). Let me know if you would like some explanations or how to do certain things in Qt as I have had my fair share of struggles with Qt-Dialogs in KLayout (though I have to say kudos to @Matthias for even exposing the API to make Qt interactions possible).
Thanks for your input Sebastian,
This works well in Spyder with python 3.7
not so much in Klayout
Hi @tagger5896 ,
As I mentioned before, KLayout doesn't use the exact same stuff as pyqt. It is more close to the C++ Qt. Therefore you have to change some stuff in your code. You can get a running example as follows. The
GroupBox
is quite different and the text of the lineedits can be called directly by.text
, i.e. it's an attribute not a function. Full working code below.sebastian,
tyvm for clairfying this I am still new too Python and Ruby flavors of Klayout we all are at some point
Tracy
Update thanks to Sebastian for multi-line input, slowly getting there , it's progress
@sebastian Thanks a lot for your assistance.
And yes, KLayout's Qt isn't pyqt. The reason is that I started with Ruby about ten years ago and qtruby (the pyqt equivalent, which AFAIK isn't maintained any longer) was not evolved. After integrating Python I looked at pyqt but found it's difficult to integrate with a C++ application. Hence the homegrown solution.
Anywhy, but @tagger5896, is there a reason you importing tkinter? And "GuiDialog" isn't really a Dialog - it's merely a function that tries a couple of modal single-value query dialogs, right? The other Dialog looks much more like a real Qt dialog
Regards,
Matthias
Matthias
it was a cut and paste from Spyder I had been using EasyGui