Why is the (PyQt5) QWidget not being added to the QBoxLayout - user-interface

Right so essentially I am creating a user interface and have attempted to add a QtWidgets.QLineEdit to a QVBoxLayout as well as a QtWidgets.QLabel to a different QVBoxLayout. Unfortunately it is not working and throwing up an error:
in build_gui_adddata_device
self.labellayout.addWidget(self.labelsupplierid)
TypeError: QBoxLayout.addwidget(QWidget; int stretch=0, Qt.Alignment alignment=0): first argument of unbound = method must have type QBoxLayout
I have defined labellayout as thus:
print("e")
self.labellayout = QtWidgets.QVBoxLayout
"e" was printed, which is how I know that there is no issue with the definition of the layout itself.
Just for reference this is the QtWidget I was trying to add:
print("f")
self.labelsupplierid = QtWidgets.QLabel("Supplier ID: ")
Again "f" was printed
This is the line that is causing the problem:
print("i")
self.labellayout.addWidget(self.labelsupplierid)
I don't understand why my code isn't working, I am honestly perplexed. My syntax seems to be correct and I have made other build_gui functions that have executed exactly the same type of code (with different widgets, might I add) that have been successful.
Please can someone enlighten me. Many Thanks.

Related

Appinventor : Property setter was expecting a com.google.appinventor.components.runtime.ImageSprite component but got a String instead

i'm currently working on a Naughts and Crosses game in MIT App Inventor 2, and have run into the error in the title, i believe i've narrowed it down to a specific block of my code (the easyBot procedure) but i cannot isolate the issue from there, i have provided source code for perusal, can anyone find the issue here?
source code: https://www.dropbox.com/s/plw8has3df47diw/XOXOXOXO_checkpoint1.aia?dl=0
error : Property setter was expecting a com.google.appinventor.components.runtime.ImageSprite component but got a String instead

PyCharm debugger doesn't show objects' content: "Unable to get repr for <type 'list>"

Debugging with PyCharm (happens on multiple versions) I'm unable to correctly view some lists and dictionaries (other are presented correctly).
In the view window the object's name is presented with the message:
{list} Unable to get repr for <type 'list>
or
{dict} Unable to get repr for <type 'dict'>
An update:
In one of my attempts, I received the following message from the debugger (presented instead of the value of one of the list variable):
Unable to display children:Error resolving variables Traceback (most
recent call last): File "/Applications/PyCharm
CE.app/Contents/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line
1004, in do_it
_typeName, valDict = pydevd_vars.resolve_compound_variable(self.thread_id, self.frame_id,
self.scope, self.attributes) TypeError: 'NoneType' object is not
iterable
I'll appreciate any idea as for what may cause this behavior?
Thanks!
It turned out the problem is due to usage of rpyc.py: The process I was debugging was called through rpyc and while I was debugging it, the calling process received a timeout on the rpyc connection.
I think that this caused variables, passed through rpc to lose integrity so the debugger couldn't present them correctly.
The solution was to downgrade rpyc.py to version 3.3.0 (I was on 3.4.2).
My colleague, Nurit Izraelov, correctly suggested the rpyc.py version may be the blame.
Thanks all!
It happened to me sometimes and what caused the behaviour was that some MyClass triggered an exception on its str method.
In such a case, PyCharm debugger only showed
some_object = {MyClass} Unable to get repr for <class 'my_app.models.MyClass'>
So what I did to confirm the origin was to watch repr(some_object) in the Watches section of the debugger. And there it gave me an explicit error message:
{TypeError}%d format: a number is required, not NoneType
Which helped me trace back to the origin.
I appreciate this is not a generic answer, but just a complement to Fabio's.
Probably some custom class of yours has a bad __repr__ or __str__ in it and the debugger is unable to print it.
You can probably use a shell at that point to know which elements are actually inside such a dict or list (and see which object has the faulty __repr__ or __str__).
Extending the scope of the problem rather than adding an answer - all the other suggestions are what I do normally to get this working.
Could it be a race condition?
For me it appears to be something weird. In the Variables pane I can see correct representation for theObject, repr(theObject) and even [theObject] but if I set a variable in my code thus a = theObject or b = [theObject] then I get the "Unable to get repr for <class 'list'>" message.
theObject in this case is an instance of a subclassed D lang struct wrapped with autowrap.

