How do you load all images at a time in pygame? - path

I'm trying to load all these images at once. Their all in the same directory so is there a way to load them all at once without being this repetitive?
bg = pygame.image.load('Desktop/Files/Dungeon Minigame/background.png')
f_zombie = pygame.image.load('Desktop/Files/Dungeon Minigame/f_zombie.png')
f_knight = pygame.image.load('Desktop/Files/Dungeon Minigame/f_knight.png')
b_knight = pygame.image.load('Desktop/Files/Dungeon Minigame/b_knight.png')
r_knight = pygame.image.load('Desktop/Files/Dungeon Minigame/r_knight.png')
heart = pygame.image.load('Desktop/Files/Dungeon Minigame/heart.png')
empty_heart = pygame.image.load('Desktop/Files/Dungeon Minigame/empty_heart.png')

Get a list of all the files in the directory (see os) and create a dictionary with the loaded files:
import os
path = 'Desktop/Files/Dungeon Minigame/'
filenames = [f for f in os.listdir(path) if f.endswith('.png')]
images = {}
for name in filenames:
imagename = os.path.splitext(name)[0]
images[imagename] = pygame.image.load(os.path.join(path, name)).convert_alpha()
You can access the images in the dictionary by its name:
screen.blit(images['background'], (0, 0))
Alternatively you can add variables to global namespace, using globals():
path = 'Desktop/Files/Dungeon Minigame/'
filenames = [f for f in os.listdir(path) if f.endswith('.png')]
for name in filenames:
imagename = os.path.splitext(name)[0]
globals()[imagename] = pygame.image.load(os.path.join(path, name)).convert_alpha()
screen.blit(background, (0, 0))

Related

ImageLabel doesn't display in BillboardGUI

So, this is my problem.
This script works with one image id, but not any others.
I literally have no idea why this is happening.
This is the script >>
function newEntity(imgId, eName)
EntityBase = Instance.new("Part", workspace)
EntityBase.Transparency = 1
EntityBase.Size = Vector3.new(0.9, 0.1, 0.7)
EntityBase.Name = eName
EntityBillboardGui = Instance.new("BillboardGui", EntityBase)
EntityBillboardGui.StudsOffset = Vector3.new(0, 5, 0)
EntityBillboardGui.Size = UDim2.new(0,250,0,250)
EntityBillboardGui.MaxDistance = math.huge
EntityBillboardGui.Adornee = EntityBase
EntityImage = Instance.new("ImageLabel",EntityBillboardGui)
EntityImage.Size = EntityBillboardGui.Size
EntityImage.BackgroundTransparency = 1
EntityImage.Image = imgId
return EntityBase
end
troller = newEntity("rbxthumb://11954446780","imposter")
troller.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
trololol = Instance.new("Sound", troller)
trololol.SoundId = "http://www.roblox.com/asset/?id=5677788502"
trololol:Play()
wait(2)
troller:Destroy()
game.Players.LocalPlayer.Character.Humanoid.Health = 0
Can anybody help fix it?
For starters I would recommend seperating the parent, like this:
EntityBase = Instance.new("Part") EntityBase.Parent = workspace
SECOND: I would recommend not using a seperate part, just put the billboardGui into the player's head
third you used rbxthumb wrong
rbxthumb://type=[ThumbnailType]&id=[TargetId]&w=[Width]&h=[Height]”
These are the supported sizes and types
example: rbxthumb://type=Avatar&id=123456789&w=720&h=720

I want to put RDF/XML format directly in SDB

