guys how to separate child to parent?
kivy.uix.widget.WidgetException: Cannot add <kivymd.uix.card.MDCard object at 0x000001EBCBFFB0B8>
it already has a parent <kivymd.uix.list.MDList object at 0x000001EBCF105B38>.
I can separate mdcard object and add a new widget.
To remove a widget from its parent you have to use remove_widget function. If you want to remove all widgets from a parent, you can use clear_widgets function. You can check more details here.
I would appreciate if you provide some code so that I can correct it
Related
I'm little confusing meaning of widgets instance creation in PyQt.
Seems QWidget(self) can create a widget.
But what's the meaning of QWidget(instance name)?
For exmaple,
grid_layout = QGridLayout(self)
test_label = QWidget(grid_layout)
I know test_label created inherited from gridlayout.
But what's the meaning during program meaning?
Is that meaning test_label widget is under grid_layout?
For many of the widgets when the signature is just a single parameter like in both of your examples, the argument given sets the created widget/layouts parent.
So in your first example, using self as the argument means that the parent of the QGridLayout and the widget that the layout will be applied to is whatever widget self is.
In the second example you are setting the parent of QWidget to be the widget represented by it's argument. A QWidget with no parent becomes a new window, when set with a parent then the widget becomes a child window within the parent widget.
Neither one are inheriting anything. Inheritance only occurs during Subclassing.
I understand that QLabel attributes such as frameGeometry, pixmap and text can be recovered using their respective commands. But is it possible to get the value of "frame shadow" around each of these label widgets?
I have 3 Labels placed inside a Frame (inside a Window) using qt-designer. I assigned shadows for each of these labels by calling self.label_1.setFrameShadow(QFrame.Raised) or self.label_1.setFrameShadow(QFrame.Plain) within the QMainWindow class.
Now I wish to update their shadow attributes after checking to see if one of them is Raised or Plain. The error says that: 'QLabel' object has no attribute 'FrameShadow'. But why so if I was able to set it?
QLabel inherits from QFrame and therefore has an accessor frameShadow() for that property.
Unlike in other frameworks, Qt accessors don't start with get...
How can I make a childWindow access and/or modify an attribute from his MainWindow?
I have a MainWindow that opens different childWindows, dependeing on the pressed button on the MainWindow.
I would like any of the childWindows to be able to modify some attributes of the MainWindow, but I cannot get the good way to access them.
When defining your widget or window (your window is possibly just a QWidget), specify it's parent in the init-Method (just pass the parent-widget).
After that, you could use the parentWdiget-Method or simply set a "link" to the parent-widget in an attribute of the child-window.
See http://srinikom.github.io/pyside-docs/PySide/QtGui/QWidget.html
You could pass a reference (self) to your childwindow.
My question is related to this one where a Text widget is used.
However, in my case I want to rebind the select all on the entry widget.
I tried the following which allows me to use Ctrl+w to select all input in the entry field:
self.frmSearch = Frame()
self.txtSearch = Entry(self.frmSearch, bd=1, width=35)
self.txtSearch.bind('<Control-w>',lambda e: self.txtSearch.select_range(0, END))
However, once I change Ctrl+w to Ctrl+a this does not work anymore and no text is selected. Does anyone have an explanation why?
It is because you are putting the binding on the widget rather than the widget class, and by default the bindings on the class fire after the bindings on the widget.
The way Tkinter processes events is to first see if there is a binding on a widget, then on a class, and then on the toplevel window, and then finally on the special class "all". The events are processed in order unless you break the chain of events, so to speak. So, your control-w binding happens, but then the binding on the class happens and effectively undoes what you you did in your binding.
The best solution is to 1) not use lambda, but instead use a real method or function, and 2) do a "return 'break'" which prevents the class and other bindings from firing. Or, if you want this binding to affect all entry widgets in your application rather than just a specific one, use bind_class giving the class name of 'Entry'.
The question you refer to you in your question has an answer that gives an example of changing the class binding.
i have a wxlistbox in a class and i want to update the data inside the listbox from a different class.Is i possible to reload the class while leave the control from another class?if yes ,how?
eg:
i have two classes,Class A and Class B.In class A there is a wxlistbox.while starting the program class A initilise the wxlistbox and bind some values.when a button inside class A clicked it call another frame class B.while close the frame B the wxlistbox inside class A should update.
My question is how to refresh listbox while close the frame B?
I would use the SetItems() method, which according to the docs does the following: "Clear and set the strings in the control from a list".
Edit: myListCtrl.SetItems(ListOfStrings)
That will replace all the items in the control with whatever is in the list.