OS X Swift Compiler Error - Segmentation Fault

I am making some variable declarations in a NSViewController custom class. The declarations are:
var filterSettings: Dictionary<String, String> = ["Location": "All", "Status": "All", "PPRDate": "All", "Project Manager": "All"]
let locationFilterSettings: Set = ["All", "Newcastle", "Sydney", "ACT & Southern NSW", "Western Sydney", "Grafton"]
let statusFilterSettings: Set = ["All", "Active", "Inactive"]
var PPRDateFilterSettings: Set<NSDate> = [] // this value needs to be set programiticaly by loading up the available PPR Dates --- use PPRDateFilterSettings.insert(dateVariable)
var projectManagerFilterSettings: Set<String> = [] // this value needs to be set programatically by loading up the available PMs
When the program compiles I get one error that shows up in the issues navigator: - a compiler error is not shown against any particular line in the code.
When I go to the issue navigator it shows against this class the following error. All other classes compile correctly with no errors:
"Swift Compiler Error Command failed due to signal: Segmentation fault: 11"
I admit to not knowing how to debug this error.
I do know that if I comment out the let locationFilterSettings.. line in the code that the compiler error goes away.
I have just added this code for the variables shown above and do make any other reference to the filterSettings valuable yet. No other changes have been made to the code which was compiling and running as expected.
Any advice on where/how to debug the issue please let me know. I am not sure what to do next.
I should add that I am running the latest version of Xcode and OSX.
I have also tried playing with optional declaration as suggested in one of the answers here:-->Swift compiler segmentation fault when building but to no avail.
EDIT: Some additional information.
I deleted and re-installed Xcode. The error still occurred.
Having declared the variables within the class I wasn't actually referencing them within any functions so I tried println the variables at a few spots in the code. The error still occurred.
I moved the declarations from the global level within the class to within one of the functions. The error disappeared.
So- three above partially solved the issue for me. I wanted the variables to be available through the class so now I may need to pass them around as parameters (which seems to work). However, I still do not understand why the error was occurring and if it was a syntax thing that I was missing.
Ok - I have now been able to compile the code without an error with the properties declared at the top of the Class.
The issue was the use of the short form declaration relying on the type of item being inferred.
let propertyName: Set = ["item1", "item2"]
when I initialised the property using the following syntax
let propertyName: Set<String> = ["item1", "item2"]
it compiled without an error. The short form declaration worked when the property was declared within a function.

AX2012 - Pre-Processed RecId parameter not found