In Jena, I saved RDF/XML documents in SDB using the "read()" method and even created a file with RDF/XML documents in SDB using the "write" method.
What I want to try is to save Triple directly in SDB.
Here is my code
prefix = "http://example.org/terms/";
ns = "ex";
model.setNsPrefix(ns, prefix);
prefix3 = "http://www.w3.org/1999/02/22-rdf-syntax-ns";
ns3 = "rdf";
model.setNsPrefix(ns3, prefix3);
prefix6 = "http://www.test/2022/#";
ns6 = "base";
model.setNsPrefix(ns6, prefix6);
for(i = 0; i<index; i++) {
Resource s_A = model.createResource(A[i].o);
Property p_A = model.createProperty(prefix3);
Resource s_B = model.createResource(B[i].s);
Property p_B = model.createProperty(B[i].p);
Resource s_C = model.createResource(C[i].s);
Property p_C = model.createProperty(C[i].p);
//model.add(s_A, p_A, prefix6); //wish <ex:Description rdf:about=baseURI+"ID">
model.add(s_A, p_B, B[i].o); //wish <ex:Description.type>1</ex:Description.type>
model.add(s_A, p_C, C[i].o); //wish <ex:Description.open>0</ex:Description.open>
//wish </ex:Description>
}
I know this(model.add(s_A, p_A, prefix6);) part is wrong, but I don't know which method I use to wish. I don't know what else to do here.

How to manipulate my dataset when making an input in flexdashboard?

I dont know how to call my dataset and manipulate it
fileInput(inputId = "file",
label = h4("Input File .csv"), fonte
multiple = F,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")
)
In this area I can generate my table from my upload
rv = reactiveValues(data = NULL)
observe({
req(input$file)
inFile = input$file
data2 = read.csv2(inFile$datapath, stringsAsFactors = FALSE)
save(data2, file = "dataread.RData")
rv$data = data2
})
DT::renderDataTable({
req(rv$data)
rv$data
})
But from here i don't know how to call it and handle it

ELKI CSV parser problems

I have changed an .arff file to a .csv file in a tool in Weka.
But now I can't use the arffparser as parser in ELKI.
What parser should I then use? The default is NumberVectorLabelParser. But it gives me a ArrayIndexOutOfBoundsException:
Running: -verbose -verbose -dbc.in /home/db/lisbet/Datasets/without ids/try 2/calling them .txt using another parser/Lymphography_withoutdupl_norm_1ofn.csv -dbc.parser NumberVectorLabelParser -algorithm outlier.lof.LOF -lof.k 2 -evaluator outlier.OutlierROCCurve -rocauc.positive yes
Task failed
java.lang.ArrayIndexOutOfBoundsException: 47
at de.lmu.ifi.dbs.elki.datasource.parser.NumberVectorLabelParser.getTypeInformation(NumberVectorLabelParser.java:337)
at de.lmu.ifi.dbs.elki.datasource.parser.NumberVectorLabelParser.buildMeta(NumberVectorLabelParser.java:242)
at de.lmu.ifi.dbs.elki.datasource.parser.NumberVectorLabelParser.nextEvent(NumberVectorLabelParser.java:211)
at de.lmu.ifi.dbs.elki.datasource.bundle.MultipleObjectsBundle.fromStream(MultipleObjectsBundle.java:242)
at de.lmu.ifi.dbs.elki.datasource.parser.AbstractStreamingParser.asMultipleObjectsBundle(AbstractStreamingParser.java:89)
at de.lmu.ifi.dbs.elki.datasource.InputStreamDatabaseConnection.loadData(InputStreamDatabaseConnection.java:91)
at de.lmu.ifi.dbs.elki.database.StaticArrayDatabase.initialize(StaticArrayDatabase.java:119)
at de.lmu.ifi.dbs.elki.workflow.InputStep.getDatabase(InputStep.java:62)
at de.lmu.ifi.dbs.elki.KDDTask.run(KDDTask.java:108)
at de.lmu.ifi.dbs.elki.application.KDDCLIApplication.run(KDDCLIApplication.java:60)
at [...]
My .csv file looks like this:
'Lymphatics = deformed','Lymphatics = displaced','Lymphatics = arched','Lymphatics = normal','Block_of_affere = yes','Block_of_affere = no','Bl_of_lymph_c = no','Bl_of_lymph_c = yes','Bl_of_lymph_s = no','Bl_of_lymph_s = yes','By_pass = no','By_pass = yes','Extravasates = yes','Extravasates = no','Regeneration_of = no','Regeneration_of = yes','Early_uptake_in = yes','Early_uptake_in = no','Changes_in_lym = oval','Changes_in_lym = round','Changes_in_lym = bean','Defect_in_node = lacunar','Defect_in_node = lac_central','Defect_in_node = lac_margin','Defect_in_node = no','Changes_in_node = lac_central','Changes_in_node = lacunar','Changes_in_node = no','Changes_in_node = lac_margin','Changes_in_stru = faint','Changes_in_stru = drop_like','Changes_in_stru = stripped','Changes_in_stru = coarse','Changes_in_stru = diluted','Changes_in_stru = grainy','Changes_in_stru = no','Changes_in_stru = reticular','Special_forms = vesicles','Special_forms = no','Special_forms = chalices','Dislocation_of = no','Dislocation_of = yes','Exclusion_of_no = yes','Exclusion_of_no = no',Lym_nodes_dimin,Lym_nodes_enlar,No_of_nodes_in,Outlier
1,0,0,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0,0,1,0,1,0,0,0.333333,0.285714,no
0,1,0,0,1,0,1,0,1,0,1,0,0,1,1,0,1,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0.333333,0.142857,no
There are 11 parsers available. But maybe it is my data, that is to large for the parser.
Thank you, this is a bug in the ELKI CSV parser.
It did not expect the class column to have a label.
So if your remove the ,Outlier part of your first line (or the first line completely), it should read this file just fine.
I will push a change that makes it more robust here (it will still lose the label though, because ELKI currently has support column labels for numerical columns but not for string label columns).

