I have designed my current GUI with QT Designer. The underlying code creates and starts multiple threads. For each thread I have a set up several QPushButtons: Start, Stop, Pause, Resume, and Status. I'd like to group them, but they are not exclusive, so I need to set the enabled attribute from the signaled slot, for each related button, depending on which button has been clicked. I've tried creating a QButtonGroup for each set of buttons. I can get the sender(), but don't see how to get access to the other buttons which belong to the group. Have tried several things, but having no luck.
OK, I think I have what I need on this. The problem was how to I set the enabled states of buttons in a group based on the identity of the sender?
I have a possible x number of threads that can be controlled. The objectNames of the buttons in each QButtonGroup are as follows:
pushButton_start_x
pushButton_stop_x
pushButton_status_x
pushButton_pause_x
pushButton_resume_x
In my Python code I have the following dictionary:
# Each key represents a button type that requires setting the group's
# buttons enabled state
# Each key's values map to these buttons: [start,stop,status,pause,resume]
testManagerButtonEnableStates = {}
testManagerButtonEnableStates["start"] = [False,True,True,True,False]
testManagerButtonEnableStates["stop"] = [True,False,True,False,False]
testManagerButtonEnableStates["pause"] = [False,False,True,False,True]
testManagerButtonEnableStates["resume"] = [False,True,True,True,False]
This routine sets the states based on the objectName of the sender:
# Note that the status button does not require any action here
def setButtonGroupEnabledStates(self):
buttonType = str(self.sender().objectName().toAscii()).split('_')[1]
if buttonType == "status":
return
i = 0
for button in self.sender().group().buttons():
button.setEnabled(self.testManagerButtonEnableStates[buttonType][i])
i+=1
Maybe not the most efficient, but it gets me there...
Related
When you try to reach the Dalaran Well in Dalaran, you are teleported to the sewers.
It is using this Game object: Doodad_Dalaran_Well_01 (id = 193904 )
Where is it scripted? How?
I've found nothing in the table smart_scripts, and found nothing in the core about this specific id so I'm curious because this type of teleport is really better than clicking on a game object
This gameobject is a unique case because it works like instance teleports do. If you check the gameobject_template table, you will see that it has several Data columns that have diferent values based on the type of the gameobject.
The gameobject you are refering too is the Well It self but the portal gameobject inside the well gives the player a dummy spell to tell the core that the player has been teleported (spell ID 61652).
For the specific case of the dalaran well, it's type is 30 which means, as the documentation says, GAMEOBJECT_TYPE_AURAGENERATOR. As soon as the player is in range, a dummy aura is cast on him to notify the core that this areatrigger has been activated (You could do stuff when player gets hit by the dummy spell).
The trick here is a bunny, but not the bunny itself since it is there mostly to determine an areatrigger. If you use command .go gobject 61148 you can check him out, he's inside the well.
Areatriggers are a DBC object that are actually present on our database on world.areatrigger. You can check the columns here. When the player enters the Radius box specified on the areatrigger, another thing happens in the core which is world.areatrigger_teleport.
If you run the following query you will be able to check the position where the trigger will teleport the player to.
SELECT * FROM areatrigger_teleport WHERE `Name` LIKE '%Dalaran Well teleporter%';
I'm trying to sort a table in SAP in Blue Prism. The code previously worked fine but now I'm getting the following error message when I try to sort the table by context menu item.
The method got an invalid argument
I've tried passing a variety of values to the selectContextMenuItem method: "&SORT_DSC", "&SORT_ASC", "&COL_INV"...all yield the same error.
Dim SAPGuiAuto as Object
Dim SAPApp as Object
Dim SAPCon as Object
Dim session as Object
Dim Table as Object
SAPGuiAuto = Microsoft.VisualBasic.Interaction.GetObject("SAPGUI")
SAPApp = SAPGuiAuto.GetScriptingEngine
SAPCon = SAPApp.Children(0)
session = SAPCon.Children(0)
Table = session.findById("/app/con[0]/ses[0]/wnd[0]/usr/cntlGRID1/shellcont/shell")
Table.setCurrentCell("-1", "LMENGEIST")
Table.selectColumn("LMENGEIST")
Table.contextMenu
Table.selectContextMenuItem("&SORT_DSC")
I expect the column I've selected to be sorted in descending order.
Thanks in advance for any help you can provide.
I know this is an old question but I just started receiving this same error in my C# Console Application (.NET Framework v4.6) after months of the program running autonomously. The only difference is that I was attempting to select a Layout Variant using the filter. Additionally, the application only failed when I ran it as a scheduled task.
First, I did as Sandra suggested and executed the action manually. Whilst doing so, I used SAP's script recording feature to find out if the script used a different argument. I found that the script still used the same argument ("&FILTER"); but I also noticed that the table took a half second to initialize. So I added a few Thread.Sleep() - one after the button click (to give the Variant Select window time to initialize) and one after clicking the context menu (to give the menu time to initialize) - and now, my program now runs as smoothly as it did previously.
//Execute Report
((GuiMainWindow)SAPActive.SAPsession.FindById("wnd[0]")).SendVKey(8);
//Change Layout
((GuiButton)SAPActive.SAPsession.FindById("wnd[0]/tbar[1]/btn[33]")).Press();
Thread.Sleep(2000);
((GuiGridView)SAPActive.SAPsession.FindById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell")).CurrentCellRow = -1;
((GuiGridView)SAPActive.SAPsession.FindById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell")).SelectColumn("VARIANT");
((GuiGridView)SAPActive.SAPsession.FindById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell")).ContextMenu();
Thread.Sleep(2000);
((GuiGridView)SAPActive.SAPsession.FindById("wnd[1]/usr/ssubD0500_SUBSCREEN:SAPLSLVC_DIALOG:0501/cntlG51_CONTAINER/shellcont/shell")).SelectContextMenuItem("&FILTER");
The error message The method got an invalid argument is very specific to SAP GUI Scripting methods, and can be recognized by the missing word has (before got).
It's a general purpose message which is sent when a method of SAP GUI Scripting has an argument which doesn't correspond to an expected value.
In your case, it would probably mean that the item &SORT_DSC does not exist in the context menu. Make sure that if you execute the action manually in the SAP GUI, you see this context menu and the option to sort in descending order.
NB: for information, this message may occur in a variety of other SAP GUI functions, for instance with fileID = application.utils.openfile("file-name.log"), just because the character "-" is not allowed in the file name.
I need to :
1. Create a single page location application
2. Display all the asset present in the selected location in a table
3. Provide a button from which user can navigate to WOTRACK to view all the workorder(s) created on selected location and its asset(s).
I am facing difficulty in the 3rd one. I have tried Launch in Context and it is working fine except am not able to pass sql query like 'location={location} and assetnum in ({asset.assetnum})'. I need to filter workorders with particular location and all its assets.
I tried to save all the assets in the location to a Non-persistant attribute and passing the values of the attribute in the Launch in context url, Its working as expected but to do so I have written a script on 'Initialize value' which is causing performance issues.
script goes like this:
from psdi.server import MXServer;
from psdi.mbo import MboConstants;
if app == "LOCATION1" :
if mbo.getString("LOCATION") is not None:
Locsite = mbo.getString("SITEID")
desc = mbo.getString("DESCRIPTION")
MaxuserSet = MXServer.getMXServer().getMboSet("MAXUSER", mbo.getUserInfo())
MaxuserSet.setWhere(" userid='"+user+"' ")
MaxuserSet.reset()
UserSite = MaxuserSet.getMbo(0).getString("DEFSITE")
if Locsite == UserSite:
AssetSet = mbo.getMboSet("ASSET")
AssetSet.setFlag(MboConstants.DISCARDABLE, True);
if not AssetSet.isEmpty():
AssetList = ""
AssetMbo = AssetSet.moveFirst()
while AssetMbo is not None:
AssetList = AssetList + str(AssetMbo.getString("ASSETNUM")) + "%2C"
AssetMbo = AssetSet.moveNext()
mbo.setValue("non-persitant",str(AssetList),11L)
and in the LIC url i have given : 'http://xx.x.x.xx/maximo/ui/?event=loadapp&value=wotrack&tabid=List&additionalevent=useqbe&additionaleventvalue=location={LOCATION}|assetnum={non-persistant}'
Is there any other feasible solution to the requirement?
Thanks in Advance
Launch In Context is better used for sending the user to an outside-of-Maximo application and passing along some data from inside-Maximo to provide context in that external app.
What you are doing sounds like a good place to use a workflow process with an Interaction node. The developer tells the Interaction node which app to take the user to and which Relationship to use to find the data the user should work with there.
Why don't you add a table control inside the table details (expanded table row) and show a list of the work orders there. From the WONUM in that table, you could have an app link to take them to WOTRACK, if they want more details about a particular work order. No customization (automation scripting) needed. No workflow needed. Nice and simple.
I would like to solve the following issue:
agent based model with a population of 500 agents
each agent gets assigned with an ID number using a variable called v_agentID using the order v_agentID++; after being created
The agent should then be further processed based on a condition monitoring the individual waiting time
How can I assign individual attributes like waiting times (as a result of the calculation waitingTime=waitingTimeEnd-waitingTimeStart)to each individual agent?
Thanks a lot for your help.
Bastian
Many ways:
1) create a cyclical event on the individual agent that calculates waitingTime with the formula you provided
2) create a dynamic variable for each agent and make it equal to waitingTimeEnd-waitingTimeStart
3) create the variable whenever you want and change it in all the agents:
for(Agent a : agents){
a.waitingTime=a.waitingTimeEnd-a.waitingTimeStart;
}
4) Find the agent with the id you want and assign the variable to it
Agent theAgent=findFirst(agents,a->a.id=theIdYouWant);
theAgent.waitingTime=theAgent.waitingTimeEnd-theAgent-waitingTimeStart;
5) If you know the index of the agent just do
agents.get(index).waitingTime=agents.get(index).waitingTimeEnd-agents.get(index).waitingTimeStart
I'm trying to mask the answer options that show up in a 3DGrid question item in Confirmit, using the value of a background variable.
E.g. when "background1" ==1, display answer category 1. If "background1" ==0, do not display answer category 1. If "background2" ==1, display category 3, otherwise do not. In any case, display answer category 2.
Hopefully this is easy for someone out there (I'm a psychologist, not a coder...so not so much so for me :/)
Thanks!
In order to access the data inside a question/variable we can use the f function of confirmit.
for instance:
f('my_question_id').get();
When masking a question, we need to pass in a Set object so Confirmit knows what Code's to show and not to show.
Often you will mask using a Set from a previous question. So you pass in the question_id and Confirmit does all the other magic.
Here we have the problem of not having a Set, so we will have to create our own.
For this, there are 2 approaches (can be found in the scripting manual under Working with Sets > Methods of the set Object > add and remove and Working with Sets > User defined functions...)
I'm going to stick to the first one because it is easier to use ;)
What we will do first is create a script node (it doesn't matter where you create it, just somewhere in the survey, I often have a folder Functions with all my script nodes in somewhere at the bottom of my survey)
In that script file we will have our function that crates our set:
function CreateMyAwesomeSet()
{
//create an empty Set
var mySet = new Set();
//if background1 equals 1, add 1 to our Set
if ( f('background1').get() == '1' )
{
mySet.add(1);
}
//return the Set of allowed Codes
return mySet;
}
Here we declare a function that we now can use wherever we want to.
So now, If we want to use this Set, we add a Code Mask to your grid:
CreateMyAwesomeSet()
You can ofcourse change the name of the function, and add extra if statements.
hope this helps