I made a custom report in AX2012, to replace the WHS Shipping pick list. The custom report is RDP based. I have no trouble running it directly (with the parameters dialog), but when I try to use the controller (WHSPickListShippingController), I get an error saying "Pre-Processed RecId not found. Cannot process report. Indicates a development error."
The error is because in the class SrsReportProviderQueryBuilder (setArgs method), the map variable reportProviderParameters is empty. I have no idea why that is. The code in my Data provider runs okay. Here is my code for running the report :
WHSWorkId id = 'LAM-000052';
WHSPickListShippingController controller;
Args args;
WHSShipmentTable whsShipmentTable;
WHSWorkTable whsWorkTable;
clWHSPickListShippingContract contract; //My custom RDP Contract
whsShipmentTable = WHSShipmentTable::find(whsWorkTable.ShipmentId);
args = new Args(ssrsReportStr(WHSPickListShipping, Report));
args.record(whsShipmentTable);
args.parm(whsShipmentTable.LoadId);
contract = new clWHSPickListShippingContract();
controller = new WHSPickListShippingController();
controller.parmReportName(ssrsReportStr(WHSPickListShipping, Report));
controller.parmShowDialog(false);
controller.parmLoadFromSysLastValue(false);
controller.parmReportContract().parmRdpContract(contract);
controller.parmReportContract().parmRdpName(classStr(clWHSPickListShippingDP));
controller.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
controller.parmArgs(args);
controller.startOperation();
I don't know if I'm clear enough... But I've been looking for a fix for hours without success, so I thought I'd ask here. Is there a reason why this variable (which comes from the method parameter AifQueryBuilderArgs) would be empty?
I'm thinking your issue is with these lines (try removing):
controller.parmReportContract().parmRdpContract(contract);
controller.parmReportContract().parmRdpName(classStr(clWHSPickListShippingDP));
controller.parmReportContract().parmRdlContract().parmLanguageId(CompanyInfo::languageId());
The style I'd expect to see with your contract would be like this:
controller = new WHSPickListShippingController();
contract = controller.getDataContractObject();
contract.parmWhatever('ParametersHere');
controller.parmArgs(args);
And for the DataProvider clWHSPickListShippingDP, usually if a report is using a DataProvider, you don't manually set it, but the DP extends SRSReportDataProviderBase and has an attribute SRSReportParameterAttribute(...) decorating the class declaration in this style:
[SRSReportParameterAttribute(classstr(MyCustomContract))]
class MyCustomDP extends SRSReportDataProviderBase
{
// Vars
}
You are using controller.parmReportContract().parmRdpContract(contract); wrong, as this is more for run-time modifications. It's typically used for accessing the contract for preRunModifyContract overloads.
Build your CrossReference in a development environment then right click on \Classes\SrsReportDataContract\parmRdpContract and click Add-Ins>Cross-reference>Used By to see how that is generally used.
Ok, so now I feel very stupid for spending so much time on that error, when it's such a tiny thing...
The erronous line is that one :
controller.parmReportName(ssrsReportStr(WHSPickListShipping, Report));
Because WHSPickListShipping is the name of the AX report, but I renamed my custom report clWHSPickListShipping. What confused me was that my DataProvider class was executing as wanted.

DbLimitExpression requires a collection argument

Does anyone have the faintest idea what this error means please and how to resolve it? All my research is drawing a blank, I can see how to set it on MSDN but it doesn't explain it in a way that explains to me what the issue is. If I remove some of my LINQ queries to set viewbag items then it seems to resolve it but the moment I set new ones and pass them into my view to generate a mail for MVCMailer it comes back. Not sure if its a viewbag issue or simply that I am calling too many linq queries to generate them to pass to the view.
I am very stuck (again)..........
Cheers,
Steve.
DbLimitExpression requires a collection argument.
Parameter name: argument
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: DbLimitExpression requires a collection argument.
Parameter name: argument
An example of the code is:
var VBSalutation = from A in context.Salutations
where A.SalutationId == policytransaction.SalutationId
select A.SalutationName;
ViewBag.Salutation = VBSalutation.FirstOrDefault();
This is repeated for various parameters and then passed to the view.
Well, I faced a similar problem and solved it. Problem was in WHERE clause: data type of left side equal operator (=) sign was not matching with data type of right side. So in your scenario:
where A.SalutationId == policytransaction.SalutationId
SalutationID of A might be an INT and SalutationId of policytransaction might be a string (This is how it was in my case).
I solved it by assigning policytransaction.SalutationId to an Int variable and using it:
int myIntVariable = Convert.ToInt16(policytransaction.SalutationId);
...//some code here
where A.SalutationId == myIntVariable;
Please also note that you cannot directly cast your variables directly in Linq else you'll get an error "LINQ to Entities does not recognize the method". You'll have to use a temp variable and then apply the where clause.
Try ViewBag.Salutation = VBSalutation.SingleOrDefault();

Resources