OpenOffice Draw macro to find replace text

I'm looking to find replace text within multiple PDF documents using Draw. Thus far I've managed to open the PDF however
mydoc.createReplaceDescription
appears not to be a valid property / method on a Draw doc. Although oddly this is used in many examples for writer and calc.
Are there any alternatives?
Okay after some playing around with the recorder in the Writer I managed to record a macro that seems to be more general purpose than the createReplaceDiscription I was trying earlier.
It's got a lot of bumf that I guess could be cleaned up but it works...
REM ***** BASIC *****
Sub Main
End Sub
sub WriterFindReplace
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(18) as new com.sun.star.beans.PropertyValue
args1(0).Name = "SearchItem.StyleFamily"
args1(0).Value = 2
args1(1).Name = "SearchItem.CellType"
args1(1).Value = 0
args1(2).Name = "SearchItem.RowDirection"
args1(2).Value = true
args1(3).Name = "SearchItem.AllTables"
args1(3).Value = false
args1(4).Name = "SearchItem.Backward"
args1(4).Value = false
args1(5).Name = "SearchItem.Pattern"
args1(5).Value = false
args1(6).Name = "SearchItem.Content"
args1(6).Value = false
args1(7).Name = "SearchItem.AsianOptions"
args1(7).Value = false
args1(8).Name = "SearchItem.AlgorithmType"
args1(8).Value = 0
args1(9).Name = "SearchItem.SearchFlags"
args1(9).Value = 65536
args1(10).Name = "SearchItem.SearchString"
args1(10).Value = "<<THE WORD YOUR FINDING>>"
args1(11).Name = "SearchItem.ReplaceString"
args1(11).Value = "<< THE WORD YOUR USING TO REPLACE>>"
args1(12).Name = "SearchItem.Locale"
args1(12).Value = 255
args1(13).Name = "SearchItem.ChangedChars"
args1(13).Value = 2
args1(14).Name = "SearchItem.DeletedChars"
args1(14).Value = 2
args1(15).Name = "SearchItem.InsertedChars"
args1(15).Value = 2
args1(16).Name = "SearchItem.TransliterateFlags"
args1(16).Value = 1280
args1(17).Name = "SearchItem.Command"
args1(17).Value = 3
args1(18).Name = "Quiet"
args1(18).Value = true
dispatcher.executeDispatch(document, ".uno:ExecuteSearch", "", 0, args1())
end sub

Resources